n8n Templates

n8n AI Agent Chat Template: Setup, Use Cases, and What to Change

The most-viewed template in the n8n library is five nodes: a chat window, GPT, memory, and web search. Here is what to connect and what to edit before you rely on it.

The n8n team's "AI agent chat" template has more than 1.8 million views on n8n.io as of October 2026, more than any other template in the library. It has five nodes and takes about ten minutes to get running. Most of the more elaborate AI templates on the site grow out of this one, so it is the best place to start.

This guide covers what the template does, which accounts you need, and the changes to make after you copy it into your own n8n. You can find the original on the n8n template page.

What the template does

A Chat Trigger node opens a chat window hosted by n8n. Each message you type goes to an AI Agent node. The agent runs on OpenAI's gpt-4o-mini, keeps recent messages in a Simple Memory node so it can follow a conversation, and calls SerpAPI when it needs a Google search to answer. The reply appears in the chat window.

The template needs n8n version 1.50.0 or later, because it uses the current AI Agent node.

Services to connect

Two credentials, and nothing else:

What to change after you copy it

1. Write a system message

The template leaves the agent's system message empty. Without one, the agent has no role, no tone, and no rules about when to search. Open the AI Agent node, add a system message under Options, and say who the agent is, who it talks to, what it must refuse, and when it should search the web instead of answering from memory.

2. Pick the model on purpose

gpt-4o-mini is cheap and fast. If the agent gives thin answers, open the OpenAI Chat Model node and try a larger model. If you prefer another provider, replace the node with the Anthropic or Google Gemini chat model node and connect it to the same agent input.

3. Replace the memory

Simple Memory lives inside the n8n process. A restart wipes every conversation, and it does not scale across several n8n workers. For anything customers will use, swap it for the Postgres Chat Memory or Redis Chat Memory node. Set the context window length while you are there. A longer window helps with follow-up questions and raises your token bill on every message.

4. Decide who can open the chat

By default the chat is available inside the n8n editor. To put it on your website, turn on "Make Chat Publicly Available" in the Chat Trigger node and restrict the allowed origins to your own domain. Then embed the n8n chat widget on the page. Check the Chat Trigger documentation for the current widget snippet, since the embed code has changed between versions.

5. Give it tools that matter to you

SerpAPI gives the agent public web knowledge. It knows nothing about your business. Add a Google Sheets, Airtable, or HTTP Request tool node and the agent can look up your prices, order status, or CRM records. Describe each tool in plain language in its description field, because the agent reads that text to decide when to call it.

Use cases

Where the template stops: it has no guardrails, no logging, and no limit on cost per conversation. Put a system message, a spend cap on your OpenAI key, and persistent memory in place before you let strangers use it.

Common questions

Does this template cost money to run?

The template is free. Self-hosted n8n is free to run apart from your server. You pay OpenAI per token and SerpAPI per search once you pass its free allowance.

Can I use Claude or Gemini instead of OpenAI?

Yes. Delete the OpenAI Chat Model node, add the Anthropic or Google Gemini chat model node, and attach it to the AI Agent's model input. The rest of the workflow stays the same.

Can the agent answer questions from my own documents?

Yes, with a vector store tool. Our WhatsApp sales chatbot guide shows the full setup, including how to load a PDF into a knowledge base.

Want this built and maintained for you?

Tell us which workflow you need. We set up the credentials, adapt the template to your business, and document it so your team can run it.

Start a Project →