Hey n8n community! ![]()
I wanted to share an end-to-end workflow architecture I recently built to tackle a common pain point for SMBs: scaling WhatsApp sales and lead qualification without getting hit by expensive per-contact SaaS subscription fees.
Instead of relying on third-party chatbot platforms, this setup runs entirely through n8n + WhatsApp Business Cloud API + Google Gemini, using lightweight RAG (Retrieval-Augmented Generation) connected directly to Google Docs and Sheets for real-time knowledge retrieval.
I recorded a step-by-step walkthrough and put together a free workflow JSON export for anyone looking to replicate or adapt this logic for their own clients or internal ops.
System Architecture & Tech Stack
Here’s how the data flows through the n8n nodes:
Plaintext
[Incoming WhatsApp Webhook]
│
▼
[n8n Route & Filter Node] ──(Ignore non-text / bot loops)
│
▼
[n8n AI Agent Node]
├── Model: Google Gemini (Google AI Studio)
├── Memory: Window Buffer Memory (for conversation context)
└── Tools / RAG Retrieval:
├── Google Docs (Company Profile & Sales Guidelines)
└── Google Sheets (Product Catalog & Pricing)
│
▼
[WhatsApp Cloud API Node] ──(Sends tailored response to user)
Key Technical Takeaways & Workflow Highlights
-
Webhook Payload Handling: How to isolate incoming WhatsApp text messages from Meta’s status payloads (
sent,delivered,read) inside n8n to avoid infinite execution loops. -
Contextual Knowledge Retrieval (RAG): Fetching structured product lists from Google Sheets and un-structured brand guidelines from Google Docs dynamically into the Gemini System Prompt context window.
-
Conversational Memory: Implementing window buffer memory so the agent retains context across multiple back-and-forth messages on WhatsApp.
-
Lead Logging: Storing conversation logs back into Google Sheets for review or downstream CRM syncing.
Step-by-Step Tutorial & Resources
If you want to build this step-by-step or import the pre-built workflow into your own n8n instance:
Full Video Walkthrough: https://youtu.be/AlxGbatqb_A
Free n8n Workflow JSON & Templates:
Video Timestamps:
-
00:00- Architecture overview & use case -
00:33- Logic flow: Gemini + WhatsApp API + n8n + RAG -
02:07- Step 1: Setting up Meta Developer Portal & WhatsApp Webhooks -
03:40- Step 2: Configuring Credentials (WhatsApp API & Gemini) in n8n -
05:06- Step 3: Building message filters to handle incoming payloads -
06:25- Step 4: Configuring the AI Agent, Memory, and System Prompts -
07:27- Step 5: Connecting Google Docs & Sheets as RAG knowledge sources -
09:07- Step 6: End-to-end live testing & debugging -
11:13- Next steps: Webhooks to CRM / Post-qualification routing
Discussion / Feedback
I’d love to hear how you all are handling multi-modal inputs or long-term conversation memory on WhatsApp inside n8n! If you test the workflow and run into any edge cases with Meta’s API or rate limits on Gemini, drop a comment below and I’m happy to help debug.