ag-ui icon indicating copy to clipboard operation
ag-ui copied to clipboard

Add n8n Support

Open NathanTarbert opened this issue 1 year ago • 3 comments

Add n8n support for AG-UI

NathanTarbert avatar Sep 10 '25 21:09 NathanTarbert

Hey @NathanTarbert

Is anyone working on this? If not, I can take this and send you my proposal shortly... let me know if you want me to work on this issue

Avngrstark62 avatar Mar 22 '26 07:03 Avngrstark62

Hi! Sharing some thoughts on how an n8n integration could work:

Integration approach:

n8n could integrate with AG-UI in two directions:

  1. n8n as an AG-UI agent backend — An n8n workflow acts as the agent, emitting AG-UI standard events (RunStarted, TextMessageContent, ToolCallStart, etc.) via SSE. A custom n8n trigger node could accept AG-UI RunAgentInput and translate workflow execution steps into the corresponding event stream.

  2. AG-UI events as n8n triggers — An n8n trigger node that subscribes to an AG-UI event stream, allowing n8n workflows to react to agent lifecycle events (e.g., fire a workflow when a ToolCall event arrives).

The AG-UI TypeScript SDK (@ag-ui/core) already provides the event types and encoder — the main work would be building the n8n community node package that bridges n8n's execution model to AG-UI's Observable-based run() interface.

Happy to contribute if there's interest. Would a PR with a community node scaffold be a good starting point?

fq393 avatar Apr 10 '26 01:04 fq393

@NathanTarbert I'd like to take this, and I have checked what it would actually involve first.

What n8n streams today decides the shape of the adapter. packages/workflow/src/interfaces.ts:4447 is the whole wire format: type ChunkType = 'begin' | 'item' | 'end' | 'error', and StructuredChunk carries an optional content string plus metadata with nodeId, nodeName, runIndex, itemIndex and timestamp. Four chunk types, text, and node metadata. No tool calls, no reasoning, no state.

That is a limit of the source rather than something an adapter can work around. The community PR adding an SSE format option (n8n-io/n8n#18924) was closed unmerged, the PR that streams tool calls and node execution (n8n-io/n8n#20499) has been open since October 2025, and n8n's own report that intermediate agent steps are lost in webhook responses (n8n-io/n8n#28271) was closed into their internal tracker.

So the faithful mapping is begin to TEXT_MESSAGE_START, item to TEXT_MESSAGE_CONTENT, end to TEXT_MESSAGE_END, error to RUN_ERROR, with RUN_STARTED and RUN_FINISHED around the request.

One part is better than it first looks. metadata.nodeName and nodeId give a natural message identity: each streaming node becomes its own AG-UI message, so a workflow with several agent nodes produces several messages instead of one merged blob. That is the semantics the protocol wants, and it comes free from the source.

What I propose for a first version: text streaming, run lifecycle, and errors, with message identity taken from the node. Delivered as integrations/n8n/typescript with an example that respects HOST and PORT, the three dojo registrations, entries in the prep and run scripts on a non-conflicting port, and an e2e spec for every feature I declare in menu.ts.

Deliberately out of scope, so it is not a surprise at review time: TOOL_CALL_*, STATE_SNAPSHOT and STATE_DELTA, and reasoning events. n8n does not emit the information those need. If n8n-io/n8n#20499 lands, tool calls become a follow-up rather than a rewrite, because the translation layer would already be in place.

@fq393 sketched two directions in the comment above. I am proposing only the first, n8n as an agent backend. The second needs a node published in n8n's own ecosystem, which is a separate project on a separate release cycle.

On maintenance: your CONTRIBUTING says community integrations are maintained by the member who built them, and I am taking that as part of the commitment rather than a footnote. My merged work here so far has been in integrations/ — langgraph, aws-strands, langchain, mastra and vercel-ai-sdk — so it is a surface I already work in.

One question before I start. Does a text-only first version fit what you want, or would you rather this wait until n8n can stream tool calls so it arrives feature-complete? I would rather build the narrow one now and extend it, but this is your roadmap.

TheSeydiCharyyev avatar Sep 05 '26 04:09 TheSeydiCharyyev