Workflow automation lets users define "when this happens, do these steps" flows inside your SaaS. It is intentionally small and hackable: triggers, step JSON, execution logs, and server-side dispatch helpers.
Built-in triggers
The default trigger list lives in src/lib/workflows/index.ts and includes:
user.createduser.updatedsubscription.createdsubscription.canceledsubscription.pausedpayment.successpayment.failedteam.member_addedteam.member_removedfeature_request.created
Add your own product events to AVAILABLE_TRIGGERS.
Built-in actions
| Action | Purpose |
|---|---|
send_email | Send an email through the Email module |
webhook | POST event data to a URL |
slack | Send a Slack webhook message |
delay | Wait before continuing |
set_property | Update a user or organization property |
API
| Route | Method | Purpose |
|---|---|---|
/api/workflows | GET | List workflows |
/api/workflows?query=options | GET | Return available triggers and actions |
/api/workflows?query=runs&id=... | GET | Return workflow runs |
/api/workflows | POST | Create, update, or delete a workflow |
Dispatching events
Call dispatchWorkflowEvent when a product event occurs:
import { dispatchWorkflowEvent } from '@/lib/workflows';
await dispatchWorkflowEvent('subscription.created', {
userId,
plan: 'pro',
subscriptionId,
});
Only active workflows with a matching trigger run. Each run is written to workflow_run with status, results, and errors.
Feature flag
ENABLE_WORKFLOWS="false"
Disabling the flag hides workflow routes and dashboard surfaces.