Skip to content
← Use cases

How do you follow an order all the way to feedback?

Three messages, and the middle one waits for the parcel to leave. The confirmation goes out the moment the order is placed. The tracking email waits for your warehouse to say the order has shipped, and carries the tracking number that did not exist before. Three days later, once the parcel has had time to arrive, a request for feedback goes out.

Three groups, one under the other, and a single vertical line running down outside them on the left that marks the flow of data. Nothing travels along that line. Instead the stretch between two ends fills, from whoever is calling toward whoever is called, holds while that one works, and then drains back the way it came. The fill is always the same grey, the ink of the Palumb mark: the line belongs to Palumb, and which end the fill starts from already says who placed the call. It carries a small stop at every height where something happens.

First group, yourapp.com/backend: your own application, and the calls it makes into Palumb: trigger for orderPlaced on topic.order-24 and sendEvent for order.shipped. Neither the bubble nor its mark exists until you make that call, and the mark is a small teal square that fills in once Palumb has it. While a call is in flight the bubble's border turns and the line below it fills down to Palumb.

Second group, palumb, the durable engine: the one that is not an address, because it is not something you run. It appears when the trigger arrives, and holds one bubble that says running workflow, except while it is waiting: then it names what it waits for, waiting order.shipped and delay, with the elapsed count in front where the wait has a limit. At the end it says run complete. Its border turns for as long as the run lives, through every wait. Just under it the journal grows, one small violet token per step that has closed, each carrying that step's number.

From the second group the fill runs down to the exact row that is about to run, and stops on it. It is not the channel of the call: your workflow is one signed endpoint, and the body replays from the top with the completed steps rehydrated until it reaches the row it has not run yet. The line is the flow of control, and control really does end up on that row.

Third group, yourapp.com/workflows/orderPlaced: your workflow file itself, 14 lines of TypeScript, with its line numbers. In the margin of every line that calls a step there is a numbered circle, the way an editor marks a breakpoint: 1 for step.send, 2 for step.waitForEvent, 3 for step.send, 4 for step.delay, 5 for step.send. At rest the margin holds only the line numbers; a step's number appears when that step starts running.

When the fill reaches a row, a band lights it, the way a debugger marks where it has stopped, and the ring in its margin turns. The moment the step is recorded the number leaves the margin, a tick takes its place, and the number reappears as a token in the row under Palumb: you wrote the step, we are the ones who remember it ran.

Not every wait is ended by an event: some are not, and those run out their clock instead. While that happens the line down to your code is grey and empty and no row is lit, while the run stays alive in Palumb. That is the frame that matters: for as long as the wait lasts your server does nothing at all and ours does.

While the run waits, the Palumb mark leaves its column and a small clock takes its place, its hand turning once for every unit of time that goes by, and the bubble puts the elapsed count in front of what it is waiting for: day 6, waiting order.shipped. The hand is fast on purpose: it is there to say that the time is moving, not to be counted.

Each wait has its own limit, taken from the code: 30 days for step.waitForEvent, cut short by the event on day 6 and 3 days for step.delay, run out in full. A wait that runs out counts up to its limit; one an event closes stops where the event arrived, and that is the number the bubble ends on.

The drawing follows one path through the code. An if has two ways out and the animation takes the one this page is about; the other ways are in the file, which is printed in full below.

At rest, which is also what anyone who has asked for less motion sees, every step the run reached is ticked, the journal holds its 5 tokens, the bubble says run complete, and the line is empty: the drawing is the finished picture of this path.

order-placed.ts

workflow("orderPlaced", async ({ payload, step }) => {
  await step.send("confirmation", "email", () => confirmation(payload))

  const shipped = await step.waitForEvent("shipped", {
    event: "order.shipped",
    timeout: "30d",
  })
  if (!shipped) return

  await step.send("tracking", "email", () => tracking(shipped))

  await step.delay("cool-off", { seconds: 3 * 24 * 3600 })
  return step.send("feedback", "email", () => feedback(payload))
})

How it works

The workflow starts when the order is placed (trigger), and the confirmation goes out straight away (step 1). Then it waits (step 2) for the warehouse, for up to thirty days, and nothing of yours is running in the meantime.

When your app says the order has shipped (sendEvent), the tracking email goes out (step 3) with the tracking number that event carried. The workflow then waits three days (step 4), long enough for the parcel to arrive, and asks for feedback (step 5).

The same wait, used to stop a message instead of sending one: there the event that arrives ends the run.

Everyone who joins gets in, and it costs nothing. Your invite goes out when the beta opens.

Join the beta