
WhatsApp RAG Chatbot with Supabase, Gemini 2.5 Flash, and OpenAI Embeddings
Description
Categories
🤖 AI & Machine Learning
Nodes Used
n8n-nodes-base.switchn8n-nodes-base.whatsAppn8n-nodes-base.whatsAppn8n-nodes-base.stickyNoten8n-nodes-base.stickyNoten8n-nodes-base.stickyNoten8n-nodes-base.stickyNoten8n-nodes-base.stickyNoten8n-nodes-base.stickyNoten8n-nodes-base.httpRequest
PriceGratuit
Views0
Last Updated11/28/2025
workflow.json
{
"id": "InxpOwOAX7qfXIvX",
"meta": {
"instanceId": "9c8f658dbece48b519a8ad7757c7d7db7a30c5f3fd29c9dc8afae32fe0c7711a",
"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": {
"id": "QkeJlJh5cCiuLpvg",
"name": "Supabase account"
}
},
"typeVersion": 1.3
},
{
"id": "0a1543fa-c9ce-4d7a-8466-c778bb532cf9",
"name": "New WhatsApp Message",
"type": "n8n-nodes-base.whatsAppTrigger",
"position": [
-304,
560
],
"webhookId": "ec046705-b8f2-4b88-9b98-4fd99975f432",
"parameters": {
"options": {},
"updates": [
"messages"
]
},
"credentials": {
"whatsAppTriggerApi": {
"id": "yVPQQ9GPjNKE9nkZ",
"name": "whatsApp_OAuth_api"
}
},
"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": {
"id": "GVGOwCYLGI5SaqsK",
"name": "OpenAi account"
}
},
"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": {
"id": "QkeJlJh5cCiuLpvg",
"name": "Supabase account"
}
},
"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": {
"id": "SuWwLWBsAfrDFgCm",
"name": "Google Gemini(PaLM) Api account"
}
},
"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
],
"webhookId": "e5e2f982-af07-4274-8937-88ef5109e71b",
"parameters": {
"textBody": "={{ $json.output }}",
"operation": "send",
"phoneNumberId": "768049963047541",
"additionalFields": {},
"recipientPhoneNumber": "={{ $('New WhatsApp Message').item.json.contacts[0].wa_id }}"
},
"credentials": {
"whatsAppApi": {
"id": "LV22R0NzX9vZLEp9",
"name": "whatsapp_reply"
}
},
"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 → text conversion → embeddings with OpenAI → stored in Supabase.\n* **Query Handling:** Query embeddings → retrieve context → 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’s credential manager.\n* Upload documents via WhatsApp to populate the vector database.\n* Ask questions directly on WhatsApp — 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 [[email protected]](mailto:[email protected]).\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
],
"webhookId": "39934341-fa40-46c5-8c26-9aa2f2b3ffcf",
"parameters": {
"resource": "media",
"operation": "mediaUrlGet",
"mediaGetId": "={{ $json.messages[0].document.id }}"
},
"credentials": {
"whatsAppApi": {
"id": "LV22R0NzX9vZLEp9",
"name": "whatsapp_reply"
}
},
"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": {
"id": "y4by5K1yYvLIIf84",
"name": "whatsapp"
}
},
"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,
"pinData": {},
"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
}
]
]
}
}
}