Build a RAG document chatbot with Supabase vector search and OpenRouter
What this workflow does
This workflow builds a Retrieval-Augmented Generation (RAG) document chat assistant inside n8n using Supabase Vector Store and AI models.
The workflow allows users to upload documents, convert them into embeddings, store them inside Supabase pgvector, and query them through an AI chat interface using semantic search.
When a user sends a question through the webhook endpoint, the workflow retrieves the most relevant document chunks from Supabase and uses an AI model to generate a grounded response based on the uploaded documents.
This template includes:
Document ingestion pipeline Recursive text chunking AI embeddings generation Supabase vector storage Semantic retrieval AI-powered document question answering Webhook API integration for frontend apps
How it works
The workflow is split into two main parts:
Document ingestion pipeline
Downloads documents from Google Drive Extracts text from PDFs Splits text into smaller chunks Generates embeddings using AI models Stores embeddings inside Supabase pgvector
RAG chat pipeline
Receives user questions through a webhook Searches Supabase vector database for relevant content Retrieves matching document chunks Sends retrieved context to the AI model Returns grounded responses back to the frontend
Requirements
n8n instance Supabase account with pgvector enabled Google Drive account AI provider credentials (OpenRouter, Gemini, or OpenAI)
Setup
Create a Supabase project and enable pgvector Create the required documents table and match_documents function Connect your Supabase credentials in n8n Connect your AI model credentials Add your Google Drive credentials Upload your documents and run the ingestion workflow Use the webhook endpoint to connect your frontend application
Setup typically takes around 15–30 minutes.
How to customize
You can customize this workflow by:
Switching AI providers (Gemini, OpenRouter, OpenAI) Adjusting chunk size and retrieval count Connecting your own frontend UI Adding support for multiple document sources Expanding the workflow into a multi-user knowledge assistant
This workflow is designed as a practical starting point for building AI-powered document assistants and RAG applications inside n8n.
Related Templates
Track Demo Bookings with Google Calendar to Meta Conversions API Integration
Who is this workflow for? If you're using Meta Ads to generate new leads to your sales pipeline, this workflow is for yo...
Transcribe & Summarize Audio with Whisper and GPT, from Google Drive to Notion
This workflow contains community nodes that are only compatible with the self-hosted version of n8n. Overview This work...
Build a PDF-Based RAG System with OpenAI, Pinecone and Cohere Reranking
This workflow contains community nodes that are only compatible with the self-hosted version of n8n. This workflow prov...
🔒 Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments