Templates / WhatsApp support bot with Google Drive RAG, GPT-4.1-mini and Cohere reranking

WhatsApp support bot with Google Drive RAG, GPT-4.1-mini and Cohere reranking

Ready for 3.0

by Basil Irfan ✓ · 1,263 views · created 2025-09-28 · Support Chatbot, AI RAG

Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.

Nodes used (17)

Supabase Vector StoreGoogle DriveEmbeddings OpenAIDefault Data LoaderCharacter Text SplitterOpenAI Chat ModelAI AgentOpenAIReranker CohereWhatsApp Business CloudSimple Memory

What it does

WhatsApp RAG Agent (Text + Voice) with Weekly Google Drive Sync One-line summary : Answers WhatsApp in under 100 words, understands voice notes, and retrieves trusted answers from your Google Drive docs (RAG) kept fresh weekly. --- What this template does Reply to WhatsApp messages in a polite, human tone with ≤100 words. Understands text and voice notes: auto-downloads audio and transcribes to text. Retrieves answers from your knowledge base (RAG): Google Drive docs → chunk → embed → store in Supabase → rerank with Cohere. Keeps short-term memory across the conversation to avoid repetition. Weekly doc sync from a selected Google Drive folder so non-technical staff can update content without touching n8n. --- Why it matters Zero busywork: Update a Google Doc; the bot learns it on the next sync. Trustworthy answers: Responses come from your vetted docs, not random web text. Voice-first friendly: Handles the WhatsApp reality of “send a voice note.” Safer by design: Guardrails—no pricing unless in KB, no pushy sales, no medical advice. --- Triggers WhatsApp Trigger: Receives incoming messages (text or audio). Google Drive Trigger (weekly): Detects new/updated files in the chosen folder for ingestion. --- App credentials required WhatsApp Business Cloud (App ID, Token, Phone Number ID) OpenAI (Chat + Embeddings) Cohere (Rerank) Supabase (SUPABASEURL, ANONKEY) Google Drive (OAuth2) + target Folder ID --- Suggested environment variables bash WHATSAPPAPPID= WHATSAPPTOKEN= WHATSAPPPHONENUMBERID= OPENAIAPIKEY= COHEREAPIKEY= SUPABASEURL= SUPABASEANONKEY= GDRIVEFOLDERID= RAGTABLENAME="documents" table to store vectors/metadata MAXANSWERWORDS=100 guardrail for concise replies --- Architecture overview Answer-time lane (RAG Tool): 1. Receive WhatsApp message → 2) Transcribe audio if present → 3) Maintain short-term memory → 4) Retrieve from Supabase vectors (topK) → 5) Rerank with Cohere → 6) Compose ≤100-word reply with sources → 7) Send on WhatsApp. Ingest lane (Weekly Sync): A) Detect Drive file updates → B) Download & convert (Docs → text/plain) → C) Chunk (size/overlap) → D) Embed with OpenAI → E) Upsert to Supabase with metadata & hashes. --- How it works (node rundown) | | Node | Key Inputs | Key Outputs | | -- | ------------------------------------------- | ------------------------------- | --------------------------------- | | 1 | WhatsApp Trigger | Incoming message | Raw WhatsApp payload | | 2 | Switch (Attachment presence/type) | Payload | Route: Text or Audio | | 3 | HTTP Request (Audio path) | attachments0.dataurl | Audio file | | 4 | OpenAI – Translate/ASR | Audio file | Transcribed text | | 5 | Merge | Text path + Audio path | Unified text message | | 6 | Simple Memory | Recent turns | Short-term context | | 7 | OpenAI Chat Model | Prompt + message + memory | Draft answer (tool calls allowed) | | 8 | Supabase Vector Tool (retrieve-as-tool) | Query text, topK=10 | Candidate KB passages | | 9 | Cohere Reranker | Candidates | Re-ranked context | | 10 | Send WhatsApp Message | to, body | Reply sent | | 11 | Google Drive Trigger (weekly) | Folder ID, fileUpdated | Changed files | | 12 | Set (File Id) | id from trigger | File ref | | 13 | Google Drive – Download File | Id (Docs→txt) | Raw text | | 14 | Character Text Splitter | chunkSize=2000, overlap=300 | Chunks | | 15 | Default Data Loader | Binary→Document | Clean docs | | 16 | OpenAI Embeddings (ingest) | Chunks | Vectors | | 17 | Supabase Vector Store (insert) | Table: documents | Upserted KB | Notes The KB Tool is the combo of steps 8–9–7 at answer time (retrieve → rerank → answer). The Ingest lane is steps 11–17 (weekly sync of your Drive folder). --- Setup (7‑minute sprint) 1. Import the workflow JSON. 2. Connect credentials: WhatsApp, OpenAI, Cohere, Supabase, Google Drive. 3. Google Drive Trigger: paste your Folder ID; keep fileUpdated event. 4. Download File: ensure Google Docs convert to text/plain. 5. Supabase Vector Store (insert): set table name to documents (or yo

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.