How do you warn before a trial ends, and stop the moment they upgrade?
The warning stops itself the moment the user upgrades. A fourteen day trial. Nothing goes out for the first eleven days, but the workflow is listening the whole time: pay on day two and no warning ever arrives. If nobody pays, three warnings follow, each one closer to the deadline, and each one is dropped as soon as the payment lands.
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 trialEnding on topic.user-58 and sendEvent for subscription.upgraded. 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 subscription.upgraded, waiting subscription.upgraded and waiting subscription.upgraded, 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/trialEnding: your workflow file itself, 23 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.waitForEvent, 2 for step.send, 3 for step.waitForEvent, 4 for step.send, 5 for step.waitForEvent, 6 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: 11 days for step.waitForEvent, run out in full and 2 days for step.waitForEvent, cut short by the event on day 1. 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. On this path the run ends before the file does: step.send, step.waitForEvent and step.send are never reached, so no mark appears in the margin of those lines at all, only the line number.
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.
trial-ending.ts
workflow("trialEnding", async ({ payload, step }) => {
const early = await step.waitForEvent("quiet", {
event: "subscription.upgraded",
timeout: "11d",
})
if (early) return
await step.send("three-days", "email", () => threeDaysLeft(payload))
const late = await step.waitForEvent("warned", {
event: "subscription.upgraded",
timeout: "2d",
})
if (late) return
await step.send("tomorrow", "email", () => endsTomorrow(payload))
const last = await step.waitForEvent("final", {
event: "subscription.upgraded",
timeout: "1d",
})
if (last) return
return step.send("ended", "email", () => trialEnded(payload))
})
How it works
The workflow starts when the user begins the trial (trigger). For the first eleven days it just listens (step 1): if the payment arrives now, the workflow stops right there.
If eleven days pass with no payment, the first warning goes out (step 2): three days left. It listens again (step 3) for two more days, and in this example that is when the payment arrives (sendEvent) and the workflow stops.
If nobody pays in time, two more warnings are waiting in the file: one for the day after, the last for when the trial ends. This path never reaches them.
The same shape, driven by activity instead of payment: nudging a user who signed up and never came back, where the sequence runs longer before the user acts.
Everyone who joins gets in, and it costs nothing. Your invite goes out when the beta opens.
Join the beta