Skip to main content

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

Workflow preview

Workflow preview
100%
WhatsApp support bot with Google Drive RAG, GPT-4.1-mini and Cohere reranking preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

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...

Best for

  • Support Chatbot automation workflows
  • AI RAG automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.vectorstoresupabase, n8n-nodes-base.googledrivetrigger, n8n-nodes-base.set, n8n-nodes-base.googledrive, @n8n/n8n-nodes-langchain.embeddingsopenai, @n8n/n8n-nodes-langchain.documentdefaultdataloader, @n8n/n8n-nodes-langchain.textsplittercharactertextsplitter, n8n-nodes-base.stickynote

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Basil Irfan.

Original n8n.io source

1.1 Workflow description

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

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 (SUPABASE_URL, ANON_KEY)
  • Google Drive (OAuth2) + target Folder ID

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

  • 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) attachments[0].data_url 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 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

  • System prompt:

    • Be polite, human, and concise (MAX_ANSWER_WORDS).
    • Cite or reference only the KB content; if unknown, say so and offer to escalate.
    • No prices unless present in the KB. No medical advice.
  • Temperature: start at 0.2 for factual replies.

  • Memory window: keep a short rolling buffer (e.g., last 4–6 turns).


Data model (minimum viable)

Table documents (example columns):

  • id (uuid)
  • source_url (text)
  • title (text)
  • chunk (text)
  • embedding (vector/float[] depending on extension)
  • chunk_hash (text)
  • updated_at (timestamp)

Indexes

  • Unique index on chunk_hash to dedupe
  • Index on updated_at for syncs

Observability & ops

  • Log question, selected chunk ids/hashes, and final response to a DB/Sheet for QA.
  • Add a low-confidence route (score threshold) → Slack/Telegram escalation to a human.
  • Track latency and token usage to tune topK and chunk sizes.

Customization

  • Latency vs quality: try topK=6–8 and chunkSize=1200 for speed.
  • Languages: ASR node can be swapped for native multilingual output.
  • Escalation: add channel handoff on low confidence or no KB hits.
  • Sync cadence: change Drive Trigger to daily if content updates frequently.

Safety & compliance

  • No medical advice. If uncertain or clinical, ask to schedule a consult or refer to the right department.
  • PII: Don’t log full phone numbers in plaintext analytics; hash where possible.
  • Prices & rates: Only answer if present in the KB; otherwise hand off to front desk.

Troubleshooting

  • No reply sent: Ensure Send message node reads {{$json.output}} (Agent’s response property).
  • Audio path failing: Confirm attachments[0].data_url exists and HTTP node fetches a valid file.
  • KB not updating: Manually execute the ingest lane; check rows in Supabase.
  • Irrelevant answers: Lower temperature to 0.2, increase overlap to 400, and verify Drive docs are clean and structured.

Categories & tags

  • Categories: AI, Customer Support, Healthcare Ops, RAG, WhatsApp
  • Tags: WhatsApp, RAG, Google Drive, Supabase, OpenAI, Cohere, Voice Notes

Pricing (rough, BYO keys)

  • n8n: self-host free; n8n.cloud billed by plan.
  • OpenAI, Cohere: usage-based by tokens/calls.
  • Supabase: free tier + usage; vector storage billed by size.
  • WhatsApp Cloud: Meta pricing per conversation.

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.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Supabase Vector Store

Type / Role
@n8n/n8n-nodes-langchain.vectorStoreSupabase - vectorStoreSupabase
Config choices
Version 1.3

Block 2 - Google Drive Trigger

Type / Role
n8n-nodes-base.googleDriveTrigger - googleDriveTrigger
Config choices
Version 1

Block 3 - Edit Fields

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 4 - Download file

Type / Role
n8n-nodes-base.googleDrive - googleDrive
Config choices
Version 3

Block 5 - Embeddings OpenAI

Type / Role
@n8n/n8n-nodes-langchain.embeddingsOpenAi - embeddingsOpenAi
Config choices
Version 1.2

Block 6 - Default Data Loader

Type / Role
@n8n/n8n-nodes-langchain.documentDefaultDataLoader - documentDefaultDataLoader
Config choices
Version 1.1

Block 7 - Character Text Splitter

Type / Role
@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter - textSplitterCharacterTextSplitter
Config choices
Version 1

Block 8 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 9 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 10 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 2

Block 11 - Switch

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3.2

Block 12 - HTTP Request

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 13 - Translate a recording

Type / Role
@n8n/n8n-nodes-langchain.openAi - openAi
Config choices
Version 1.8

Block 14 - Merge

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Block 15 - Embeddings OpenAI1

Type / Role
@n8n/n8n-nodes-langchain.embeddingsOpenAi - embeddingsOpenAi
Config choices
Version 1.2

Block 16 - Reranker Cohere

Type / Role
@n8n/n8n-nodes-langchain.rerankerCohere - rerankerCohere
Config choices
Version 1

Block 17 - Send message

Type / Role
n8n-nodes-base.whatsApp - whatsApp
Config choices
Version 1

Block 18 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 19 - WhatsApp Trigger

Type / Role
n8n-nodes-base.whatsAppTrigger - whatsAppTrigger
Config choices
Version 1

Block 20 - Kknowledge_base

Type / Role
@n8n/n8n-nodes-langchain.vectorStoreSupabase - vectorStoreSupabase
Config choices
Version 1.3

Block 21 - Simple Memory

Type / Role
@n8n/n8n-nodes-langchain.memoryBufferWindow - memoryBufferWindow
Config choices
Version 1.3

Block 22 - HTTP Request1

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 23 - Edit Fields1

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 24 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Showing the first 24 of 25 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow WhatsApp support bot with Google Drive RAG, GPT-4.1-mini and Cohere reranking
Complexity advanced
Nodes 25
Categories Support Chatbot, AI RAG
Author Basil Irfan
Published 28 Sept 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/9043/9043.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does WhatsApp support bot with Google Drive RAG, GPT-4.1-mini and Cohere reranking do?

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...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Support Chatbot, AI RAG use case.