> For the complete documentation index, see [llms.txt](https://dnotifier.gitbook.io/product-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/overview.md). Agents can also search and read this documentation through its [MCP server](https://dnotifier.gitbook.io/product-docs/~gitbook/mcp).

# Workflows overview

**Workflows** orchestrate multi-step AI logic with **named agents**, shared **state**, and optional **observability** in the DNotifier dashboard. Define agents once, compose them in a `Workflow`, and execute with `runWorkflow`.

{% hint style="info" %}
Run workflows with **`transport: "http"`**. Each `runWorkflow` call authenticates via `connect()` and returns `{ result, state, executionId? }`.
{% endhint %}

## Core concepts

| Concept                 | Description                                                                                                                                                                       |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Agent**               | Named unit of work — classic `defineAgent({ name, run })` or tool agent `defineAgent({ name, tools, instructions })`                                                              |
| **Tools / MCP**         | Local `notifier.tools.register` or `notifier.mcp.connect` — see [Tools & MCP](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/tools-and-mcp.md)                    |
| **Workflow**            | Entry function + registered agents — `new Workflow({ name, entry })`                                                                                                              |
| **WorkflowContext**     | `ctx` passed to `entry` and agents — AI, search, `runAgent` / `runAgents`, shared `state`                                                                                         |
| **Standalone runAgent** | `notifier.runAgent(agent, { input })` for tool agents outside a workflow                                                                                                          |
| **Middleware**          | Hooks around agents and workflows — logging, tool access, auth — see [Middleware](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/middleware.md)                   |
| **Checkpoints**         | `sessionId` + resume / retry / replay — durable runs across turns and failures — see [Checkpoints](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/checkpoints.md) |
| **Observability**       | `observability: true` — step telemetry in the dashboard                                                                                                                           |
| **Runner**              | `notifier.runWorkflow({ workflow, input })`                                                                                                                                       |

## Architecture

```
  runWorkflow({ input })
         │
         ▼
  Workflow.entry(ctx)
         │
         ├─ ctx.runAgent("intent-agent")
         ├─ ctx.search({ query })
         ├─ ctx.sendAI({ message })
         └─ ctx.state.sharedKey = value
         │
         ▼
  { result, state, executionId }
```

## Three-step integration

1. [**Define agents**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/define-agent.md) — `DNotifier.defineAgent` / `define_agent`
2. [**Build a workflow**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/build-workflow.md) — `new DNotifier.Workflow` + `registerAgents`
3. [**Run a workflow**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/run-workflow.md) — `runWorkflow` after `connect()`

For **tools and MCP**, see [**Tools & MCP agents**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/tools-and-mcp.md) (local tools, MCP connect, standalone `runAgent`).\
For **logging, tool guards, and workflow access checks**, see [**Middleware**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/middleware.md).\
For **multi-turn memory and retry after failure**, see [**Checkpoints, sessions & resume**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/checkpoints.md).\
For agents on other servers, see [**Remote agents**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/remote-agents.md) (JavaScript, Python, and Dart).\
To let Claude, Cursor, or other agents call yours, see [**Serve agents over MCP**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/mcp-server.md) and [**Agent-to-agent (A2A)**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/a2a.md).

## When to use workflows

| Scenario              | Why workflows                       |
| --------------------- | ----------------------------------- |
| Intent routing        | Classify → branch to search or chat |
| RAG pipelines         | Search → summarize → answer         |
| Content generation    | Draft → edit → SEO (multi-agent)    |
| Tool / MCP assistants | Agent loop with local or MCP tools  |
| Auditable automation  | Observability per step              |

## vs single `sendAI`

| Single prompt                    | Workflow                         |
| -------------------------------- | -------------------------------- |
| One model call                   | Many steps with branching        |
| No shared state object           | `ctx.state` across agents        |
| Manual orchestration in app code | Declarative `entry` function     |
| AI session logs only             | Workflow dashboard + step detail |

## Examples

| Example                                                                                                       | Description                             |
| ------------------------------------------------------------------------------------------------------------- | --------------------------------------- |
| [Intent router](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/example-intent-router.md)      | Classify → search or general Q\&A       |
| [Multi-agent pipeline](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/example-multi-agent.md) | Blog: create → edit → SEO               |
| [Local tool agent](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/example-tool-agent.md)      | Register a tool and run with `runAgent` |
| [MCP Mermaid agent](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/example-mcp-agent.md)      | Public MCP server + diagram assistant   |

## Reference

* [**Middleware**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/middleware.md)
* [**Workflow observability**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/observability.md)
* [**WorkflowContext reference**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/workflow-context.md)

## Next steps

* [**Define an agent**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/define-agent.md)
* [**AI overview**](https://dnotifier.gitbook.io/product-docs/ai/overview.md)
