> 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).

# 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](/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                                                           |
| **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**](/product-docs/workflows-and-agents/define-agent.md) — `DNotifier.defineAgent` / `define_agent`
2. [**Build a workflow**](/product-docs/workflows-and-agents/build-workflow.md) — `new DNotifier.Workflow` + `registerAgents`
3. [**Run a workflow**](/product-docs/workflows-and-agents/run-workflow.md) — `runWorkflow` after `connect()`

For **tools and MCP**, see [**Tools & MCP agents**](/product-docs/workflows-and-agents/tools-and-mcp.md) (local tools, MCP connect, standalone `runAgent`).\
For agents on other servers, see [**Remote agents**](/product-docs/workflows-and-agents/remote-agents.md) (JavaScript, Python, and Dart).

## 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](/product-docs/workflows-and-agents/example-intent-router.md)      | Classify → search or general Q\&A       |
| [Multi-agent pipeline](/product-docs/workflows-and-agents/example-multi-agent.md) | Blog: create → edit → SEO               |
| [Local tool agent](/product-docs/workflows-and-agents/example-tool-agent.md)      | Register a tool and run with `runAgent` |
| [MCP Mermaid agent](/product-docs/workflows-and-agents/example-mcp-agent.md)      | Public MCP server + diagram assistant   |

## Reference

* [**Workflow observability**](/product-docs/workflows-and-agents/observability.md)
* [**WorkflowContext reference**](/product-docs/workflows-and-agents/workflow-context.md)

## Next steps

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