Skip to main content

Build a RAG chatbot using Google Gemini and a Supabase vector store

Workflow preview

Workflow preview
100%
Build a RAG chatbot using Google Gemini and a Supabase vector store preview
Open on n8n.io

1. Workflow Overview

AI Chatbot with RAG: Google Gemini & Supabase Vector Store Summary Build a custom, intelligent knowledge base in minutes. This n8n workflow provides a complete Retrieval Augmented Generation ...

Best for

  • Internal Wiki automation workflows
  • AI RAG automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.errortrigger, n8n-nodes-base.set, @n8n/n8n-nodes-langchain.lmchatgooglegemini, @n8n/n8n-nodes-langchain.chattrigger, @n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.memorypostgreschat, @n8n/n8n-nodes-langchain.vectorstoresupabase

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Tricore Infotech Pvt Ltd.

Original n8n.io source

1.1 Workflow description

Title
Build a RAG chatbot using Google Gemini and a Supabase vector store
Workflow name
Build a RAG chatbot using Google Gemini and a Supabase vector store

🧠 AI Chatbot with RAG: Google Gemini & Supabase Vector Store

πŸ“Œ Summary

Build a custom, intelligent knowledge base in minutes. This n8n workflow provides a complete Retrieval-Augmented Generation (RAG) system using Google Gemini and Supabase. It features a seamless dual-flow design: an ingestion pipeline to process and store your uploaded documents, and a conversational AI agent that queries those documents to provide accurate, context-aware answers while remembering past interactions.


✨ Key Features

  • Two-in-One Architecture: Combines both the document ingestion pipeline and the conversational chat interface into a single, cohesive workflow template.
  • State-of-the-Art AI: Leverages Google Gemini (models/gemini-embedding-001 and models/gemini-2.5-flash) for high-quality text embeddings and intelligent chat generation.
  • Persistent Conversational Memory: Uses PostgreSQL to remember chat histories per sessionId, allowing the AI to maintain context across ongoing conversations. The chat trigger automatically generates a unique Session ID per browser window, keeping individual user conversations completely separate.
  • Vector-Powered Accuracy: Integrates with Supabase (pgvector) to retrieve the top 5 most relevant chunks, ensuring the agent answers based strictly on your uploaded company documents without hallucinating.
  • Global Error Handling: Built-in error triggers actively catch API rate limits, parsing failures, and bad requests, formatting them into clear alerts ready to be routed to your team.

πŸ› οΈ How It Works

  1. Data Ingestion (Knowledge Base Setup): * Documents are uploaded via the Form Trigger and validated for size (<10MB) to prevent parsing timeouts.
  • The text is parsed and split into optimized 1000-character chunks with a 100-character overlap.
  • Gemini generates embeddings for these chunks, which are permanently stored in your Supabase Vector Store.
  1. Query Processing (Chat Interface):
  • A user asks a question via the Chat Trigger.
  • The AI Agent accesses the Postgres database to load previous chat context for that specific user's session.
  • The Agent uses the Supabase Retriever tool to pull the top 5 most relevant document chunks based on the user's query.
  • Gemini formulates a concise, factual response citing the retrieved data.

πŸš€ Setup Instructions

1. Create Database Tables

Before running the workflow, ensure your Supabase/Postgres database has the required tables. ⚠️ See the "DATABASE SETUP (SQL)" sticky note on the canvas for the complete SQL script.

2. Connect Credentials

Connect your Google Gemini API, Supabase (URL and Service Role Key), and Postgres databases. (Note: Your Postgres memory can be hosted within your Supabase project). Ensure your Supabase database has pgvector enabled.

3. Update Table Names

Open the Supabase and Postgres nodes and replace:

  • your_documents_table β†’ your actual table name
  • your_chat_history_table β†’ your actual table name

4. Configure Error Notifications (Important)

The workflow catches errors and formats an alert message, but you must manually connect a messaging node (like Slack, Microsoft Teams, or Email) directly after the Format Error Alert node to receive these notifications.

5. Ingest Data

Open the Upload Knowledge Base Form node, click "Test step", and upload a sample document to index it into your database.

6. Test the Agent

Open the User Chat Trigger node, click "Chat", and ask a question related to the document you just uploaded!


πŸ“¦ Nodes Used

User-Facing Interfaces:

  • Chat Trigger - The user-facing chat interface for asking questions (includes Pin Data for easy testing).
  • Form Trigger & File Validator - Provides a simple UI to upload and size-check files, with explicitly stated rules for the end-user. Includes a Webhook Response for success confirmation.

Data Processing Pipeline (Ingestion):

  • Document Default Data Loader - Extracts raw text from uploaded files.
  • Character Text Splitter - Chunks large texts into digestible pieces (1000 chars) for the AI.
  • Embeddings Google Gemini - Converts text chunks into mathematical vectors.
  • Supabase Inserter - Stores vectors in the knowledge base.

AI & Memory (Query):

  • Supabase Retriever - Performs semantic search to find top 5 relevant chunks.
  • Postgres Chat Memory - Stores and retrieves historical chat context by session ID.
  • Google Gemini Chat Model - The core LLM powering the conversational responses.
  • Knowledge-Base AI Agent - Orchestrates the memory, tools, and LLM to answer the user's prompt.

Error Handling:

  • Error Trigger & Format Error Alert - Catches global execution failures. Connect an output to route these formatted alerts to your team.

⚠️ Limitations & Guidelines

  • File Size & Type: The workflow limits files to 10MB to prevent memory exhaustion, and currently supports .pdf, .txt, .docx, .pptx. Highly complex PDFs with nested tables or un-OCR'd images may fail parsing.
  • Context Window Limits: While the Agent tracks sessions, very long ongoing conversations (e.g., hundreds of messages) will eventually hit the LLM's token limit. It is recommended to implement a cron job or separate workflow to prune the chat_history table periodically or clear old sessions.
  • API Costs: Each document ingestion and chat query uses Gemini API calls (embeddings + chat). Monitor your API usage.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - πŸ“– Complete Documentation

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 2 - Group: Chat Phase

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 3 - Group: Ingestion Phase

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 4 - Database Schema

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - Group: Error Handling

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 6 - Error Trigger

Type / Role
n8n-nodes-base.errorTrigger - errorTrigger
Config choices
Version 1

Block 7 - Format Error Alert

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 8 - Google Gemini Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1

Block 9 - User Chat Trigger

Type / Role
@n8n/n8n-nodes-langchain.chatTrigger - chatTrigger
Config choices
Version 1.4

Block 10 - Knowledge-Base AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 3.1

Block 11 - Persistent Chat History

Type / Role
@n8n/n8n-nodes-langchain.memoryPostgresChat - memoryPostgresChat
Config choices
Version 1.3

Block 12 - Supabase Retriever

Type / Role
@n8n/n8n-nodes-langchain.vectorStoreSupabase - vectorStoreSupabase
Config choices
Version 1.3

Block 13 - Upload Knowledge Base Form

Type / Role
n8n-nodes-base.formTrigger - formTrigger
Config choices
Version 2.5

Block 14 - File < 10MB?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.3

Block 15 - Parse File Size

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 16 - Reject Upload

Type / Role
n8n-nodes-base.stopAndError - stopAndError
Config choices
Version 1

Block 17 - Supabase Inserter

Type / Role
@n8n/n8n-nodes-langchain.vectorStoreSupabase - vectorStoreSupabase
Config choices
Version 1.3

Block 18 - Success Response

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.1

Block 19 - Document Parser

Type / Role
@n8n/n8n-nodes-langchain.documentDefaultDataLoader - documentDefaultDataLoader
Config choices
Version 1.1

Block 20 - Text Chunker

Type / Role
@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter - textSplitterCharacterTextSplitter
Config choices
Version 1

Block 21 - Gemini Embeddings

Type / Role
@n8n/n8n-nodes-langchain.embeddingsGoogleGemini - embeddingsGoogleGemini
Config choices
Version 1

3. Summary Table

Workflow Build a RAG chatbot using Google Gemini and a Supabase vector store
Complexity advanced
Nodes 21
Categories Internal Wiki, AI RAG
Author Tricore Infotech Pvt Ltd
Published 15 May 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/15738/15738.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Build a RAG chatbot using Google Gemini and a Supabase vector store do?

AI Chatbot with RAG: Google Gemini & Supabase Vector Store Summary Build a custom, intelligent knowledge base in minutes. This n8n workflow provides a complete Retrieval Augmented Generation ...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Internal Wiki, AI RAG use case.