> 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/python.md). Agents can also search and read this documentation through its [MCP server](https://dnotifier.gitbook.io/product-docs/~gitbook/mcp).

# Python

Execute a workflow over HTTP and read `result`, `state`, and `executionId`.

## Complete example

```python
import asyncio
from dnotifier import DNotifier

USER_ID = "workflow-runner"

async def main():
    notifier = DNotifier(
        app_id="your-app-id",
        secret="your-app-secret",
        transport="http",
        user_id=USER_ID,
        on_connected=lambda: print("Connected"),
    )

    await notifier.connect()

    search_run = await notifier.run_workflow(
        workflow=intent_router_workflow,
        input_data="How do refunds work?",
    )

    print(f"Branch: {search_run['result']}")
    print(f"Execution: {search_run.get('executionId')}")

    general_run = await notifier.run_workflow(
        workflow=intent_router_workflow,
        input_data="What is your name?",
    )

    print(f"Branch: {general_run['result']}")

asyncio.run(main())
```

## HTTP handler pattern (aiohttp)

```python
from aiohttp import web

async def handle_support_workflow(request: web.Request) -> web.Response:
    body = await request.json()
    question = body.get("question", "")

    run = await notifier.run_workflow(
        workflow=intent_router_workflow,
        input_data=question,
    )

    return web.json_response({
        "result": run["result"],
        "executionId": run.get("executionId"),
    })
```

## Blog pipeline input

```python
run = await notifier.run_workflow(
    workflow=blog_article_workflow,
    input_data={
        "topic": "Building AI workflows with DNotifier",
        "keywords": ["workflow", "sdk", "observability"],
        "audience": "developers",
        "tone": "professional",
        "wordCount": 900,
    },
)

result = run["result"]
if isinstance(result, dict):
    article = result.get("article", "")
    print(article[:200] if article else "")
    print(result.get("seo"))
```

## Learn more

* [**Workflow observability**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/observability.md)
* [**Example: Multi-agent pipeline**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/example-multi-agent/python.md)
