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.
How Workflows Work
Section titled “How Workflows Work”- An event triggers the workflow (e.g.,
purchase) - The workflow evaluates conditions
- Actions execute in sequence or parallel
- Results are recorded for audit
Example: Purchase Reward Workflow
Section titled “Example: Purchase Reward Workflow”{ "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" } } ]}Available Actions
Section titled “Available Actions”| Action | Description |
|---|---|
credit_points | Add points to customer’s wallet |
debit_points | Remove points from wallet |
send_notification | Send email/push notification |
apply_promotion | Apply a promotion to the customer |
update_metadata | Update customer metadata |
webhook | Call an external webhook |
Workflow Conditions
Section titled “Workflow Conditions”Conditions support rich comparison operators:
| Operator | Description |
|---|---|
eq | Equal to |
neq | Not equal to |
gt | Greater than |
gte | Greater than or equal |
lt | Less than |
lte | Less than or equal |
in | Value in array |
contains | String contains |