Learn how to build a scalable Retrieval-Augmented Generation (RAG) solution using n8n workflow templates. This n8n automation integrates Supabase for vector storage, TogetherAI for embeddings, and OpenRouter for cost-effective LLM access.
Download this n8n workflow template and start using it instantly.
AI developers needing robust RAG knowledge base solutions.
Users looking for advanced n8n templates for generative AI applications.
Engineers utilizing Supabase for vector storage in their n8n workflows.
Automation specialists seeking to integrate external LLMs like TogetherAI and OpenRouter.
This sophisticated n8n workflow template demonstrates a complete RAG pipeline, divided into a one-time training phase and a continuous runtime phase. The challenge solved is enabling an AI model to answer questions based strictly on a specific, large corpus of proprietary data (a Google Doc). By using TogetherAI for generating embeddings and storing these vectors in a dedicated Supabase database table, the n8n automation significantly improves answer accuracy and reduces reliance on the LLM's general knowledge base.
The resulting chatbot is triggered by a simple chat message, which then utilizes the optimized knowledge base to retrieve context before generating a highly relevant answer via an OpenRouter connection. This complex n8n workflow showcases how powerful, multi-service integrations can be achieved efficiently using various specialized n8n node types.
The entire process is split into two distinct operational flows within this n8n workflow:
BAAI/bge-large-en-v1.5) to generate a vector representation.embed table in the database.When chat message received n8n trigger starts the process when a user sends a message to the public webhook chat interface.matchembeddings1 RPC function. This function uses the query embedding to find the top 5 most semantically similar chunks from the stored knowledge base.qwen/qwen3-8b:free model) to process the final prompt and generate the detailed, contextualized response.To deploy this expert n8n workflow template, follow these steps:
embed and the necessary vector search RPC function (matchembeddings1) set up for similarity search.When chat message received n8n trigger node is active to enable the runtime chatbot. Content for the Training (Google Docs n8n node): Fetches the raw text content from the specified Google Doc URL, serving as the knowledge source for the RAG system. Authentication uses a Service Account.
Splitting into Chunks (Code n8n node): Custom JavaScript code that divides the fetched document into 1000-character segments. This preparation is vital for creating accurate and manageable embeddings.
Embedding Uploaded document / Embend User Message (HTTP Request n8n node): Calls the TogetherAI API endpoint to convert text (either knowledge base chunks or user input) into numerical vector embeddings using the BAAI/bge-large-en-v1.5 model. Requires Together AI API credentials.
Save the embedding in DB (Supabase n8n node): Handles the persistent storage, saving the text chunk and its corresponding vector embedding into the Supabase embed table, completing the knowledge base setup for the n8n workflow.
When chat message received (Chat Trigger n8n trigger): The entry point for the RAG system, responding to new incoming chat messages via a public webhook.
Search Embeddings (HTTP Request n8n node): Executes a query against Supabase, utilizing a custom RPC function to perform vector similarity search, retrieving the top 5 relevant document chunks.
Aggregate (Aggregate n8n node): Combines the disparate retrieved chunks into a single context payload, ready to be injected into the LLM prompt.
Basic LLM Chain (chainLlm n8n node): Defines the core RAG logic and prompting strategy. It creates a robust instruction set for the model, ensuring the answer is grounded in the retrieved context.
qwen/qwen3-8b:free model to generate the final human-readable response.Use this comprehensive n8n workflow to create a Retrieval-Augmented Generation (RAG) chatbot. Automatically sync company policies from Google Drive to Pinecone using Gemini embeddings.

Automate journal paper drafting with this powerful n8n workflow. It uses Qwen-Max (via OpenRouter), searches CrossRef, Semantic Scholar, and OpenAlex for citations, and compiles a full APA-cited document.

Use this n8n workflow to automatically send personalized welcome emails to new QuickBooks customers. This robust n8n template tracks processed customer IDs in Google Sheets to prevent duplicate emails and ensure reliable automation.

Use this powerful n8n workflow to build a custom RAG knowledge base. Upload files via an n8n trigger, embed data using OpenAI, and query context with an AI agent for advanced retrieval.

Build an advanced RAG-powered AI voice agent using this n8n workflow template, integrating Supabase vector storage and Google Gemini (Vertex AI) for accurate customer support responses.

Use this powerful n8n workflow to create a conversational AI agent capable of reading and answering questions based on complex multi-format file uploads (PDF, CSV, images, JSON). Leverage OpenAI and Gemini for advanced RAG capabilities.









































