# Workflow builder

> Workflow definitions a tenant edits as an engine-neutral node graph, with draft, published and archived versions, triggers (webhook tokens stored hashed), credential references a CredentialProvider resolves, a synced step library, per-node run status pinged on the run's topic, and failed and slow alerts written as workflow_alert.triggered outbox events.

- Category: Automation
- Module: `workflow-editor`
- Modes: `managed`, `custom`
- Docs: https://bettersupabase.com/docs/blocks/workflow-editor
- Page: https://bettersupabase.com/blocks/workflow-editor

## Install

```bash
npx better-supabase add workflow-editor
```

The command also installs `updated-at`, `memberships`, `permissions`, `workflows`.

## Configure

Add the block to `better-supabase.config.ts`:

```ts
import { defineConfig } from "better-supabase/config";

export default defineConfig({
  blocks: {
    // Required by workflow-editor; add installs them too.
    "updated-at": {},
    memberships: {},
    permissions: {},
    workflows: {},
    // Modes: "managed", "custom". The default is "managed".
    "workflow-editor": { mode: "managed" },
  },
});
```

## Client

The React hooks are in `better-supabase/blocks/workflow-editor/react`. They return data and actions and render no UI. Source: https://github.com/ScaleDockHQ/better-supabase/blob/main/packages/better-supabase/src/blocks/workflow-editor/react/index.ts

## Events

- `workflow.published`
- `workflow_alert.triggered`

## Related blocks

Requires: [workflows](https://bettersupabase.com/blocks/workflows.md), [memberships](https://bettersupabase.com/blocks/memberships.md), [permissions](https://bettersupabase.com/blocks/permissions.md)

Works with: [service-accounts](https://bettersupabase.com/blocks/service-accounts.md), [subjects](https://bettersupabase.com/blocks/subjects.md), [teams](https://bettersupabase.com/blocks/teams.md)

## Recipes

- [Workflow canvas](https://bettersupabase.com/recipes/workflow-canvas.md): A node editor for a workflow definition that saves drafts, publishes versions and runs the workflow.
