Skip to main content

Choose a setup method

Start with one method for a call path. Combining SDK tracking with framework OpenTelemetry on the same call can create duplicate interactions.
Recommended. Choose this path when you want your coding agent to inspect the project, select a supported transport, make the smallest instrumentation change, send a test event, and verify that it reached Agnost AI.
Install the skill once in your coding-agent environment:
Run the framework-specific prompt below from the application root. Review the resulting diff before deploying it.

Manual setup: Agnost AI ingest API

An n8n workflow cannot load the Agnost AI SDK, so this setup uses HTTP Request nodes that call the same ingest API the SDKs use: Capture Session and Capture Event. It works on n8n Cloud and on self-hosted n8n, with no code and no environment variables. After each chat message, the workflow sends:
  • one session for the chat, keyed by the Chat Trigger’s sessionId, with the user ID if the chat passes one
  • one event for the turn, with the user’s message as input and the AI Agent’s reply as output
  • one child event for each tool the AI Agent called, with the tool’s input and result

1. Get your organization ID

Sign in to app.agnost.ai, open Settings, and copy the Organization ID under General. It is a UUID.

2. Import the workflow

The workflow below is a chat agent (Chat Trigger, AI Agent, Anthropic Chat Model, Calculator tool) with four Agnost AI nodes after the AI Agent:
  1. Copy the JSON and paste it on an empty n8n canvas with Ctrl+V (Cmd+V on macOS).
  2. In each of the three Agnost AI nodes, replace YOUR_AGNOST_ORG_ID in the x-org-id header with your organization ID.
  3. Open Anthropic Chat Model and select your Anthropic credential, or swap in the chat model you already use.
  4. Publish the workflow.
To add Agnost AI to an agent you already have, copy the four Agnost AI nodes into it. Connect the AI Agent’s output to both Agnost AI: session and Tool steps, as in the JSON above. Then:
  • In the AI Agent node, turn on Options > Return Intermediate Steps. Without it, Tool steps has nothing to split and no tool events are sent.
  • If your trigger node is not named When chat message received, update the $('When chat message received') references in the three Agnost AI bodies.
  • If your agent node is not named AI Agent, update $('AI Agent') in Agnost AI: turn.
  • Change primitive_name: 'n8n-ai-agent' in Agnost AI: turn to the agent name you want to see in Agnost AI.

3. How the fields map

Agnost AI maps session_id, event_id, and parent_id strings that are not UUIDs to a fixed UUID, so the same string always points at the same record. The Chat Trigger has no user field. The n8n embedded chat (@n8n/chat) sends its metadata option with every message, so pass the user ID there:
A custom client that posts to the chat webhook sends the same fields itself: {"action": "sendMessage", "sessionId": "...", "chatInput": "...", "metadata": {"userId": "..."}}. Without a user ID, the conversation is still captured, without a user.

4. Keep the chat reply working

The Chat Trigger in the workflow uses the Streaming response mode, so the AI Agent streams its reply to the chat and the Agnost AI nodes run after it. If your Chat Trigger uses When Last Node Finishes, n8n sends the output of the last node that ran as the reply, which would be an Agnost AI node. Switch to Streaming, or end the workflow with an Edit Fields node that sets output to {{ $('AI Agent').item.json.output }}. Each Agnost AI node has Settings > On Error set to Continue, so an ingest error never fails the chat.

Manual setup: OpenTelemetry

Self-hosted n8n 2.19 and later can export OpenTelemetry traces of workflow and node executions. n8n marks this feature as Preview. Agnost AI accepts these spans: AI Agent, chat model, and tool node spans carry GenAI attributes (gen_ai.operation.name, gen_ai.agent.name, gen_ai.request.model, gen_ai.provider.name, gen_ai.tool.name). The spans carry no message text, no chat session ID, and no user ID. In Agnost AI, each workflow execution becomes its own conversation with agent, model, and tool events, their latency, and the model name, but no transcript. Use OpenTelemetry when you want execution timing. Use the ingest API above for conversations, users, and patterns. With both turned on, each chat turn also shows up as a separate trace conversation without text.

Install

Nothing to install. OpenTelemetry tracing is built into self-hosted n8n 2.19 and later.

Setup

Set these environment variables on every n8n process (main, workers, and webhook processes) and restart n8n:
n8n appends the default trace path /v1/traces and uses OTLP over HTTP/protobuf by default. Keep both defaults. By default, n8n traces only production executions. Runs you start from the editor are not traced. Set N8N_OTEL_TRACES_PRODUCTION_ONLY=false to trace them too.

Verify

Ingest API:
  1. Open the chat for the published workflow and send a message that makes the agent call a tool.
  2. In app.agnost.ai, open Conversations and find the conversation for the chat session. It shows the user ID you passed in metadata.userId.
  3. Open the conversation. The turn event shows your message and the agent’s reply. The tool event shows the tool name, input, and result, nested under the turn.
OpenTelemetry:
  1. Run the published workflow once.
  2. Open Events in Agnost AI. Within about a minute you see an AI Agent agent event, a chat event per model call, and an event per tool call, all in one conversation for the execution.
Settings > OpenTelemetry > Send test trace in n8n checks the connection only. The test span carries no AI attributes, so it does not appear in Agnost AI.

Troubleshooting

  • No conversation appears: open the execution in n8n and check the output of Agnost AI: session. A working call returns {"status": "accepted"}. A 400 means the x-org-id header is missing or is not a UUID.
  • Calls are accepted but nothing appears in your organization: check that x-org-id matches the organization selected in Agnost AI. The ingest API does not check the ID at request time.
  • Every message is a separate conversation: the trigger is not sending a stable sessionId. The n8n chat keeps one sessionId per chat. Custom clients must send the same sessionId with every message.
  • No tool events: turn on Return Intermediate Steps in the AI Agent options, and check that the AI Agent’s output connects to Tool steps.
  • The chat shows {"status":"accepted"} or an error instead of the reply: the Chat Trigger uses When Last Node Finishes. See Keep the chat reply working.
  • No OpenTelemetry events: confirm the variables are set on the process that runs the execution (workers in queue mode), that the run was a production execution, and that N8N_OTEL_EXPORTER_OTLP_HEADERS is X-Agnost-Org-ID=<your-org-id>.

References

Next steps

  • Conversations: review each chat session with its turns and tool calls.
  • Events: inspect the turn and tool events n8n sent.
  • Patterns: organize production conversations by what users wanted.