Skip to content

Workflows

Workflows let you automate multi-step business logic that triggers in response to events. They are powered by the workflow execution engine built on Durable Objects.

  1. An event triggers the workflow (e.g., purchase)
  2. The workflow evaluates conditions
  3. Actions execute in sequence or parallel
  4. Results are recorded for audit
{
"name": "Purchase Points Reward",
"trigger": {
"event": "purchase"
},
"steps": [
{
"type": "condition",
"check": {
"field": "amount",
"operator": "gte",
"value": 1000
}
},
{
"type": "action",
"action": "credit_points",
"params": {
"amount": "{{ event.amount / 100 }}",
"reason": "Purchase reward for order {{ event.metadata.orderId }}"
}
},
{
"type": "action",
"action": "send_notification",
"params": {
"template": "points_earned",
"channel": "email"
}
}
]
}
ActionDescription
credit_pointsAdd points to customer’s wallet
debit_pointsRemove points from wallet
send_notificationSend email/push notification
apply_promotionApply a promotion to the customer
update_metadataUpdate customer metadata
webhookCall an external webhook

Conditions support rich comparison operators:

OperatorDescription
eqEqual to
neqNot equal to
gtGreater than
gteGreater than or equal
ltLess than
lteLess than or equal
inValue in array
containsString contains