Online orders need to land in the ERP for invoicing and in the warehouse for fulfillment. On a normal day this is fine. On a campaign day, it is thousands of orders per minute, and any of them can fail because the ERP is slow, the warehouse API is down, or the connection drops.
Losing an order means losing money and losing trust. Processing the same order twice is just as bad. And once volume picks up, the simple "send and pray" integration that worked last year starts dropping things silently.
dataflows handles every order as a durable workflow. The order is first saved in your own database, so it is never lost. Then it is pushed to the ERP and the warehouse, with retries if either system is busy.
Every order is processed exactly once, even if the shop sends the webhook twice. If the ERP is down, the workflow waits and retries instead of failing. If something is permanently broken, it shows up in the dashboard so the team can fix it without losing the order.
// Order sync workflow
export const orderSync = defineWorkflow({
id: 'order-sync',
trigger: shop.onOrderCreated(),
async run({ event, step }) {
const order = event.payload
const isNew = await step.run('persist', () =>
db.orders.insertIfMissing(order)
)
if (!isNew) return { status: 'skipped' }
await step.run('sync-erp', {
retries: 5,
backoff: 'exponential'
}, () =>
erp.createSalesOrder(order)
)
await step.run('sync-warehouse', () =>
warehouse.reserveStock(order)
)
await step.run('mark-synced', () =>
db.orders.update(order.id, { status: 'synced' })
)
return { status: 'synced' }
}
})