WhatsApp RAG Chatbot with Supabase, Gemini 2.5 Flash, and OpenAI Embeddings

Go to Workflow
104 views
Built by Manav Desai Manav Desai
Created on June 06, 2026

Description

WhatsApp RAG Chatbot with Supabase, Gemini 2.5 Flash, and OpenAI Embeddings

This n8n template demonstrates how to build a WhatsApp-based AI chatbot that answers user questions using document retrieval (RAG) powered by Supabase for storage, OpenAI embeddings for semantic search, and Gemini 2.5 Flash LLM for generating high-quality responses.

Use cases are many: Turn your WhatsApp into a knowledge assistant for FAQs, customer support, or internal company documents — all without coding.

Good to know

The workflow uses OpenAI embeddings for both document embeddings and query embeddings, ensuring accurate semantic search.
Gemini 2.5 Flash LLM** is used to generate user-friendly answers from the retrieved context.
Messages are processed in real-time and sent back directly to WhatsApp.
Workflow is modular — you can split document ingestion and query handling for large-scale setups.
Supabase and WhatsApp API credentials must be configured before running.

How it works

Trigger: A new WhatsApp message triggers the workflow via webhook.
Message Check: Determines if the message is a query or a document upload.
Document Handling:
Fetch file URL from WhatsApp.
Convert binary to text.
Generate embeddings with OpenAI and store them in Supabase.
Query Handling:
Generate query embeddings with OpenAI.
Retrieve relevant context from Supabase.
Pass context to Gemini 2.5 Flash LLM to compose a response.
Response: Send the answer back to the user on WhatsApp.

Optional: Add Gmail node to forward chat logs or daily summaries.

How to use

Configure WhatsApp Business API webhook for incoming messages.
Add your Supabase and OpenAI credentials in n8n’s credentials manager.
Upload documents via WhatsApp to populate the Supabase vector store.
Ask queries — the bot retrieves context and answers using Gemini 2.5 Flash.

Requirements

WhatsApp Business API** (or Twilio WhatsApp Sandbox)
Supabase account** (vector storage for embeddings)
OpenAI API key** (for generating embeddings)
Gemini API access** (for LLM responses)

Customising this workflow

Swap WhatsApp with Telegram, Slack, or email for different chat channels.
Extend ingestion to other sources like Google Drive or Notion.
Adjust the number of retrieved documents or prompt style in Gemini for tone control.
Add a Gmail output node to send logs or alerts automatically.

Nodes Used (7)

AI Agent
@n8n/n8n-nodes-langchain.agent
Default Data Loader
@n8n/n8n-nodes-langchain.documentDefaultDataLoader
Embeddings OpenAI
@n8n/n8n-nodes-langchain.embeddingsOpenAi
Google Gemini Chat Model
@n8n/n8n-nodes-langchain.lmChatGoogleGemini
HTTP Request
n8n-nodes-base.httpRequest
Supabase Vector Store
@n8n/n8n-nodes-langchain.vectorStoreSupabase
WhatsApp Business Cloud
n8n-nodes-base.whatsApp