Examples
Two .warp workflows, both verified to compile against the live runtime at
https://warp.aimer.ma.
| File | What it shows |
|---|---|
cart_recovery.warp |
A cart abandoned for 30 minutes triggers a customer-profile lookup and a WhatsApp reminder. The compiler checks that profile.phone is a PhoneNumber before it reaches WhatsAppSend.to. |
post_purchase.warp |
A post-purchase thank-you. Demonstrates two commerce-model invariants: capacity verification before a commitment is Accepted (I-3), and Commitments forming before Fulfillments execute (I-4). |
Compile one
Replace your-tenant-id with your tenant id, then:
jq -Rs --arg t "YOUR_TENANT_ID" '{tenant_id:$t, warp_source:.}' cart_recovery.warp \
| curl -s -X POST https://warp.aimer.ma/api/v1/workflows/compile \
-H "content-type: application/json" \
-H "X-Warp-API-Key: YOUR_API_KEY" \
--data @-
See the Getting Started guide for how to get a tenant id and API key.
Warp workflow files
The DSL workflows shipped in the repository’s examples/ directory:
cart_recovery.warp
project "cart_recovery" {
version = "1.0.0"
tenant = "your-tenant-id"
CartAbandoned trigger {
min_value: Currency(200, MAD)
after: Duration(30, minutes)
}
ACPGetCustomerProfile profile {
customer_id: trigger.customer_id
}
WhatsAppSend message {
to: profile.phone
template: "cart_reminder"
lang: profile.language
params: { cart_value: trigger.cart_value }
}
}
post_purchase.warp
project "post_purchase_thank_you" {
version = "1.0.0"
tenant = "your-tenant-id"
// Capacity-verification comes first: the model won't let an order reach
// Accepted until the buyer (a Party) is known — Invariant 3.
ACPGetCustomerProfile profile {
customer_id: "cust_demo"
}
OrderPlaced order {
min_value: Currency(150, MAD)
}
// Commitments form before Fulfillments execute — Invariant 4 — so the delay
// and the message are declared after the order.
DelayFor wait {
duration: Duration(2, hours)
}
WhatsAppSend thank_you {
to: profile.phone
template: "order_thank_you"
lang: profile.language
}
}
Quickstart — TypeScript
Verified to run as written against the published package:
import { order } from "@warp-lang/commerce-types";
const built = order()
.from("buyer_1").to("seller_1")
.item({ sku: "TSHIRT-RED-M", price: { amount: 200, currency: "MAD" } })
.paid().fulfilled()
.build();
if (built.ok) {
const violations = built.value.audit(); // [] — clean
}
Quickstart — Python
from warp_commerce_types import Money, party_id, new_commitment, transition_commitment, add
total = add(Money(amount=200, currency="MAD"), Money(amount=30, currency="MAD"))
order = new_commitment(party_id("buyer"), party_id("seller"))
proposed = transition_commitment(order, {"type": "Proposed"}, party_id("buyer"))
print(proposed.ok, proposed.value.state.type if proposed.ok else None)
Live playground
Prefer to try it without installing? The interactive playground runs the real published package in your browser.