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

# Python

Enable dashboard AI telemetry with **`logs=True`** on the `DNotifier` constructor.

## Complete example

```python
import asyncio
from dnotifier import DNotifier

USER_ID = "user-123"

async def main():
    notifier = DNotifier(
        app_id="your-app-id",
        secret="your-app-secret",
        transport="http",
        user_id=USER_ID,
        logs=True,
        on_connected=lambda: print("Ready — logging enabled"),
    )

    await notifier.connect()

    await notifier.send_ai(
        sender_id=USER_ID,
        message={
            "messages": [
                {"role": "system", "content": "You are a concise assistant."},
                {
                    "role": "user",
                    "content": "Explain session logging in one paragraph.",
                },
            ],
        },
    )
    # Check app.dnotifier.com → Logs

asyncio.run(main())
```

## Conditional logging

```python
import os

enable_logs = os.environ.get("DNOTIFIER_LOGS") == "true"

notifier = DNotifier(
    app_id=os.environ["DNOTIFIER_APP_ID"],
    secret=os.environ["DNOTIFIER_SECRET"],
    transport="http",
    user_id=USER_ID,
    logs=enable_logs,
)
```

## With session continuation

```python
first = await notifier.send_ai(
    sender_id=USER_ID,
    message={"text": "Start logged session."},
)

session_id = session_id_from_response(first)

await notifier.send_ai(
    sender_id=USER_ID,
    session_id=session_id,
    message={"text": "Follow-up — also logged."},
)
```

## Learn more

* [**Sessions**](https://dnotifier.gitbook.io/product-docs/ai/sessions/python.md)
* [**Workflow observability**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/observability.md)
