Approve the easy ones automatically. Route the rest to a person.

Most requests follow a rule, and a few need judgement. A Volvel flow applies the rule, sends the rest to the right group with a link in their email, and records every decision.

A stock order, start to finish.

At Fernhill's clinics, a check every half hour finds stock running low. The supplier is asked for a price. A small order is placed at once; a large one waits for a practice manager.

  • The threshold lives in the quote script, so changing it is a reviewed change, not a setting someone forgot.
  • Only practice managers may decide. The phone assistant can see that an order waits, and can't approve it.
  • A refusal is recorded, so the stock line is checked again next time instead of being forgotten.
  • The same flow can be started by hand, or by an agent, with the same fields the event carries.

The whole thing is one file.

This is the flow, shortened from the Fernhill example. Draw it in the console's flow editor or write it like this; it's the same thing either way.

  • What the approver sees is chosen here: the clinic, the item, the quantity, the total and what's on hand.
  • The error path from the approval is where a rejection or a timeout goes.
  • The run waits days without holding a worker, and a restart or a deploy in the middle doesn't lose it.
examples/fernhill/src/flows.tsdefineFlow
export const reorder = defineFlow({
  path: "inventory/reorder",
  nodes: {
    low: trigger.event(stockLow),
    by_hand: trigger.manual({ input: StockLine }),
    quote: step.script(quoteOrder, { input: "{'sku': trigger.sku, …}" }),
    route: step.branch({ large: "steps.quote.output.needs_approval" }),
    approve: step.approval("Approve a stock order", {
      detail: "{'clinic': trigger.clinic, 'item': trigger.item, …}",
      timeoutSeconds: 3 * 24 * 3600,
      approvers: { groups: ["practice-managers"] },
    }),
    place: step.script(placeOrder, { input: "…" }),
    refused: step.script(recordRefusedOrder, { input: "…" }),
  },
  edges: [
    ["low", "quote"], ["by_hand", "quote"], ["quote", "route"],
    ["route", "approve", { when: "large" }],
    ["route", "place", { when: "otherwise" }],
    ["approve", "place"],
    ["approve", "refused", { error: true }],
  ],
});

Shortened from examples/fernhill.

What a workflow needs, already there.

The parts that usually turn a simple approval into a project of its own.

NeedHow it's handled
The right peopleA step names groups or roles. A person needs the approval permission and a place in one of them, so having admin rights elsewhere isn't enough.
Reaching themEach approver gets an email with a link of their own. It opens Approve and Reject with no sign-in, works once, and stops when anyone decides or after 48 hours.
Enough to decideThe step chooses what the approver sees, and the queue shows its first fields, so nobody has to open each one to know what it's about.
Nobody decidingA timeout per step. When it passes, the request takes the same path as a rejection.
A recordEach decision and its comment are kept under the person's name, with "decided from the mail" where it was.
The right placeAn approval belongs to its workspace. A step can also list it on the tenant's page, for a decision that matters beyond one team.
Many at onceApprove or reject a selection together, each one recorded as if decided alone.

More from the examples.

Each of these is in the repository, and runs as written.

Lending a device
Lakeshore's Tech Desk approves calculators and chargers at once. A laptop, a hotspot or an iPad waits three days for someone in the Tech Desk group, then is denied.
A large order
Acme's orders over 1,000 wait for approval before they go to the ERP. The rest go straight through, and every one is recorded with how it ended.
After a visit
Fernhill writes the invoice, then texts the owner. A text that fails doesn't undo the invoice: its error path notes the problem and the flow ends cleanly.
Chasing unpaid invoices
Every Monday, each invoice unpaid for two weeks gets a text, four at a time. One owner who can't be reached doesn't stop the rest, and the run counts both.
A public form
New clients register on a form the platform serves. The answer is written to a table and announced as an event, for the front desk to call back.
Started by an agent
The phone assistant can start a reorder with the same fields the stock check sends, and the same approval applies.

Put the rule in the flow, and the judgement with a person.

Approvals, timeouts and a record of every decision, in open-source Volvel.