Skip to main content

AI WhatsApp support with human handoff using Gemini, Twilio, and Supabase RAG

Workflow preview

Workflow preview
100%
AI WhatsApp support with human handoff using Gemini, Twilio, and Supabase RAG preview
Open on n8n.io

Important notice

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

1. Workflow Overview

What it is: An n8n workflow that enables AI first WhatsApp support with seamless human handoff. Why it’s unique: The AI agent answers queries using RAG (Supabase vector store + Gemini). If a human ...

Best for

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

Tools used

n8n-nodes-base.twilio, n8n-nodes-base.googledrivetrigger, n8n-nodes-base.googledrive, @n8n/n8n-nodes-langchain.vectorstoresupabase, @n8n/n8n-nodes-langchain.documentdefaultdataloader, @n8n/n8n-nodes-langchain.textsplitterrecursivecharactertextsplitter, n8n-nodes-base.stickynote, n8n-nodes-base.splitinbatches

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
AI WhatsApp support with human handoff using Gemini, Twilio, and Supabase RAG
Workflow name
AI WhatsApp support with human handoff using Gemini, Twilio, and Supabase RAG

Quick Overview

What it is: An n8n workflow that enables AI-first WhatsApp support with seamless human handoff. Why it’s unique: The AI agent answers queries using RAG (Supabase vector store + Gemini). If a human intervenes, the AI steps down. If there’s no human reply within 2 hours, the AI resumes. Channel constraints: Respects WhatsApp’s 24-hour customer care window and requires approved message templates for out-of-window messages.

How It Works

AI-first: Incoming WhatsApp messages are routed to an AI agent (Gemini) with knowledge grounded by a Supabase vector store. Human-in-the-loop: When a human responds in the dashboard, AI pauses for 2 hours for that conversation. Auto-resume: If no human reply within 2 hours, AI automatically resumes. Compliance: Only responds within 24 hours of the user’s last message, or via approved templates when outside this window.

Architecture (At a Glance)

Transport: Twilio WhatsApp; n8n http node. RAG: Supabase (Postgres + embeddings) stores knowledgebase. LLM: Google Gemini (free API key supported). Handoff: Human dashboard (GitHub project) logs and labels AI vs Human responses, and controls AI pause/resume. Prerequisites n8n (self-hosted or cloud) with public webhook access. Twilio account with a WhatsApp-enabled number. Supabase project for vector store. Google Gemini API key. Human dashboard: https://github.com/shadrack-ago/whatsapp-dashboard.git Setup Steps (n8n + Integrations) Import workflow in n8n Create new workflow → Import from JSON → Paste the provided JSON. Enable the workflow. Create credentials Twilio: Add TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, TWILIO_PHONE_NUMBER. Do NOT paste real secrets publicly. Gemini: Add GEMINI_API_KEY. Supabase: Add SUPABASE_URL, SUPABASE_ANON_KEY (or service role where needed), and your table/bucket names. Connect Twilio WhatsApp WhatsApp Business setup in Twilio, or Sandbox for testing. Point Twilio incoming webhook to your n8n webhook URL. Ensure approved templates for any out-of-window messaging. Set environment variables (examples) TWILIO_ACCOUNT_SID=... TWILIO_AUTH_TOKEN=... TWILIO_PHONE_NUMBER=+1... GEMINI_API_KEY=... SUPABASE_URL=... SUPABASE_ANON_KEY=... SUPABASE_TABLE=knowledge_base EMBEDDING_MODEL HUMAN_TIMEOUT_MS=7200000 (2 hours) Human-in-the-loop dashboard Follow the repo guide: https://github.com/shadrack-ago/whatsapp-dashboard.git Run the dashboard and connect it to the same conversation store used by the workflow. Verify that human responses are captured and labeled; confirm AI pause/resume logic. Supabase for RAG Create table(s) for documents and embeddings. Ingest content per this tutorial:Supabase Tutorial Confirm your n8n nodes query the vector store before calling Gemini. Gemini setup Get API key: Gemini API Set model (e.g., gemini-pro or latest available in your environment). Test Send a WhatsApp message to your Twilio number. Observe AI response. Trigger a human reply via the dashboard → confirm AI pauses for that thread. Wait 2 hours or adjust HUMAN_TIMEOUT_MS to test auto-resume. Customization Providers: You can swap Twilio for Meta’s WhatsApp Cloud API; keep the 24-hour and template rules. Tone/Policies: Adjust system prompts and fallback behaviors in the LLM node. RAG Quality: Tune chunking, TOP_K, and embedding model for better retrieval. Timeouts: Change HUMAN_TIMEOUT_MS to alter handoff duration. WhatsApp Policy Notes 24-hour window: Replies must occur within 24 hours of user’s last message; otherwise use an approved template. Templates: Create and get approval inside Twilio/Meta before sending out-of-window messages. Security & Reliability Secrets: Store all keys in n8n credentials or environment variables. Never commit secrets to repos. Logging: Use the dashboard to audit AI vs Human messages. Rate limits: Add retry/backoff nodes for Twilio and LLM calls. Troubleshooting No replies: Check Twilio webhook URL and n8n workflow is active. Policy blocks: Ensure template use outside 24-hour window. Poor answers: Improve RAG data, increase TOP_K, refine prompts. Handoff not pausing: Verify dashboard is writing the “human active” flag that the workflow reads. Links Human dashboard (Full guide): GitHub Repo Link

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 - Send an SMS/MMS/WhatsApp message

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

Block 2 - Google Drive Trigger

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

Block 3 - Google Drive Trigger1

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

Block 4 - Download file

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

Block 5 - Supabase Vector Store

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

Block 6 - Default Data Loader

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

Block 7 - Recursive Character Text Splitter

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

Block 8 - Sticky Note

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

Block 9 - Knowledgebase

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

Block 10 - Loop Over Items

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

Block 11 - Embeddings OpenAI

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

Block 12 - Think

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

Block 13 - Calculator

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

Block 14 - conversation buffer

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

Block 15 - Deletes old records

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

Block 16 - Set the fields for mapping

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

Block 17 - human in the loop

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

Block 18 - Sticky Note7

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

Block 19 - Validate text input

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 20 - Sticky Note1

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

Block 21 - 2hour Filter

Type / Role
n8n-nodes-base.filter - filter
Config choices
Version 2.2

Block 22 - Twilio (whatsapp) Trigger

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

Block 23 - Airtable CRM

Type / Role
n8n-nodes-base.airtableTool - airtableTool
Config choices
Version 2.1

Block 24 - Sticky Note2

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

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

3. Summary Table

Workflow AI WhatsApp support with human handoff using Gemini, Twilio, and Supabase RAG
Complexity advanced
Nodes 27
Categories Support Chatbot, AI RAG
Author Shadrack
Published 10 Dec 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/11648/11648.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 AI WhatsApp support with human handoff using Gemini, Twilio, and Supabase RAG do?

What it is: An n8n workflow that enables AI first WhatsApp support with seamless human handoff. Why it’s unique: The AI agent answers queries using RAG (Supabase vector store + Gemini). If a human ...

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.