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

# Run a workflow

Execute a registered workflow with **`runWorkflow`** after **`connect()`** on an HTTP-configured `DNotifier` instance.

## Method

```
runWorkflow({
  workflow: Workflow,
  input: *,
  senderId?: string,   // defaults to notifier.userId
})
```

## Return value

| Field         | Description                                                   |
| ------------- | ------------------------------------------------------------- |
| `result`      | Return value of the workflow `entry` function                 |
| `state`       | Final `ctx.state` object after execution                      |
| `executionId` | Present when `observability: true` — dashboard correlation id |

## Minimal run

```js
await notifier.connect();

const run = await notifier.runWorkflow({
  workflow: myWorkflow,
  input: "How does messaging work?",
});

console.log(run.result);
console.log(run.executionId);
```

{% hint style="info" %}
Use **`transport: "http"`**. The runner uses the authenticated notifier for all `ctx.sendAI` and `ctx.search` calls inside the workflow.
{% endhint %}

## Input types

`input` can be any JSON-serializable value:

| Type     | Example use                                |
| -------- | ------------------------------------------ |
| `string` | User question for intent router            |
| `object` | Blog brief `{ topic, keywords, audience }` |
| `array`  | Batch items (process in `entry`)           |

## Error handling

Uncaught errors in `entry` or agent `run` propagate from `runWorkflow`. Use try/catch at the call site:

```js
try {
  const run = await notifier.runWorkflow({ workflow, input });
} catch (err) {
  if (err.name === "WorkflowError") {
    console.error("Workflow validation:", err.message);
  }
  throw err;
}
```

## Language guides

| Language                | Guide                                                                                                |
| ----------------------- | ---------------------------------------------------------------------------------------------------- |
| JavaScript / TypeScript | [javascript-typescript.md](/product-docs/workflows-and-agents/run-workflow/javascript-typescript.md) |
| Dart / Flutter          | [dart-flutter.md](/product-docs/workflows-and-agents/run-workflow/dart-flutter.md)                   |

## Next steps

* [**Workflow observability**](/product-docs/workflows-and-agents/observability.md)
* [**Example: Intent router**](/product-docs/workflows-and-agents/example-intent-router.md)
