Build stateful, long-running, reliable workflows using the Dapr Workflow JavaScript SDK with Catalyst. The Dapr Workflow JavaScript SDK provides a powerful way to orchestrate complex business processes using Node.js and TypeScript.

Prefer to start from a diagram? Use [Workflow Composer](https://docs.diagrid.io/develop/workflows/workflow-composer) to generate a runnable JavaScript Dapr Workflow project from a BPMN flowchart, then iterate with this SDK. For local monitoring of running workflows, use the [Dapr Dev Dashboard](https://docs.diagrid.io/develop/local-development/dev-dashboard).

## Resources

- [Dapr JavaScript SDK GitHub](https://github.com/dapr/js-sdk)
- [Dapr JavaScript SDK npm](https://www.npmjs.com/package/@dapr/dapr)
- [Dapr Workflow Documentation](https://docs.dapr.io/developing-applications/building-blocks/workflow/)
- [Catalyst Workflow Quickstart](https://docs.diagrid.io/getting-started/quickstarts/workflow)

**Prerequisites:**

- Node.js LTS or Current ([Download](https://nodejs.org/))
- [Dapr JavaScript SDK](https://www.npmjs.com/package/@dapr/dapr)

## Installation

Install the Dapr JavaScript SDK via npm:

```bash
npm install --save @dapr/dapr
```

## Core Application

Use the essential components of a Dapr Workflow application (Workflows and Activities) to build and run a workflow application.

- [Develop a Workflow Definition](https://docs.dapr.io/developing-applications/building-blocks/workflow/howto-author-workflow#tabs-03-03-tab) — Learn how to define workflows using generator functions and TypeScript types
- [Develop an Activity Definition](https://docs.dapr.io/developing-applications/building-blocks/workflow/howto-author-workflow#tabs-02-03-tab) — Create activities that perform the actual work orchestrated by workflows

## Dapr Client

Connect to the Dapr Workflow API and start, get status, and manage workflow executions.

- [Workflow Client and Runtime](https://docs.dapr.io/developing-applications/sdks/js/js-workflow/#create-a-workflow-client-and-runtime) — Learn how to create and configure the DaprWorkflowClient and WorkflowRuntime, including registration of workflows and activities
- [Start a Workflow](https://docs.dapr.io/developing-applications/sdks/js/js-workflow/#start-a-workflow-instance) — Schedule new workflow instances via the JavaScript SDK
- [Get Workflow Results](https://docs.dapr.io/developing-applications/sdks/js/js-workflow/#get-workflow-instance-status) — Retrieve workflow instance data such as the current status, input, custom status, and output

## Failure Detection

Explore how your application can detect failures using timeouts.

- [Workflow Timeouts](https://docs.dapr.io/developing-applications/building-blocks/workflow/workflow-features-concepts/#workflow-timeouts) — Each workflow timeout controls the maximum duration of a different aspect of a workflow execution
- [Activity Timeouts](https://docs.dapr.io/developing-applications/building-blocks/workflow/workflow-features-concepts/#activity-timeouts) — Each activity timeout controls the maximum duration of a different aspect of an activity execution

## External Events

Wait for external input and send events to running workflows.

- [Wait for External Event](https://docs.dapr.io/developing-applications/building-blocks/workflow/workflow-patterns#tabs-10-03-tab) — Wait for external input, such as human approvals or system responses
- [Raise Workflow Event](https://docs.dapr.io/developing-applications/sdks/js/js-workflow/#raise-an-event-to-a-running-workflow-instance) — Send an event to a running workflow instance from a client or another workflow

## Control Workflow Progression

Interrupt a workflow execution with pause, resume, or terminate actions.

- [Pause a Workflow](https://docs.dapr.io/developing-applications/sdks/js/js-workflow/#suspend-a-running-workflow-instance) — Pause a running workflow instance
- [Resume a Workflow](https://docs.dapr.io/developing-applications/sdks/js/js-workflow/#resume-a-suspended-workflow-instance) — Resume a paused workflow instance
- [Terminate a Workflow](https://docs.dapr.io/developing-applications/sdks/js/js-workflow/#terminate-a-workflow-instance) — Terminate a workflow execution and its activities

## Advanced Features

- [Durable Timers](https://docs.dapr.io/developing-applications/building-blocks/workflow/workflow-patterns/#tabs-06-03-tab) — Use timers to make a workflow execution pause or sleep for a fixed time period
- [Continue-As-New](https://docs.dapr.io/developing-applications/building-blocks/workflow/workflow-patterns/#tabs-06-03-tab) — Continue the workflow execution with a new workflow execution using the same workflow ID

## Observability

Configure and use observability features to monitor and debug workflows.

- [Workflow Visibility](https://docs.diagrid.io/operate/project-operations/observability) — Use the Catalyst workflow dashboard to view workflow executions, states, and success rates

## Getting Started

- [Workflow Quickstart](https://docs.diagrid.io/getting-started/quickstarts/workflow) — Get started with workflows in Catalyst
- [Workflow Patterns](https://docs.dapr.io/developing-applications/building-blocks/workflow/workflow-patterns/) — Learn about common workflow patterns
- [Dapr Workflow Documentation](https://docs.dapr.io/developing-applications/building-blocks/workflow/) — Comprehensive Dapr workflow guide
