RAG-Powered WhatsApp Assistant with Gemini and Supabase - n8n Workflow

Deploy a powerful, knowledge-based WhatsApp Assistant using this sophisticated n8n workflow. Integrates Google Docs, Supabase vector search, and the Gemini AI model for advanced RAG automation.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Teams needing automated customer support via WhatsApp, leveraging specific internal documents.

  • Developers looking for advanced RAG n8n templates integrating multiple cloud services.

  • Businesses wanting to integrate the Google Gemini AI model with a proprietary knowledge base for contextual replies.

  • Users specializing in complex vector database operations within an n8n workflow structure.

Overview

This solution leverages the power of n8n to build a sophisticated Retrieval-Augmented Generation (RAG) system accessible directly via WhatsApp. The core challenge this n8n workflow solves is providing accurate, context-specific answers based on internal documents (sourced from Google Docs), rather than relying solely on the general knowledge of the AI model.

The workflow is divided into two parts: an ingestion pipeline and a query pipeline. The ingestion part reads documents, chunks the content using an n8n node dedicated to custom code, embeds it, and stores it in a Supabase vector database. The query pipeline, initiated by the WhatsApp trigger, ensures that every user question is processed, contextually searched in the database, and then answered intelligently by the Google Gemini Chat Model. This is an essential n8n template for robust knowledge management and high-performance automation.

How it Works

This powerful n8n workflow operates in two distinct modes: knowledge ingestion and real-time query response.

A. Knowledge Base Ingestion (Training):


  1. The process starts with the 'When clicking ‘Execute workflow’' n8n trigger for manual initiation.

  2. The 'Content for the Training' n8n node pulls documentation from a specified Google Docs file.

  3. The content is passed to the 'Splitting into Chunks' custom code n8n node for preparation, ensuring optimal size for vector processing.

  4. The prepared chunks are embedded using the 'Embedding Uploaded document' HTTP Request n8n node, converting text into vectors.

  5. Finally, the 'Save the embedding in DB' Supabase n8n node persists both the text and vectors into your database for efficient RAG retrieval.

B. WhatsApp Interaction (Query):


  1. A user message activates the 'WhatsApp Trigger', initiating the conversational flow within this n8n workflow.

  2. The 'If' n8n node checks message validity before proceeding.

  3. The user's incoming message is converted into an embedding via the 'Embend User Message' HTTP Request n8n node.

  4. This vector is used by the 'Search Embeddings' n8n node (HTTP Request) to perform a similarity search against the Supabase database, retrieving the most relevant knowledge chunks (the RAG step).

  5. The 'Aggregate' n8n node bundles these retrieved chunks into a unified context payload.

  6. The 'AI Agent' n8n node forwards the user question and the retrieved context to the language model.

  7. The language model, powered by the 'Google Gemini Chat Model' n8n node, generates a precise answer grounded strictly in the RAG context.

  8. The final output is delivered back to the user using the 'Send message' WhatsApp n8n node, completing the automation cycle.

Installation Guide


  1. Import: Copy the provided n8n workflow JSON and paste it directly into your n8n instance to start configuring this n8n template.

  2. Credentials Setup:

Configure the Google Docs n8n node with credentials allowing read access to your knowledge document.
Set up Supabase credentials for the 'Save the embedding in DB' n8n node, ensuring connection details for your vector database table are correct.
* Ensure API keys are configured for the Google Gemini Chat Model n8n node.

  1. Embedding Service: The HTTP Request n8n nodes for embedding ('Embedding Uploaded document' and 'Embend User Message') require configuration pointing to your chosen embedding provider API (e.g., dedicated endpoint URL, headers, and payload structure).

  2. Webhooks & Trigger: Activate the 'WhatsApp Trigger' n8n trigger to generate the necessary webhook URL. This URL must then be configured within your WhatsApp Business API settings to listen for incoming messages.

  3. Initial Load: Manually execute the n8n workflow starting from the 'When clicking ‘Execute workflow’' n8n trigger to index your initial knowledge base content into the Supabase vector database.

Node Details

WhatsApp Trigger: The primary n8n trigger for the query pipeline. It securely captures incoming user messages, initiating the full RAG sequence for every request to the n8n workflow.
Google Docs: Used in the ingestion pipeline to retrieve the raw text content from the knowledge repository.
Code (Splitting into Chunks): A custom n8n node script responsible for text preprocessing, ensuring the knowledge base is chunked optimally before vectorization.
HTTP Request (Embedding Uploaded document): This n8n node executes the API call to generate dense vector embeddings from the chunked text data.
Supabase (Save the embedding in DB): A crucial storage n8n node for the vector database. It efficiently saves both the text chunks and their embeddings, ready for context retrieval.
HTTP Request (Embend User Message): Converts the real-time incoming user query from the WhatsApp trigger into a vector representation, necessary for the subsequent similarity search operation.
HTTP Request (Search Embeddings): Executes the similarity search query against the Supabase database, retrieving relevant contextual documents to ground the LLM's response.
AI Agent (LangChain Agent): Manages the orchestration of the RAG process, feeding the user prompt and the retrieved context to the LLM for a structured answer generation using this powerful n8n node.
Google Gemini Chat Model: The specific large language model n8n node utilized by the Agent to formulate the final, contextualized response based on the knowledge provided by the RAG system.
WhatsApp (Send message): The final action n8n node, ensuring the AI-generated answer is delivered back to the originating WhatsApp user, closing the automated conversation loop.

Related n8n Workflows

Paid

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

Featured*