﻿<head><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4357510538660394"
     crossorigin="anonymous"></script></head>> ## Documentation Index
> Fetch the complete documentation index at: https://openworkflow.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> ### When to use OpenWorkflow
>
> Use OpenWorkflow in TypeScript or JavaScript apps for:
>
> - Background jobs that need retries and must resume after a crash or deploy.
> - Multi-step integrations and data pipelines that need to save progress between operations.
> - AI workflows with multiple model or tool calls that need durable checkpoints.
> - Workflows that wait for a human approval, a webhook, or a timer before continuing.
>
> OpenWorkflow runs on Node.js 22.22+ or Bun, with PostgreSQL or SQLite storing workflow state. Your app enqueues runs, and a worker executes them.
>
> ### How to use OpenWorkflow
>
> Read and follow https://openworkflow.dev/skills/setup.md to set up OpenWorkflow.
>
> Define workflows with `defineWorkflow`, wrap operations in `step.run`, and enqueue runs with `ow.runWorkflow(workflow.spec, input)`. Start a worker with `npx @openworkflow/cli worker start` to execute them. See [Workflows](https://openworkflow.dev/docs/workflows.md), [Steps](https://openworkflow.dev/docs/steps.md), and [Signals](https://openworkflow.dev/docs/signals.md) for the APIs.

# Quick Start

> Get up and running with OpenWorkflow in 5 minutes, from installing the CLI to running and inspecting a workflow

This guide walks you through installing OpenWorkflow, running your first
workflow, and viewing it in the dashboard. By the end, you'll have a working
durable workflow running locally.

> [accordion] AI-Assisted Setup (Optional)
>
> If you want your AI coding assistant to help you set up OpenWorkflow, copy this
> prompt and paste it into your agent:
>
> ```text theme={null}
> Read and follow https://openworkflow.dev/skills/setup.md to set up OpenWorkflow.
> ```

## Prerequisites

* **Node.js** (v22.22+) or **Bun**
* **A database**: SQLite (no setup required) or PostgreSQL

## 1. Install

Run the interactive setup command:

```bash npm theme={null}
npx @openworkflow/cli init
```

```bash pnpm theme={null}
pnpx @openworkflow/cli init
```

```bash bun theme={null}
bunx @openworkflow/cli init
```

For unattended setup from a script or agent, pass both `--backend` and `--yes`:

```bash npm theme={null}
npx --yes @openworkflow/cli init --backend sqlite --yes
```

```bash pnpm theme={null}
pnpx @openworkflow/cli init --backend sqlite --yes
```

```bash bun theme={null}
bunx @openworkflow/cli init --backend sqlite --yes
```

## 2. Start a worker

A worker is a process that watches for new workflow runs and executes them.
Start one with:

```bash npm theme={null}
npx @openworkflow/cli worker start
```

```bash pnpm theme={null}
pnpx @openworkflow/cli worker start
```

```bash bun theme={null}
bunx @openworkflow/cli worker start
```

The worker reads your `openworkflow.config.ts`, connects to the database, loads
the workflows from your `openworkflow/` directory, and begins polling for work.
Leave this running in its own terminal.

## 3. Run your first workflow

Open a second terminal and trigger the example workflow:

```bash npm theme={null}
npx tsx openworkflow/hello-world.run.ts
```

```bash pnpm theme={null}
pnpx tsx openworkflow/hello-world.run.ts
```

```bash bun theme={null}
bun openworkflow/hello-world.run.ts
```

This script calls `ow.runWorkflow(helloWorld.spec, {})` to create a new workflow
run in the database. The worker in your first terminal picks it up, executes
each step, and marks it complete.

> [!NOTE]
>
> The `hello-world.run.ts` file is a temporary helper for testing. In a real
> app, you'd call `ow.runWorkflow(workflow.spec, input)` from your API routes,
> scripts, or other application code.

## 4. View workflows in the dashboard

OpenWorkflow includes a built-in web dashboard. Start it with:

```bash npm theme={null}
npx @openworkflow/cli dashboard
```

```bash pnpm theme={null}
pnpx @openworkflow/cli dashboard
```

```bash bun theme={null}
bunx @openworkflow/cli dashboard
```

Open [http://localhost:3000](http://localhost:3000) to see your workflow run,
its steps, and their results.

## What you just built

The setup has four parts:

1. **`openworkflow.config.ts`**: Tells OpenWorkflow which database to use and
   where to find your workflow files.
2. **`openworkflow/hello-world.ts`**: Defines a workflow with one or more
   steps. Each step is a checkpoint: if anything crashes, the workflow
   resumes from the last completed step instead of starting over.
3. **`openworkflow/hello-world.run.ts`**: A script that enqueues a workflow
   run. In production, this would be your API handler or a cron job.
4. **The worker**: A long-running process that executes workflow runs. It polls
   the database, claims available work, and persists results.

## Next steps

* [Overview](https://openworkflow.dev/docs/overview.md): Understand how workflows, steps, and workers fit
  together
* [Workflows](https://openworkflow.dev/docs/workflows.md): Learn how to define and configure workflows
* [Steps](https://openworkflow.dev/docs/steps.md): See how steps protect your operations from crashes
* [Production](https://openworkflow.dev/docs/production.md): Deploy OpenWorkflow to your infrastructure


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.