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

889 views · 💬 Support Chatbots

Description

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


Why it matters


Triggers


App credentials required


Suggested environment variables

WHATSAPP_APP_ID=
WHATSAPP_TOKEN=
WHATSAPP_PHONE_NUMBER_ID=
OPENAI_API_KEY=
COHERE_API_KEY=
SUPABASE_URL=
SUPABASE_ANON_KEY=
GDRIVE_FOLDER_ID=
RAG_TABLE_NAME="documents"     # table to store vectors/metadata
MAX_ANSWER_WORDS=100            # guardrail for concise replies

Architecture overview


How it works (node rundown)

#NodeKey InputsKey Outputs
1WhatsApp TriggerIncoming messageRaw WhatsApp payload
2Switch (Attachment presence/type)PayloadRoute: Text or Audio
3HTTP Request (Audio path)attachments[0].data_urlAudio file
4OpenAI – Translate/ASRAudio fileTranscribed text
5MergeText path + Audio pathUnified text message
6Simple MemoryRecent turnsShort-term context
7OpenAI Chat ModelPrompt + message + memoryDraft answer (tool calls allowed)
8Supabase Vector Tool (retrieve-as-tool)Query text, topK=10Candidate KB passages
9Cohere RerankerCandidatesRe-ranked context
10Send WhatsApp Messageto, bodyReply sent
11Google Drive Trigger (weekly)Folder ID, fileUpdatedChanged files
12Set (File Id)id from triggerFile ref
13Google Drive – Download FileId (Docs→txt)Raw text
14Character Text SplitterchunkSize=2000, overlap=300Chunks
15Default Data LoaderBinary→DocumentClean docs
16OpenAI Embeddings (ingest)ChunksVectors
17Supabase Vector Store (insert)Table: documentsUpserted KB

Notes


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 your schema).

  6. Character Text Splitter: keep chunkSize=2000, overlap=300 (balanced recall/latency).

  7. Retrieve-as-tool: set topK=10 and enable reranker.

  8. Send WhatsApp Message mapping:

    • Recipient: {{$("WhatsApp Trigger").item.json.messages[0].from}}
    • Body: {{$json.output}}
  9. Test:

    • Send a text and a voice note to your WhatsApp number → confirm concise answers.
    • Drop a Google Doc into the watched folder → verify it’s chunked/embedded on the next weekly poll (or run ingest nodes once manually).

Prompt, tone & guardrails


Data model (minimum viable)

Table documents (example columns):

Indexes


Observability & ops


Customization


Safety & compliance


Troubleshooting


Categories & tags


Pricing (rough, BYO keys)


Nodes used in workflow

WhatsApp Trigger, Switch, HTTP Request, OpenAI (ASR + Chat + Embeddings), Merge, Simple Memory, Supabase Vector Tool (retrieve), Cohere Reranker, Google Drive Trigger, Set, Google Drive – Download, Character Text Splitter, Default Data Loader.

🔗 Nodes Used

HTTP Request, Google Drive, Google Drive Trigger, WhatsApp Business Cloud, AI Agent, Embeddings OpenAI

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup