Skip to content

Workflows

How the work runs: each Team's Processes, the Workflows that run them, what starts each one, and the Approvals they wait on.

A Process is a job the business does again and again, owned by one Role on one Team. Its Workflows run it, the same way whether an agent or a person holds the seat.

LayerWhat it isExample
TeamOwns its Processes and the Metrics that judge themFinance Team
ProcessThe job: its outcome, accountable Role, Settings and service levelBilling
WorkflowThe steps that do the job, started by a TriggerDunning, every day
StepOne Verb called as one Role, under its Permissions and Limits; past a Limit it waits on an ApprovalInvoice.collect as the Billing Specialist
ActionOne execution of a Workflow, kept foreverDunning on the 3rd, done

Most Processes are on from the first day for every Product Template. You change one by saying what you want.

You sayProcessIt changes
Retry failed payments four timesBillingdunning.retries
Ask me before any charge over $500Expense approvalspend.askAbove
Answer new leads within five minutesInbound salesinbound.answerWithin
Close the books by the fifth business dayBooksclose.businessDay
Pay suppliers on FridaysSupplier payoutspayouts.day
Remind me before the annual report is dueCompany filingsturns it on
Answer our phoneCall routingturns it on

Each sentence becomes one call:

Text
Retry failed payments four times
Read nextFor
ProcessesEvery Process by Team, with its Workflows
How a Workflow runsSteps, failures, service levels, and turning a Process on or off
TriggersThe four ways a Workflow starts
ApprovalsWhere a step waits for a yes
RhythmEvery Workflow by when it starts: the operating week

Guides.

You sayGuideCallsStatus
Ask me before big refundsAsk me before big refundsProcess.enable, Setting.updatelive
When a customer reaches one year with us, email them a thank-you from me and give them a free monthAutomate a workflowProcess.create, Coupon.create, Workflow.create, Trigger.createbeta
Announce every releaseAnnounce every releaseWorkflow.create, Trigger.createlive
Answer privacy requestsAnswer privacy requestsProcess.enable, Setting.updatelive
Card charges under $500 are fine without meApprove card charges over $500Process.enable, Setting.updatelive
Chase unpaid invoicesChase unpaid invoicesProcess.enable, Setting.updatelive
Close the books every monthClose the books every monthProcess.enable, Setting.updatelive
Escalate hard support questions to meEscalate hard support questions to meProcess.enable, Setting.updatelive
Pay suppliers every FridayPay suppliers every weekProcess.enable, Setting.updatelive
Qualify leads and book demosQualify leads and book demosLead.qualify, Meeting.booklive
Remind me before the annual report is dueRemind me before the annual report is dueProcess.enable, Setting.updatelive
Test two onboarding emailsTest two onboarding emailsExperiment.create, Experiment.startlive
Welcome every new customerWelcome every new customerProcess.enable, Setting.updatelive
Turn on the Monday Role reviewTurn a process on or offProcess.enable, Setting.updatelive

Processes by Team

The number counts each Process’s Workflows.

One Workflow, end to end

  1. TriggerSubscription.renewedthe twelfth renewal
  2. StepsCoupon.create → Subscription.update → Message.createeach durable, each retried
  3. ApprovalApproval.approvea high-stakes, one-way step waits for you
workflows/loyalty/one-year-thanks.mdx
You, to your agent

When a customer reaches one year with us, give them a free month and thank them from me.

Ask me before each free month goes out.

# 1. Process.create
curl -X POST https://api.sb/leaseline.app/processes \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"First-year thanks"}'

# 2. Coupon.create
curl -X POST https://api.sb/leaseline.app/coupons \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"duration":"once","percentOff":100}'

# 3. Workflow.create
curl -X POST https://api.sb/leaseline.app/workflows \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"steps":{"check":"Stop unless this renewal starts the second year.","thank":"Email the Customer a thank-you from dana@leaseline.app.","credit":"Apply the free-month Coupon to the next Invoice."},"retries":3}'

# 4. Trigger.create
curl -X POST https://api.sb/leaseline.app/triggers \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"event":"Subscription.renewed"}'
import { $ } from 'startup-builder'

await $.Process.create({ name: 'First-year thanks' })
await $.Coupon.create({ duration: 'once', percentOff: 100 })
await $.Workflow.create({ steps: { check: 'Stop unless this renewal starts the second year.', thank: 'Email the Customer a thank-you from dana@leaseline.app.', credit: 'Apply the free-month Coupon to the next Invoice.' }, retries: 3 })
await $.Trigger.create({ event: 'Subscription.renewed' })
npx startup-builder do Process.create --json '{"name":"First-year thanks"}'
npx startup-builder do Coupon.create --json '{"duration":"once","percentOff":100}'
npx startup-builder do Workflow.create --json '{"steps":{"check":"Stop unless this renewal starts the second year.","thank":"Email the Customer a thank-you from dana@leaseline.app.","credit":"Apply the free-month Coupon to the next Invoice."},"retries":3}'
npx startup-builder do Trigger.create --json '{"event":"Subscription.renewed"}'
{
  "name": "do",
  "arguments": {
    "code": "await $.Process.create({ name: 'First-year thanks' })\nawait $.Coupon.create({ duration: 'once', percentOff: 100 })\nawait $.Workflow.create({ steps: { check: 'Stop unless this renewal starts the second year.', thank: 'Email the Customer a thank-you from dana@leaseline.app.', credit: 'Apply the free-month Coupon to the next Invoice.' }, retries: 3 })\nreturn await $.Trigger.create({ event: 'Subscription.renewed' })"
  }
}
---
stakes: high
---
## Thank a customer at one year {#one-year-thanks}

When a Subscription renews for the twelfth month, the customer
gets a free month and a note from Dana.

```ts
on.Subscription.renewed(async ($, { subscription }) => {
  if (subscription.renewals < 12) return
  const coupon = await $.step('coupon', () =>
    $.Coupon.create({ percentOff: 100, duration: 'once' }))
  // stakes: high, so this one-way step waits for an Approval.
  await $.step('apply', () =>
    $.Subscription.update({ id: subscription.$id, coupon: coupon.$id }))
  await $.step('thank', () =>
    $.Message.create({ to: subscription.customer, template: 'one-year' }))
})
```
The founder’s form is Automate a workflow; the file’s reference is Workflows in Code.