Multichannel Customer Support AI Assistant for Chatwoot - n8n Workflow

Build a powerful multichannel customer support AI assistant using this n8n workflow. Integrates Chatwoot webhooks with OpenRouter/LLMs to automatically respond to user queries using a defined knowledge base.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Businesses using Chatwoot across multiple communication channels (WhatsApp, Telegram, etc.).
Support teams looking to automate level-1 responses using a constrained knowledge base.
Developers seeking an advanced n8n workflow template for building custom LLM-powered integrations.
Anyone needing an n8n solution to prevent infinite reply loops in webhook-triggered chat bots.

Overview

This comprehensive n8n workflow provides a robust solution for deploying an automated AI assistant directly into your Chatwoot customer support platform. By integrating Chatwoot’s webhook system with the power of modern Language Models (LLMs) via OpenRouter, this n8n workflow ensures that every incoming customer query across all connected channels receives a fast, consistent, and knowledge-based response.

The primary value of this n8n templates is its sophisticated architecture: it fetches the full conversation history, processes it into a clean, context-rich format, and utilizes strict prompting directives to ensure the AI assistant adheres only to a pre-defined knowledge base, minimizing hallucinations. Furthermore, the inclusion of a crucial 'Check If Incoming Message' n8n node prevents reply loops, a common pitfall in chatbot automation. This n8n workflow is the perfect foundation for building scalable, multichannel AI support systems.

How it Works

The n8n workflow begins execution immediately upon receiving a message created event via the Chatwoot Webhook n8n trigger.


  1. Receive and Filter: The initial webhook n8n trigger captures the event. A subsequent Set n8n node extracts and structures only the necessary conversation and account IDs (convid, accountid).

  2. Loop Prevention: An If n8n node checks if the message type is strictly "incoming". This step is critical; if the message is not incoming (i.e., it's an agent reply or the AI’s own outgoing message), the n8n workflow stops, preventing an endless conversation loop.

  3. Context Retrieval: If the message is incoming, an HTTP Request n8n node uses the extracted IDs to call the Chatwoot API and load the full conversation history.

  4. History Formatting: A Code n8n node processes this history. It cleans the data, identifies senders as 'user' or 'assistant', and formats the entire thread into a single, delimited string ([USER] : message \n [ASSISTANT] : reply). This structured input is ideal for the language model.

  5. AI Generation: The Chatwoot Assistant n8n node (a LangChain LLM chain) receives the formatted history. It uses the OpenRouter Chat Model to apply a detailed System Prompt that defines its role and restricts its answers strictly to the provided knowledge base, ensuring accurate, focused support.

  6. Response Delivery: Finally, a second HTTP Request n8n node uses the generated AI text, along with the original accountid and convid, to post the outgoing assistant message back into the Chatwoot conversation. This completes the automated response cycle in this powerful n8n workflow.

Installation Guide

To use this powerful n8n templates, follow these steps:


  1. Import the n8n workflow: Copy the provided JSON data and paste it into your n8n instance via the "New" menu -> "Import from JSON."

  2. Chatwoot Webhook Setup:

Activate the Chatwoot Webhook n8n trigger node and copy its unique URL.
In your Chatwoot instance, navigate to Settings > Integrations > Webhooks.
Create a new webhook, paste the n8n URL, and ensure only the message created event is selected.

  1. Credential Setup (OpenRouter):

Click on the OpenRouter Chat Model n8n node and set up your OpenRouter API credentials.
Alternative: Replace this n8n node with any preferred LLM provider (e.g., OpenAI Chat Model).

  1. API Token Configuration (Chatwoot):

Update the URL parameter in both Load Chatwoot Conversation History and Send Message n8n nodes, replacing https://yourchatwooturl.com with your actual Chatwoot domain.
* In both HTTP Request n8n nodes, replace YOURACCESSTOKEN with a valid Chatwoot Super Admin API access token. This is required for fetching history and posting replies.

  1. Activation: Save the n8n workflow and toggle it to "Active."

Node Details

Chatwoot Webhook (n8n trigger):
Function: Acts as the entry point for this n8n workflow, listening for POST requests from Chatwoot whenever a message is created in any integrated channel. It is the core n8n trigger.
Key Configuration: Configured to a specific webhookId and path for receiving the message created event.
Squize Webhook Data (Set n8n node):
Function: Cleans the bulky incoming JSON payload, extracting essential metadata like accountid, convid, and messagecontent using expression variables.
Check If Incoming Message (If n8n node):
Function: Implements flow control, proceeding only if the received messagetype equals "incoming." This is a crucial defense against infinite automation loops in this n8n workflow.
Load Chatwoot Conversation History (HTTP Request n8n node):
Function: Authenticates with the Chatwoot API token to retrieve all preceding messages in the current conversation, ensuring the AI has full context before responding.
Process Loaded History (Code n8n node):
Function: Transforms the raw conversation history array into a single, structured string ([ROLE]: Content), making it optimized for the subsequent LLM call. It correctly assigns user and assistant roles.
Chatwoot Assistant (LangChain LLM Chain n8n node):
Function: The core intelligence of the n8n workflow. It uses the input history and a detailed prompt to generate a knowledge-based answer, constrained by the built-in KNOWLEDGE BASE section.
Send Message (HTTP Request n8n node):
* Function: Posts the AI-generated response ({{ $json.text }}) back to the specific Chatwoot conversation, marked as an outgoing message.

Related n8n Workflows

Free

Nodes: 8 Nodes
Updated: December 26 2025
View all
Created by

Building AI Systems & Multi-Agent Assistants incorporating data collection, intent classification, human handoff, RAG, and API-driven CRM actions. 10+ years in software development including iOS and Android. Now in the process of founding my AI Automation Platform - Agenza AI.

Featured*