Knowledge-Powered Chatbot with Claude, Supabase RAG & Postgres Memory - n8n Workflow

Build a powerful, context-aware chatbot using this advanced n8n workflow. Integrates Claude (Anthropic), Supabase Vector Store, and Postgres chat memory for RAG capabilities.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Developers and Integrators: Those looking to deploy advanced, customized AI agents rapidly.
Businesses needing RAG: Organizations requiring a chatbot that answers questions based on specific, internal knowledge bases or documentation.
Automation Specialists: Users interested in leveraging the power of n8n templates for complex language model operations.
n8n Users: Individuals who need to implement conversation memory and specialized tools within a core n8n workflow.

Overview

This sophisticated n8n workflow provides a robust solution for building custom, knowledge-powered chatbots capable of Retrieval-Augmented Generation (RAG). Unlike simple conversational AIs, this specific n8n template integrates seamlessly with external vector databases (Supabase) and internal storage (Postgres) to maintain context and ensure high-accuracy responses based on your proprietary documentation.

The core value is the creation of a powerful AI Agent that uses multiple specialized tools (memory and vector store), orchestrated entirely by n8n. The setup utilizes an initial chat n8n trigger, followed by the AI Agent n8n node which delegates tasks, resulting in an enterprise-ready conversational system. This comprehensive n8n workflow eliminates the need for managing complex infrastructure outside of n8n.

How it Works

This powerful n8n workflow initiates when a message is received via the When chat message received n8n trigger. This action immediately kicks off the flow:


  1. Trigger Initiation: The When chat message received n8n trigger captures the incoming user query, enabling the execution of the entire sequence.

  2. Agent Orchestration: The query is routed to the AI Agent n8n node. This central controller evaluates the user's intent.

  3. Language Model: The agent utilizes the high-performance Anthropic Chat Model (Claude Sonnet 4) to understand the query and formulate a response.

  4. Memory Management: Before responding, the agent checks the Postgres Chat Memory n8n node. This memory tool maintains a history of the last 20 messages, ensuring the response is contextually relevant across the conversation session—a key feature of this n8n workflow.

  5. Knowledge Retrieval (RAG): If the query requires external data (e.g., asking about a product detail), the agent activates the Supabase Vector Store n8n node (configured as a tool). This tool performs a semantic search against the specified knowledge base table (growthaidocuments).

  6. Embedding Service: The vector search performed by the Supabase n8n node is facilitated by the Embeddings OpenAI n8n node, which translates the user query into vectors for similarity matching.

  7. Final Response: Based on the conversation history and any retrieved documents, the AI Agent n8n node generates the final, accurate response, completing the execution of this complex n8n template.

Installation Guide

To deploy this specialized n8n workflow, follow these steps:


  1. Import the n8n workflow: Copy the provided JSON and import it directly into your n8n instance.

  2. Anthropic Credentials: Configure the Anthropic Chat Model n8n node with your Anthropic API key.

  3. OpenAI Credentials (Embeddings): Set up the API key for the Embeddings OpenAI n8n node. This is crucial for vectorizing queries for the RAG functionality.

  4. Postgres Credentials (Memory): The Postgres Chat Memory n8n node utilizes n8n's built-in PostgreSQL instance for memory. Ensure this internal connection is active.

  5. Supabase Credentials (Vector Store): Configure the Supabase Vector Store n8n node with your Supabase API URL and Service Role Key. Ensure the table name specified (growthaidocuments) matches your actual vectorized knowledge base table.

  6. Activate the Trigger: Once all credentials and configurations are complete, activate the When chat message received n8n trigger to make the chatbot live.

This robust n8n workflow is now ready to handle incoming chat messages with deep contextual awareness.

Node Details

When chat message received (n8n trigger):
Function: Serves as the starting point for this n8n workflow, listening for incoming chat queries. It provides a standard interface for connecting external chat platforms via webhooks.
Key Configuration: Setup as a basic chat n8n trigger.

AI Agent (n8n node):
Function: The core decision-making unit. It orchestrates the flow, choosing which connected tools (memory, knowledge base) to use before generating the final response using the language model.
Key Configuration: System Message: "You are a helpful assistant".

Anthropic Chat Model (n8n node):
Function: Provides the LLM capabilities, processing input and generating coherent text. It acts as the brain of the n8n workflow.
Key Configuration: Model selected is claude-sonnet-4-20250514.

Postgres Chat Memory (n8n node):
Function: Maintains conversation state, allowing the agent to remember previous exchanges. Essential for context in any long-running n8n workflow.
Key Configuration: Context Window Length set to 20 messages.

Supabase Vector Store (n8n node):
Function: Acts as a specialized tool for the AI Agent, providing access to the custom knowledge base stored in Supabase for RAG.
Key Configuration: Mode: retrieve-as-tool; Table Name: growthaidocuments; Tool Description: Database.

Embeddings OpenAI (n8n node):
* Function: Converts text (user queries) into numerical vectors (embeddings), enabling the Supabase Vector Store n8n node to perform efficient semantic searches for the knowledge retrieval step.

Related n8n Workflows

Free

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

Featured*