n8n AI Chatbot Tutorial

Build a chatbot · beginner tutorial

n8n AI Chatbot Tutorial: Build a Working Chatbot Step by Step

Connect a chat trigger, AI Agent, model, and optional memory to create a chatbot in n8n. Follow the build, test its answers, and learn how to add knowledge sources and human handoff.

  • Beginner-friendly node walkthrough
  • Website and support use cases
  • Privacy and safety guidance

What is an n8n AI chatbot?

A chat experience connected to a workflow and an AI model.

An n8n AI chatbot takes a message, passes it through a workflow, and returns a response. The workflow can connect a chat trigger, AI Agent, language model, optional memory, and tools or knowledge sources.

You decide what information the chatbot can use and what actions it can take. Start with a narrow purpose, test what it answers, and provide a path to a person when it cannot help. Learn more in our n8n AI automation guide.

Before you build

What you need for an n8n chatbot

The components and availability depend on your n8n version and chosen services.

An n8n workspace

Use a hosted or self-managed instance where you can create and test workflows.

A supported AI model

Set up provider credentials and choose a model that fits your needs and budget.

Chat input and agent

Use a chat trigger and AI Agent node or another supported chatbot pattern.

Optional conversation memory

Carry context between messages when your use case needs it.

Optional knowledge source

Provide relevant documents or data for grounded answers.

A clear bot purpose

Define what it should answer, what it must avoid, and when to hand off.

New to workflows? Start with the n8n tutorial for beginners before connecting the model.

Step-by-step build

Build an AI chatbot in n8n

Begin with a basic chat flow. Add a knowledge base and deployment method after the core response works.

  1. 1

    Create a new workflow

    Name it for the chatbot’s purpose so its role is easy to recognize.

  2. 2

    Add a Chat Trigger

    Use the chat input supported by your n8n version. Run a test message to inspect the incoming data.

  3. 3

    Add an AI Agent node

    Connect the trigger’s message to the agent. Define what it can help with and what to do when uncertain.

  4. 4

    Connect an AI model

    Select a supported model connection and configure credentials securely. See the n8n OpenAI integration guide for provider setup.

  5. 5

    Write system instructions

    Set the chatbot’s role, scope, tone, source rules, and fallback response. Keep the instructions specific.

  6. 6

    Add memory if needed

    Connect a memory component when the conversation needs context across turns. Configure session handling deliberately.

  7. 7

    Test useful and difficult prompts

    Test a normal question, an out-of-scope question, an ambiguous request, and a request needing a human.

  8. 8

    Make it available carefully

    Choose a chat interface or integration, review access controls, then publish only after testing.

Give the chatbot clear instructions

A system instruction can define a useful boundary. Adapt this example to your actual service and information:

Example instruction: “You are a support assistant for [business]. Answer only using the approved information provided to you. If the answer is missing or unclear, say you’re unsure and offer to connect the visitor with a person. Do not request passwords or payment details.”

Do not claim the chatbot is accurate or tested until you have checked it against realistic questions and edge cases.

Ground answers in your material

Add a knowledge base with RAG

Retrieval-augmented generation gives the model relevant source material to use for a response.

1 · Prepare

Choose documents

Select appropriate, current source material and remove information that should not be shared.

2 · Index

Store searchable chunks

Split and index content using the storage and retrieval components you configure.

3 · Retrieve

Find relevant context

Use the question to retrieve relevant source passages for the model.

4 · Answer

Respond with limits

Instruct the chatbot to rely on sources and say when the answer is not found.

RAG can improve relevance but does not guarantee correctness. Keep the source material maintained and test whether answers match it. Explore our AI automation guide for more workflow patterns.

Add an n8n chatbot to a website

Choose an interface and protect the workflow endpoint.

Hosted chat interface: use an n8n-provided chat option if available for your version and plan, then configure its access and presentation.

Embedded interface: connect a website chat UI to the workflow using a supported method. Check authentication, origins, rate limits, and what data the endpoint accepts.

Never expose an unprotected workflow endpoint or powerful actions publicly. Test the site interface on desktop and mobile before launch.

Customer support pattern

Build a support chatbot with human handoff

A support chatbot can answer common questions using approved help content, collect a brief description, and route unresolved cases to a person. Set a clear handoff condition, such as a user request, missing source information, or a sensitive topic.

  • Tell visitors when they are speaking with an automated assistant.
  • Make the human support path easy to find.
  • Pass only necessary conversation context to the support team.
  • Do not let the bot make promises beyond approved policy.

For messaging channels, see n8n WhatsApp automation.

n8n AI chatbot examples and use cases

Start with bounded tasks where a response can be checked.

Website customer support

Answer common questions from approved support content.

Lead qualification

Collect key details and route an enquiry to the right team.

Sales assistant

Explain product information and offer a person for complex cases.

Document Q&A

Retrieve relevant passages from selected documents.

WhatsApp or Telegram bot

Connect a messaging interface to a workflow with channel-specific rules.

Appointment assistant

Collect preferences and route booking requests for confirmation.

For ready-made starting points, browse n8n workflow templates and practical n8n automation examples.

AI chatbot vs AI agent

They can overlap, but the terms describe different patterns.

Pattern Typical behavior Good starting point
Chatbot Responds to user messages using configured instructions and context. FAQ, guided answers, or a bounded conversation.
AI agent Can select from connected tools to work toward a request. Tasks that need a tool choice, with scoped permissions.

A chatbot may use an agent under the hood. Learn more in the n8n AI agent tutorial.

Common chatbot problems and what to check

Chatbot does not respond

Check the trigger, workflow activation, input mapping, and execution details.

Model is not connected

Verify saved credentials, model availability, and node compatibility.

Conversation is not remembered

Review the memory component and ensure each conversation uses a consistent session identifier.

Answers are inaccurate

Check source quality, prompts, retrieved context, and out-of-scope behavior.

Website chat is not loading

Check endpoint access, browser errors, allowed origins, and interface configuration.

Responses are slow

Inspect model latency, retrieval steps, workflow executions, and response size.

Build responsibly

Security and privacy for AI chatbots

  • Collect only information needed for the chatbot’s purpose.
  • Review provider data handling and retention settings.
  • Protect credentials and restrict tool permissions.
  • Keep private or sensitive information out of public logs and prompts where possible.
  • Use human review for consequential decisions or actions.
  • Test prompt injection and attempts to request data outside the bot’s scope.
  • Provide a clear disclosure and human contact path.

Before launch: test normal, ambiguous, and adversarial inputs, and verify what data is stored or sent to connected providers.

Quick answers

Frequently asked questions

Can I build an AI chatbot with n8n?

Yes. A workflow can connect a chat trigger, AI Agent or model, and optional memory or knowledge retrieval.

Is an n8n AI chatbot free?

Costs depend on n8n hosting, model usage, and connected services. Review each provider’s current pricing.

Do I need coding skills?

You can build many chatbot workflows visually. Code may help for custom interfaces or advanced processing.

Can I use ChatGPT in an n8n chatbot?

You can connect a supported OpenAI model using the required API credentials. ChatGPT subscriptions and API access are separate.

Can I add an n8n chatbot to WordPress?

It may be possible through a supported chat interface or an embedded custom interface. Configure endpoint access and security carefully.

Can the chatbot remember previous messages?

Conversation memory can retain context depending on its configuration and session handling. It is not a guarantee that every detail will be remembered.

Can an n8n chatbot answer questions from PDF files?

A workflow can use document processing and retrieval components to provide relevant passages, if configured. Test answers against the source documents.

Can I connect a chatbot to WhatsApp?

Yes, with a supported WhatsApp Business setup and workflow configuration. See our WhatsApp automation guide.

Can the chatbot transfer a conversation to a human?

Yes. Add a handoff path that notifies a person or support system when the user requests help or the bot cannot answer.

Explore more n8n AI guides

Continue with our n8n AI automation guide, AI agent tutorial, OpenAI integration guide, WhatsApp automation guide, workflow templates, and automation examples.

n8n Automation AI is an independent educational resource and is not affiliated with or endorsed by n8n GmbH.

Official documentation and resources

External references are grouped at the bottom of the guide.

Node names and features can change. Check current documentation and test your workflow before using it with real users.

Add your own screenshots and a tested demonstration before describing a chatbot as tested or production-ready.

Build a chatbot you can explain and test

Start with one clear purpose, check its answers, and keep a human path available.

Learn n8n basics

Scroll to Top