Build a robust RAG system using n8n and Supabase. This advanced n8n workflow template uses AI agents to decompose complex queries, filter results, and synthesize high-quality answers with GPT-5.
Download this n8n workflow template and start using it instantly.
AI Engineers and Developers needing sophisticated, hallucination-resistant RAG solutions.
Technical writers and content creators looking to build Q&A bots based on structured documentation using an n8n workflow.
Users implementing knowledge base retrieval systems who require strict relevance filtering.
n8n automation specialists seeking advanced n8n templates for LangChain integration and custom tooling.
Traditional RAG systems often fail on complex, multi-faceted queries because the single retrieval call returns inadequate or conflicting information. This powerful n8n workflow solves this by implementing an Advanced Multi-Query RAG Agent pattern. The core of this system is a sophisticated AI agent that automatically breaks down the user's complex question into 1 to 5 smaller sub-queries.
These sub-queries are processed by a dedicated sub-workflow, which retrieves relevant chunks from a Supabase vector store, cleans the data, and crucially, applies a relevance filter (score > 0.4) to ensure only high-quality context is returned. This robust filtering mechanism, managed within an n8n node, significantly improves the accuracy of the final answer. This n8n workflow template provides a blueprint for reliable, production-ready knowledge retrieval.
The process begins with the When chat message received n8n trigger, initiating the chat conversation flow.
AI Agent n8n node. Based on its system prompt, the agent, utilizing the OpenAI Chat Model (GPT-5 Mini), analyzes the request and breaks it down into an array of sub-queries (1 to 5 questions).Query knowledge base n8n tool (a sub-workflow call), passing the array of sub-queries.Split Out n8n node to process each query individually. Each sub-query is embedded via Embeddings OpenAI1 and used to query the Supabase Vector Store1 n8n node.Keep score over 0.4 n8n node filters out low-relevance results. If chunks remain, they are aggregated (Aggregate chunks). If no chunks pass the filter, a 'no match' message is generated.AI Agent. The agent then uses the Think n8n tool to reason over the retrieved information, ensuring coherence and adherence to the course content before finally crafting and returning the comprehensive response to the user. This structured use of n8n nodes ensures reliability and traceable outputs.To deploy this powerful n8n workflow, follow these steps:
OpenAI Chat Model (for the LLM) and the Embeddings OpenAI1 n8n node (for embedding lookup). Note that these might use different OpenAI API accounts.Supabase Vector Store1 n8n node. Verify that the table name is correctly set to 'documents' or your specified vector table.Query knowledge base n8n tool must be linked to the secondary RAG sub-workflow that contains the vector store retrieval logic. If you imported both workflows, ensure the workflowId is updated to match the ID of your RAG retrieval workflow (Template: c9FlK6mLuWAwqLsP).System Message in the AI Agent n8n node to align with the specific domain or course content of your knowledge base. When chat message received (n8n trigger): The starting point, listening for incoming chat messages to begin the automation.
AI Agent (LangChain n8n node): The core control structure. It manages conversational flow, utilizes memory (Simple Memory), connects to the LLM (OpenAI Chat Model), and orchestrates the use of retrieval tools.
Query knowledge base (Tool Workflow n8n node): A crucial custom tool that allows the Agent to execute a dedicated n8n workflow for complex data retrieval, passing an array of generated sub-queries.
Supabase Vector Store1 (n8n node): Performs similarity searches against the Supabase database, fetching relevant text chunks based on the query embedding generated by the OpenAI embedding model.
Keep score over 0.4 (Filter n8n node): Implements strict quality control. This n8n node filters out any retrieved documents where the relevance score is below 0.4, drastically reducing noise and potential hallucinations in the final output.
Think (LangChain n8n node): A reasoning tool used by the agent to critically analyze the retrieved knowledge and plan the final synthesis before responding to the user's initial prompt.
Use this robust n8n workflow to create an AI-powered SMS support system. Integrates GPT-4 for real-time sentiment analysis, data enrichment, and automated escalation management via Twilio and PostgreSQL.

Automate peer recognition using this powerful n8n workflow. Integrate Jotform, GPT-4 for objective analysis, Google Sheets for tracking, and Gmail for instant notifications. Get started with these versatile n8n templates.

Automate an AI phone agent using n8n to handle customer calls, perform RAG lookups via Qdrant, extract call summaries, and book appointments in Google Calendar using specialized n8n templates.

Build a powerful RAG AI assistant using this complex n8n workflow template. It integrates Anthropic Claude 4, Supabase vector DB, Postgres memory, and multi-format file analysis (PDF, CSV, Image, Audio).








































