This workflow corresponds to n8n.io template #6771 — we link there as the canonical source.
This workflow follows the Agent → Documentdefaultdataloader recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"id": "InxpOwOAX7qfXIvX",
"meta": {
"templateCredsSetupCompleted": true
},
"name": "WhatsApp RAG Chatbot with Supabase, Gemini 2.5 Flash, and OpenAI Embeddings",
"tags": [],
"nodes": [
{
"id": "d02befa0-18c6-4aa6-8c94-e84f6993a406",
"name": "Retrieve Context from Supabase",
"type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
"position": [
480,
496
],
"parameters": {
"mode": "retrieve-as-tool",
"options": {},
"tableName": {
"__rl": true,
"mode": "list",
"value": "documents",
"cachedResultName": "documents"
},
"toolDescription": "call this tool to reach the goal"
},
"credentials": {
"supabaseApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.3
},
{
"id": "0a1543fa-c9ce-4d7a-8466-c778bb532cf9",
"name": "New WhatsApp Message",
"type": "n8n-nodes-base.whatsAppTrigger",
"position": [
-304,
560
],
"parameters": {
"options": {},
"updates": [
"messages"
]
},
"credentials": {
"whatsAppTriggerApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "79a849a1-da91-4af8-9ba4-7e6e504e4eeb",
"name": "Check if Query or Document",
"type": "n8n-nodes-base.switch",
"position": [
-48,
560
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "query",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "dcd448ce-72f0-4c83-b721-3417a746473e",
"operator": {
"type": "object",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.messages[0].text }}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "document",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "8b2b9810-08c7-452f-a2e0-ba1453586919",
"operator": {
"type": "object",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.messages[0].document }}",
"rightValue": ""
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3.2
},
{
"id": "50a072f5-e8ce-4eae-adf9-8fbf4fd494da",
"name": "Convert File to Text",
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"position": [
1008,
1216
],
"parameters": {
"options": {},
"dataType": "binary"
},
"typeVersion": 1.1
},
{
"id": "3932f7f3-524e-40b1-87dd-c9ff1e85d95e",
"name": "Generate OpenAI Embeddings",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"position": [
816,
1216
],
"parameters": {
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "75f6cdb9-ef4f-43cd-83ae-b8ceb602b876",
"name": "Store Embeddings in Supabase",
"type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
"position": [
896,
928
],
"parameters": {
"mode": "insert",
"options": {},
"tableName": {
"__rl": true,
"mode": "list",
"value": "documents",
"cachedResultName": "documents"
}
},
"credentials": {
"supabaseApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.3
},
{
"id": "d569775f-c2d0-4c12-bb89-fe36667de6ce",
"name": "Google Gemini LLM",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
352,
496
],
"parameters": {
"options": {}
},
"credentials": {
"googlePalmApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "ee2b82a8-cd95-4ff0-8e42-3d67eedd848d",
"name": "RAG Query Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
368,
272
],
"parameters": {
"text": "={{ $json.messages[0].text }}",
"options": {},
"promptType": "define"
},
"typeVersion": 2.1
},
{
"id": "8eeb7e2c-11de-4ea5-8287-3ef026427f3d",
"name": "Send WhatsApp Reply",
"type": "n8n-nodes-base.whatsApp",
"position": [
912,
272
],
"parameters": {
"textBody": "={{ $json.output }}",
"operation": "send",
"phoneNumberId": "768049963047541",
"additionalFields": {},
"recipientPhoneNumber": "={{ $('New WhatsApp Message').item.json.contacts[0].wa_id }}"
},
"credentials": {
"whatsAppApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "a73408a1-1ea2-4867-9c3d-8b6d54989d7d",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
240,
736
],
"parameters": {
"color": 7,
"width": 960,
"height": 384,
"content": "## Document Flow:\n\n* Fetch file URL from WhatsApp message\n* Download and convert file to readable text\n* Generate embeddings with OpenAI\n* Store embeddings in Supabase for future queries"
},
"typeVersion": 1
},
{
"id": "1281e915-20c7-462e-9416-c980a14790c6",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
240,
80
],
"parameters": {
"color": 7,
"width": 560,
"height": 544,
"content": "## Query Flow:\n\n- Convert user query into embeddings (OpenAI)\n- Match embeddings with Supabase vectors to find context\n- Send retrieved context to Gemini 2.5 Flash for answer\n- Return concise response to WhatsApp user"
},
"typeVersion": 1
},
{
"id": "9a40bc48-1dbe-4ed9-9a7e-d6bf86b2e935",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-112,
432
],
"parameters": {
"color": 7,
"height": 304,
"content": "## Message Check: \n- Determines if the message is a query(text) or a document upload. "
},
"typeVersion": 1
},
{
"id": "72e122e4-f577-43ef-bf2e-e51712ef7bd9",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1168,
208
],
"parameters": {
"width": 800,
"height": 832,
"content": "## Try It Out!\n### This n8n template demonstrates how to build a WhatsApp-based AI chatbot using **document retrieval (RAG)**.It stores documents in **Supabase** with **OpenAI embeddings** and generates user-friendly answers using **Gemini 2.5 Flash LLM**.\n\nUse cases: Turn your WhatsApp into a **knowledge assistant** for FAQs, customer support, or internal team knowledge.\n\n### How it works\n\n* **Trigger:** A WhatsApp webhook activates on every new message.\n* **Message Check:** Detects if the message is a document upload or a query.\n* **Document Handling:** File URL \u2192 text conversion \u2192 embeddings with OpenAI \u2192 stored in Supabase.\n* **Query Handling:** Query embeddings \u2192 retrieve context \u2192 Gemini 2.5 Flash generates response.\n* **Reply:** Sends the answer back to the user via WhatsApp.\n\n### How to use\n\n* Configure **WhatsApp Business API**, **Supabase**, and **OpenAI credentials** in n8n\u2019s credential manager.\n* Upload documents via WhatsApp to populate the vector database.\n* Ask questions directly on WhatsApp \u2014 the bot retrieves context and replies instantly.\n\n### Requirements\n\n* WhatsApp Business API (or Twilio sandbox)\n* Supabase account (vector storage)\n* OpenAI API key (embeddings)\n* Gemini API access (LLM responses)\n\n### Need Help?\n\nDM me on [X (formerly Twitter)](https://x.com/manav170303) or email [titanfactz@gmail.com](mailto:titanfactz@gmail.com).\n\nAlways open to feedback and improvements!"
},
"typeVersion": 1
},
{
"id": "7698302b-cba7-43ed-abbb-c6c036cd1380",
"name": "Get Document URL",
"type": "n8n-nodes-base.whatsApp",
"position": [
288,
928
],
"parameters": {
"resource": "media",
"operation": "mediaUrlGet",
"mediaGetId": "={{ $json.messages[0].document.id }}"
},
"credentials": {
"whatsAppApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "9eb653ec-15c8-4854-b841-7151efe2cf9d",
"name": "Download WhatsApp Document",
"type": "n8n-nodes-base.httpRequest",
"position": [
560,
928
],
"parameters": {
"url": "={{ $json.url }}",
"options": {},
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth"
},
"credentials": {
"httpHeaderAuth": {
"name": "<your credential>"
}
},
"typeVersion": 4.2
},
{
"id": "e0621b81-844e-4427-bee2-38ebbe0bd734",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
1296,
736
],
"parameters": {
"width": 336,
"height": 832,
"content": "## Document Upload Flow\n\nExample: Shows how a document is uploaded and detected in the workflow. \n\n\n"
},
"typeVersion": 1
},
{
"id": "001539b5-1ea9-4656-ad10-bf07cb77393b",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
1104,
-192
],
"parameters": {
"width": 336,
"height": 848,
"content": "## Contextual Answer Flow\n\nExample: Demonstrates how the bot retrieves context from Supabase and responds with Gemini 2.5 Flash. \n\n\n"
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "daa23c09-b671-4bb3-b3c3-f84193cf0ad6",
"connections": {
"RAG Query Agent": {
"main": [
[
{
"node": "Send WhatsApp Reply",
"type": "main",
"index": 0
}
]
]
},
"Get Document URL": {
"main": [
[
{
"node": "Download WhatsApp Document",
"type": "main",
"index": 0
}
]
]
},
"Google Gemini LLM": {
"ai_languageModel": [
[
{
"node": "RAG Query Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Convert File to Text": {
"ai_document": [
[
{
"node": "Store Embeddings in Supabase",
"type": "ai_document",
"index": 0
}
]
]
},
"New WhatsApp Message": {
"main": [
[
{
"node": "Check if Query or Document",
"type": "main",
"index": 0
}
]
]
},
"Check if Query or Document": {
"main": [
[
{
"node": "RAG Query Agent",
"type": "main",
"index": 0
}
],
[
{
"node": "Get Document URL",
"type": "main",
"index": 0
}
]
]
},
"Download WhatsApp Document": {
"main": [
[
{
"node": "Store Embeddings in Supabase",
"type": "main",
"index": 0
}
]
]
},
"Generate OpenAI Embeddings": {
"ai_embedding": [
[
{
"node": "Store Embeddings in Supabase",
"type": "ai_embedding",
"index": 0
},
{
"node": "Retrieve Context from Supabase",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Store Embeddings in Supabase": {
"main": [
[]
]
},
"Retrieve Context from Supabase": {
"ai_tool": [
[
{
"node": "RAG Query Agent",
"type": "ai_tool",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
googlePalmApihttpHeaderAuthopenAiApisupabaseApiwhatsAppApiwhatsAppTriggerApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
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.
Source: https://n8n.io/workflows/6771/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
Your AI workforce is ready. Are you?
This intelligent chatbot leverages cutting-edge financial APIs and AI-driven analysis to deliver comprehensive stock research reports. Get instant access to professional-grade investment analysis that
The "WhatsApp Productivity Assistant with Memory and AI Imaging" is a comprehensive n8n workflow that transforms your WhatsApp into a powerful, multi-talented AI assistant. It's designed to handle a w
Who is this for? This workflow is ideal for HR teams, startups, and enterprises that want to handle employee interactions through WhatsApp and automate responses using LLM (OpenAI) and intelligent rou
4827. Uses agent, lmChatOpenAi, embeddingsOpenAi, memoryBufferWindow. Event-driven trigger; 35 nodes.