How I Built a WhatsApp Automation Chatbot Using n8n, Gemini, Google Sheets & Meta API

Introduction
Imagine running a busy Kirana store. Customers constantly ping you on WhatsApp for daily essentials like milk, sugar, or snacks. Handling these requests manually can get overwhelming, especially when you’re also managing the store.
That’s when automation comes in. Using n8n, I built a WhatsApp chatbot that:
Understands what customers want (via AI)
Records the order automatically
Sends back a confirmation message instantly
This blog will walk you through the tools, components, workflow, and real-life example of how I made this possible.
Tools & Components
1️⃣ n8n – The Automation Engine
What it is: n8n is an open-source workflow automation platform, similar to Zapier, but much more flexible.
Why I used it:
Visual, drag-and-drop workflow builder.
Integrates with hundreds of apps & APIs.
Lets me connect WhatsApp, AI, and Google Sheets in one place.
Role in my project: Acts as the central brain. It receives WhatsApp messages, triggers AI analysis, logs data in Sheets, and sends replies.
2️⃣ Meta WhatsApp Cloud API – Communication Layer
What it is: The official API from Meta (Facebook) for businesses to send and receive messages on WhatsApp.
Why I used it:
Reliable & supported directly by Meta.
Handles message delivery and webhook events.
No need for unofficial hacks or WhatsApp Business app.
Role in my project: It’s the entry and exit point.
Entry: Customer’s WhatsApp message comes in via API.
Exit: Confirmation message is sent back using the API.
3️⃣ Gemini AI – The Smart Assistant
What it is: Google’s AI model (like ChatGPT) designed for text understanding and reasoning.
Why I used it:
Can understand natural human text like “Bhaiya, 2 kg sugar bhej do.”
Extracts structured data (item names, quantities).
Can distinguish between an Order vs. an FAQ.
Role in my project: Acts as the intelligent interpreter.
If message = Order → Extract items, qty, format JSON.
If message = FAQ → Fetch reply (e.g., “We are open from 8 AM to 10 PM”).

4️⃣ Google Sheets – Order Management
What it is: A cloud-based spreadsheet tool from Google.
Why I used it:
Easy to set up, no coding needed.
Simple interface for store owners.
Can later connect with dashboards or reports.
Role in my project: Serves as the order database.
Logs customer number, order items, date/time, and status.
Can also be extended to track payments, stock, or delivery status.

5️⃣ Sample Store Inventory – The Data Reference
What it is: A mock product catalog (Sugar, Rice, Oil, Milk, Maggi, Biscuits).
Why I used it:
To validate AI outputs (if item exists in store or not).
To simulate a real Kirana store use-case.
Role in my project: Provides the product list for order validation and FAQs like “Do you have Maggi?”
How It Works (Workflow Overview)
Here’s the big picture flow:
Customer → WhatsApp:
Message like: “I want 1 litre milk and 2 packets of Maggi.”Meta WhatsApp Cloud API:
Forwards message to n8n webhook.n8n Workflow Trigger:
Starts automation once a new message arrives.Gemini AI Node:
Extracts order details:
{"item": "Milk", "quantity": "1 Litre"}
{"item": "Maggi", "quantity": "2 Packets"}
- Classifies intent (Order / FAQ).
Google Sheets Node:
Appends data into sheet:Customer number
Order items
Date & Time
Status = Confirmed
WhatsApp Reply Node:
Sends confirmation:
“✅ Order confirmed: 1L Milk, 2 Packets Maggi. Delivery in 30 mins.”
(Insert Workflow Diagram Image: Webhook → Gemini → Sheets → WhatsApp Send)
Step-by-Step Setup
Step 1: Connect WhatsApp Cloud API
Register on Meta for Developers.
Create an app → Enable WhatsApp.
Generate Access Tok****en & Phone Number I****D.
Add n8n webhook URL under “Callback URL”.
Step 2: Build n8n Workflow
Webhook Node: Captures messages from WhatsApp.
Gemini Node: Analyzes text.
Google She****ets Node: Stores structured order.
WhatsApp Sen****d Node: Sends back confirmation.
Step 3: Setup Google Sheets
Columns:
| Order ID | Customer Number | Item | Quantity | Date | Status |
Step 4: Configure Gemini Prompt
Sample prompt:
"You are a chatbot for a Kirana store. If the message is an order, extract items and quantity in JSON. If it’s a question, respond with store info (timing: 8 AM – 10 PM)."
Example Run
Message: “Do you have 2kg rice and 1 litre oil?”
AI Output:
{
"order": [
{"item": "Rice", "quantity": "2kg"},
{"item": "Oil", "quantity": "1 Litre"}
],
"intent": "order"
}
Google Sheet Log:
Order ID Number Item Qty Date Status 102 +91XXXXXXX Rice 2kg 2025-08-31 Confirmed 102 +91XXXXXXX Oil 1L 2025-08-31 Confirmed WhatsApp Reply:
“✅ Your order for 2kg Rice and 1L Oil is confirmed. Thank you!”
🌟 Benefits of This Setup
✅ Customers get instant replies
✅ Store owners save time and avoid mistakes
✅ Easy to scale – just add more nodes
✅ Affordable – uses free tools (Sheets + n8n self-hosted)
🚀 Future Upgrades
Integrate payment collection (UPI, Stripe, Razorpay).
Add stock availability check from Google Sheets.
Create a dashboard with order analytics.
Add multi-language support (Marathi, Hindi, English).
🎯 Conclusion
This project proves how even small businesses can become AI-powered with simple, free, and open-source tools.
By connecting WhatsApp + n8n + Gemini + Google Sheets, you can automate orders, answer FAQs, and focus more on running your store instead of replying to messages all day.



