Skip to main content
A workflow is what you’d reach for n8n, Zapier, or Gumloop to do: a PR is merged, you post to Slack, then open a Linear ticket. In Corsair it’s a webhook hook, so the steps are ordinary TypeScript with types and your own helpers available. There’s no DAG to define and no separate engine to run. Pattern: the webhook fires, the hook runs, then it calls any plugin’s .api.

The shape

Every webhook event accepts an after hook, which runs once the event is saved to your database. Inside it you have the full corsair instance:
These examples assume multiTenancy: true (the quick-start setup), so they scope each call with corsair.withTenant(ctx.tenantId). On a single-tenant instance, drop withTenant and call the plugin .api directly.
corsair.ts
That’s the whole workflow. Chaining more steps means writing more lines, each one a normal await:
Because these are function calls rather than a graph, branching and early returns are just if statements.

Filtering with before

Use before to drop events you don’t care about. Throwing stops processing, and the event isn’t written to your database:
corsair.ts
Filtering in before is cheaper than filtering in after, since it avoids the write.

Slow work belongs in a queue

Webhook senders expect a fast response. If a step calls an LLM, sends email, or generates a report, hand it to a job queue and return:
corsair.ts
inngest/functions.ts
Pass ctx.tenantId through to the job, since the queue worker runs outside the request and has to re-scope itself. Adapters for Inngest, Temporal, Trigger.dev, and Hatchet all follow this shape.

Multi-tenant workflows

Hooks receive the tenant on ctx, so one definition serves every customer:
Don’t hardcode channel IDs or team IDs when the app is multi-tenant. Read them from your own settings table.

Checklist

  • Events you don’t want are rejected in before, not ignored in after.
  • Anything slow is queued; hooks return quickly.
  • ctx.tenantId is threaded through to background jobs.
  • Per-tenant destinations come from your settings, not constants.
  • Hooks are idempotent where the provider may redeliver an event.

What’s next

Workflows guide

More patterns, including Slack to GitHub and multi-step chains.

Webhooks setup

Get a tunnel running and register your first endpoint.

Hooks reference

The full before/after API surface.

Dashboard

Surface what your workflows produced.