what it does
โญ If this workflow helped you, please leave a review on n8n Basket!
---
๐ค WhatsApp AI Customer Support Bot
Fully Automated AI-Powered Customer Support for WhatsApp Business
Workflow ID: `e0yLrzmWqsWlRcZE`
Webhook URL: `https://YOUR-N8N-INSTANCE/webhook/whatsapp-ai-support`
Total Nodes: 30 (22 functional + 8 sticky notes)
AI Model: Groq llama-3.3-70b-versatile
Status: Production-Ready
---
๐ Overview
This workflow turns your WhatsApp Business number into a fully automated, AI-powered customer support agent. When a customer sends your business a WhatsApp message, the bot reads the message, understands what the customer needs, finds the best answer from your FAQ knowledge base, and replies instantly โ all without any human involvement. If the bot is unsure or the customer needs a real person, it automatically escalates the conversation to you with a Telegram alert and creates a task in Notion so nothing falls through the cracks.
Who is this for?
- ๐ Restaurants & food businesses โ handle order questions, menu inquiries, and booking requests
- ๐ช Retail shops โ answer price questions, stock availability, and return policies
- ๐ฅ Clinics & healthcare โ manage appointment requests and general FAQs
- ๐ Salons & spas โ handle booking requests and service inquiries
- ๐ฆ Any WhatsApp-based business โ if your customers message you on WhatsApp, this bot works for you
Key Benefits:
- โ
24/7 customer support โ your bot never sleeps, never takes a day off
- โ
Zero human effort for FAQs โ common questions are answered instantly by AI
- โ
Instant escalation โ complex issues reach you within seconds via Telegram
- โ
Complete conversation logging โ every message is tracked in Google Sheets
- โ
Anti-spam protection โ prevents abuse from message flooding
- โ
Task management โ escalated issues automatically create Notion tasks
---
โจ Features
๐ง AI Message Classification
- Every incoming message is analyzed by the AI and classified into one of 6 categories:
- `ORDER_INQUIRY` โ questions about existing or new orders
- `PRICE_QUESTION` โ asking about costs, pricing, or fees
- `COMPLAINT` โ customer complaints or negative feedback
- `BOOKING_REQUEST` โ appointment or reservation requests
- `GENERAL_FAQ` โ general questions about your business
- `HUMAN_NEEDED` โ customer explicitly asks for a human, or message is abusive/threatening
- Extracts the customer's name if mentioned in the message
- Determines the intent (what the customer actually wants)
- Assigns an urgency level (low / medium / high)
- Calculates a confidence score (0.0 to 1.0) for routing decisions
๐ TF-IDF Knowledge Base Matching
- Reads your FAQ spreadsheet from Google Sheets automatically
- Uses TF-IDF similarity scoring to find the top 3 most relevant answers from your knowledge base
- Removes common stop words for better matching accuracy
- Falls back gracefully if the FAQ sheet is empty or unavailable
๐ค GPT-Powered Personalized Reply Generation
- Powered by Groq llama-3.3-70b-versatile (blazing fast, high quality)
- System prompt: *"You are a friendly, professional customer support agent. Answer concisely in under 100 words."*
- Uses the classified intent + top 3 FAQ matches to generate accurate replies
- Personalizes replies using the customer's name when available
- Automatically escalates if the AI is not confident in its answer
๐ก๏ธ Anti-Spam Protection
- Built-in rate limiter: maximum 5 messages per 10 minutes per phone number
- Uses n8n's persistent workflow static data โ no external database needed
- Rate-limited users receive a polite message automatically
โ
Auto-Reply Branch (Confident Answers)
- Sends AI-generated reply back to customer via WhatsApp Business API
- Logs the full conversation to Google Sheets
- Sends a real-time Telegram notification to you
๐จ Escalation Branch (Uncertain or Complex Queries)
- Triggers when category is `HUMAN_NEEDED` OR confidence score is below `0.7`
- Sends the customer a hold message
- Logs escalation details to a separate Google Sheets tab
- Sends an urgent Telegram alert to you
- Creates a Notion task in your "Support Tasks" database
โ ๏ธ Full Error Handling
- Built-in Error Trigger node catches any errors across the entire workflow
- Sends a Telegram alert with error details
---
๐ ๏ธ Required Credentials
You need 5 credentials to run this workflow:
| # | Credential Name | Service | Cost |
|---|----------------|---------|------|
| 1 | Groq_HTTP_Auth | Groq AI API | Free tier available |
| 2 | WhatsApp account | WhatsApp Business API | Free (Meta for Developers) |
| 3 | Google_Sheets_OAuth | Google Sheets | Free (Google account) |
| 4 | Telegram account | Telegram Bot API | Free |
| 5 | Notion_API | Notion API | Free (Notion account) |
---
1๏ธโฃ Groq API Key (AI Engine)
1. Go to [https://console.groq.com](https://console.groq.com)
2. Click "Sign Up" โ create a free account
3. Click "API Keys" โ "Create API Key"
4. Copy the key (starts with `gsk_`)
5. In n8n, create a new HTTP Header Auth credential named `Groq_HTTP_Auth`
6. Set Header Name: `Authorization`, Header Value: `Bearer YOUR_KEY_HERE`
> ๐ก Free tier: Groq offers generous free usage. Most small businesses will never need to pay.
---
2๏ธโฃ WhatsApp Business API
1. Go to [https://developers.facebook.com](https://developers.facebook.com)
2. Log in โ "My Apps" โ "Create App" โ Select "Business"
3. Add WhatsApp product โ follow setup steps
4. Go to WhatsApp โ API Setup โ copy your Phone Number ID and access token
5. For permanent access: Business Settings โ System Users โ generate permanent token with `whatsapp_business_messaging` permission
6. In n8n, open the "WhatsApp account" credential โ paste your permanent access token
> โ ๏ธ You need a verified Meta Business Account. Verification can take 1โ3 business days.
---
3๏ธโฃ Google Sheets OAuth
1. Go to [https://console.cloud.google.com](https://console.cloud.google.com)
2. Create a new project โ APIs & Services โ Library โ Enable Google Sheets API
3. Go to Credentials โ Create Credentials โ OAuth client ID
4. Configure OAuth consent screen first (External, add yourself as test user)
5. Application type: Web application
6. Authorized redirect URI: `https://YOUR-N8N-INSTANCE/rest/oauth2-credential/callback`
7. Copy Client ID and Client Secret
8. In n8n, open "Google_Sheets_OAuth" โ paste credentials โ "Sign in with Google"
---
4๏ธโฃ Telegram Bot Token
1. Open Telegram โ search @BotFather โ send `/newbot`
2. Enter a display name and username (must end in `bot`)
3. Copy the bot token (looks like `7123456789:AAHx8kLmN-abc123`)
4. In n8n, open "Telegram account" โ paste token in the "Access Token" field
---
5๏ธโฃ Notion API Key
1. Go to [https://www.notion.so/my-integrations](https://www.notion.so/my-integrations)
2. Click "+ New Integration" โ name it โ select your workspace
3. Copy the Internal Integration Token (starts with `ntn_`)
4. In n8n, open "Notion_API" โ paste token in "API Key" field
5. Important: Go to your Notion database โ "..." โ "Connections" โ connect your integration
---
๐ Google Sheets Setup
Create one Google Spreadsheet with three tabs:
Tab 1 โ `FAQ_Knowledge_Base`
| Column A | Column B |
|----------|----------|
| Question | Answer |
Example rows to get started:
| Question | Answer |
|----------|--------|
| What are your business hours? | We're open Monday to Saturday, 9:00 AM to 6:00 PM. Closed Sundays and public holidays. |
| How can I place an order? | Send us a message with the items you'd like. We'll confirm availability and total. |
| What payment methods do you accept? | We accept cash on delivery, bank transfer, and all major credit/debit cards. |
| How long does delivery take? | Standard delivery takes 30โ60 minutes within our delivery zone. |
| What is your return/refund policy? | Full refunds for defective or incorrect items within 24 hours. Contact us with your order details. |
| Do you offer discounts for bulk orders? | Yes! Contact us for a custom quote on large orders. |
| Where are you located? | We're at [Your Address Here]. Walk-ins welcome during business hours! |
| How can I book an appointment? | Send your preferred date, time, and service. We'll confirm within minutes. |
> ๐ก Add at least 15โ20 FAQ rows for best results.
Tab 2 โ `Conversations`
| Timestamp | Customer Phone | Customer Name | Message | Bot Reply | Category | Urgency | Confidence | Resolution |
|---|---|---|---|---|---|---|---|---|
Tab 3 โ `Escalations`
| Timestamp | Customer Phone | Customer Name | Message | Category | Urgency | Confidence | Reason | Status |
|---|---|---|---|---|---|---|---|---|
---
๐๏ธ Notion Database Setup
Create a database called Support Tasks with these exact properties:
| Property Name | Type | Options |
|---------------|------|---------|
| Customer Phone | Title | Default first column โ just rename it |
| Message | Rich Text | โ |
| Priority | Select | `Low` (green), `Medium` (yellow), `High` (red) |
| Status | Select | `Open` (red), `In Progress` (yellow), `Closed` (green) |
| Category | Select | `ORDER_INQUIRY`, `PRICE_QUESTION`, `COMPLAINT`, `BOOKING_REQUEST`, `GENERAL_FAQ`, `HUMAN_NEEDED` |
---
๐ฒ WhatsApp Business API Setup
1. Go to [https://developers.facebook.com](https://developers.facebook.com) โ open your app
2. Navigate to WhatsApp โ Configuration
3. Under Webhook, click "Edit"
4. Callback URL: `https://YOUR-N8N-INSTANCE/webhook/whatsapp-ai-support`
5. Verify Token: any secret string you choose (e.g., `my-support-bot-2024`)
6. Click "Verify and Save"
7. Under Webhook Fields, click "Subscribe" next to messages
> โ ๏ธ The workflow must be Active in n8n for webhook verification to succeed.
---
๐ค Telegram Bot Setup โ Getting Your Chat ID
1. Open Telegram โ search @userinfobot โ send any message
2. It replies with your Chat ID (a number like `123456789`)
3. Add this Chat ID to 4 nodes in the workflow:
| Node Name | Purpose |
|-----------|---------|
| Notify Owner | Auto-handled message summaries |
| Alert Owner | Urgent escalation alerts |
| Error Telegram Alert | Error notifications |
| Send Daily Summary *(in summary workflow)* | Daily report |
---
โถ๏ธ How to Import & Activate
1. Open your n8n instance in your browser
2. Click "Add workflow" โ "..." menu โ "Import from File..."
3. Select the downloaded `.json` file
4. Double-click each โ ๏ธ node and select the matching credential:
| Node | Credential |
|------|------------|
| WhatsApp nodes | WhatsApp account |
| Google Sheets nodes | Google_Sheets_OAuth |
| Telegram nodes | Telegram account |
| HTTP Request (Groq) nodes | Groq_HTTP_Auth |
| Notion node | Notion_API |
5. Click the toggle switch top-right โ turn Active (green)
---
๐งช How to Test
Test 1: Basic FAQ Question
Send to your WhatsApp Business number:
> *"What are your business hours?"*
Expected: AI reply within 5โ10 seconds + Telegram notification + Google Sheets row logged
Test 2: Trigger Escalation
Send:
> *"I want to speak to a human agent please"*
Expected: Hold message on WhatsApp + urgent Telegram alert + Notion task created + Escalations sheet row
Test 3: Anti-Spam
Send 6 messages in quick succession โ the 6th should receive:
> *"โณ Please wait, our system is processing your previous messages."*
Test 4: Low-Confidence Escalation
Send:
> *"asdfjkl what do I do about the thing from last time"*
Expected: escalation branch triggered (confidence below 0.7)
---
โ Troubleshooting
Problem 1: Webhook Not Receiving Messages
- โ
Workflow must be Active
- โ
Webhook URL in Meta Dashboard must be exactly: `https://YOUR-N8N-INSTANCE/webhook/whatsapp-ai-support`
- โ
Must be subscribed to the "messages" webhook field
- โ
Check Meta App Dashboard โ Webhooks for delivery errors
Problem 2: Google Sheets Permission Denied
- โ
Re-authorize: open Google_Sheets_OAuth โ "Sign in with Google"
- โ
Confirm Google Sheets API is enabled in Google Cloud Console
- โ
Make sure your Google account has edit access to the spreadsheet
Problem 3: Groq API Rate Limit
- โ
Check usage at [https://console.groq.com/usage](https://console.groq.com/usage)
- โ
Verify the credential value starts with `Bearer gsk_...`
- โ
Free tier limits reset quickly โ wait a few minutes and retry
Problem 4: Telegram Chat ID Not Working
- โ
Send `/start` to your bot first
- โ
Chat ID must be a number, not a username
- โ
Group Chat IDs start with `-100`
- โ
All 4 Telegram nodes must have the Chat ID set
Problem 5: Anti-Spam Triggering Incorrectly
- โ
Deactivate โ wait 10 seconds โ reactivate to reset all counters
- โ
Default: 5 messages per 10 minutes per phone โ adjust in "Rate Limit Check" node
Problem 6: Notion Task Not Created
- โ
Connect your integration to the database: Notion DB โ "..." โ Connections
- โ
Database must have exact property names: `Customer Phone`, `Message`, `Priority`, `Status`, `Category`
- โ
Priority options must include: `Low`, `Medium`, `High`
- โ
Status options must include: `Open`
---
๐ก Customization Tips
Add More FAQ Rows
Open your Google Sheet โ FAQ_Knowledge_Base tab โ add rows. No restart needed.
Change the AI Reply Tone
Open "Generate AI Reply" node โ edit the system prompt:
- Casual: *"You are a fun, casual support agent. Use emojis."*
- Formal: *"You are a formal, corporate customer support representative."*
- Sales-focused: *"You are a helpful agent who also suggests additional products when relevant."*
Change the Spam Threshold
Open "Rate Limit Check" node โ find:
```javascript
const WINDOW_MS = 10 * 60 * 1000; // 10 minutes
const MAX_MESSAGES = 5;