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

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.

0
Downloads
104
Views
8.78
Quality Score
intermediate
Complexity
Author:Manav Desai(View Original →)
Created:8/13/2025
Updated:10/13/2025

🔒 Please log in to import templates to n8n and favorite templates

Workflow Visualization

Loading...

Preparing workflow renderer

Comments (0)

Login to post comments