> 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/observability/ai-workflow-observability.md).

# How to enable AI workflow observability

**AI workflow observability** records every execution of a multi-agent pipeline in the DNotifier dashboard — agents, `sendAI` steps, searches, documents, latency, tokens, and optional `provider` / `model`.

Enable it with **`observability: true`** on the `Workflow` (not on the notifier).

## Why use it?

* See which agent ran and in what order
* Inspect AI prompts/outputs per step (when recorded)
* Correlate a support ticket with `executionId`
* Track `provider` and `model` on AI steps (from `sendAI`, agent defaults, or project default)

{% hint style="success" %}
Use **`transport: "http"`** for workflows. Observability requires a connected notifier (`await connect()`).
{% endhint %}

## How to enable AI observability

### 1. Set `observability: true` on the workflow

{% tabs %}
{% tab title="JavaScript" %}

```js
const workflow = new DNotifier.Workflow({
  name: "intent-router",
  description: "Route user questions",
  observability: true,
  async entry(ctx) {
    const intent = await ctx.runAgent("intent-agent");
    return ctx.runAgent(
      intent.intent === "search" ? "search-agent" : "general-agent"
    );
  },
}).registerAgents({
  "intent-agent": intentAgent,
  "search-agent": searchAgent,
  "general-agent": generalAgent,
});
```

{% endtab %}

{% tab title="Python" %}

```python
workflow = Workflow(
    name="intent-router",
    description="Route user questions",
    observability=True,
    entry=entry,
).register_agents({
    "intent-agent": intent_agent,
    "search-agent": search_agent,
    "general-agent": general_agent,
})
```

{% endtab %}

{% tab title="Dart" %}

```dart
final workflow = Workflow(
  name: 'intent-router',
  description: 'Route user questions',
  observability: true,
  entry: entry,
).registerAgents({
  'intent-agent': intentAgent,
  'search-agent': searchAgent,
  'general-agent': generalAgent,
});
```

{% endtab %}
{% endtabs %}

### 2. Connect and run

```js
const notifier = new DNotifier({
  appId: process.env.DNOTIFIER_APP_ID,
  secret: process.env.DNOTIFIER_SECRET,
  transport: "http",
  userId: "user-123",
  logs: true, // optional: also enable session logs for each sendAI
});

await notifier.connect();

const run = await notifier.runWorkflow({
  workflow,
  input: "How do I reset my password?",
});

console.log(run.executionId); // find this run in Dashboard → Workflows
```

If `observability` is `false` or omitted, **no** workflow is registered in the dashboard and `executionId` is absent.

## What gets recorded

| SDK call                         | Dashboard step                                                     |
| -------------------------------- | ------------------------------------------------------------------ |
| Workflow start / end             | Execution status, duration                                         |
| `ctx.runAgent` / `ctx.runAgents` | Agent nodes                                                        |
| `ctx.sendAI`                     | AI-LLM step (latency, tokens when available, `provider` / `model`) |
| `ctx.search` / document APIs     | Search / document steps                                            |
| `ctx.recordStep`                 | Custom labeled steps                                               |

### Label AI steps for clearer graphs

```js
await ctx.sendAI({
  message: { text: "Classify intent" },
  provider: "open_ai",
  model: "gpt-4o",
  saveHistory: false, // often false for internal routing steps
  label: "Intent classification",
});
```

### Agent-level provider / model

```js
const intentAgent = DNotifier.defineAgent({
  name: "intent-agent",
  provider: "open_ai",
  model: "gpt-4o",
  async run(ctx) {
    return ctx.sendAI({ message: { text: String(ctx.input) } });
  },
});
```

Observability records the effective `provider` / `model` on the step (call override → agent default → project `current_model` for model).

## Where to view results

1. Open [app.dnotifier.com](https://app.dnotifier.com)
2. Go to **Workflows**
3. Open the workflow by name (e.g. `intent-router`)
4. Select an execution — match `run.executionId` from your SDK

See [Dashboard overview](https://dnotifier.gitbook.io/product-docs/getting-started/dashboard-overview.md).

## Observability vs logs vs saveHistory

|             | `observability: true`  | `logs: true`          | `saveHistory: true`                         |
| ----------- | ---------------------- | --------------------- | ------------------------------------------- |
| Scope       | One workflow execution | Each `sendAI` session | Stored AI turns                             |
| Dashboard   | Workflows              | Logs                  | Not a dashboard list — use `fetchAIHistory` |
| Typical use | Multi-agent debugging  | Ops / token audit     | Product chat history                        |

→ Full comparison: [Observability overview](https://dnotifier.gitbook.io/product-docs/observability/observability.md)

## Requirements checklist

* [ ] `observability: true` on `Workflow`
* [ ] `await notifier.connect()` before `runWorkflow`
* [ ] Prefer `transport: "http"`
* [ ] Valid app credentials with AI enabled on plan
* [ ] (Recommended) `logs: true` for session-level AI telemetry
* [ ] (Optional) `saveHistory: true` when end users should retrieve turns

## Next steps

* [Observability FAQ](https://dnotifier.gitbook.io/product-docs/observability/faq.md)
* [Enable session logs](https://dnotifier.gitbook.io/product-docs/observability/enable-session-logs.md)
* [WorkflowContext reference](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/workflow-context.md)
* [Run a workflow](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/run-workflow.md)
