How do you chase an unpaid invoice without chasing someone who paid?
The reminders stop by themselves when the invoice is paid. A reminder goes out when the invoice falls due, then the workflow waits a week for the payment. If it arrives, the run ends there and the final notice is never sent. If it does not, the last message goes to the account owner.
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 call it makes into Palumb: trigger for invoiceDue on topic.invoice-77. 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 invoice.paid, 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/invoiceDue: your workflow file itself, 15 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. 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: none of them is, 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: 7 days for step.waitForEvent, 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 3 tokens, the bubble says run complete, and the line is empty: the drawing is the finished picture of this path.
invoice-due.ts
import { workflow } from "@palumb-com/sdk"
import { reminder, finalNotice } from "../emails"
workflow("invoiceDue", async ({ payload, step }) => {
await step.send("reminder", "email", () => reminder(payload))
// durable: a deploy in the middle does not lose it
const paid = await step.waitForEvent("paid", {
event: "invoice.paid",
timeout: "7d",
})
if (paid) return
return step.send("final", "email", () => finalNotice(payload), { to: payload.accountOwner })
})
How it works
The workflow starts when the invoice falls due (trigger), and the reminder goes out at once (step 1). Then it waits (step 2) up to seven days for your app to say the invoice was paid. A payment on any of those days ends the run on the spot, and there is nothing scheduled that you have to go and cancel.
In this example nobody pays. The seven days run out, the wait gives up, and the final notice goes out (step 3) to the account owner rather than to whoever received the reminder.
Related: nudging a user who never came back, which uses the same wait for the opposite purpose: there, the silence is what makes the message go out.
Everyone who joins gets in, and it costs nothing. Your invite goes out when the beta opens.
Join the beta