Build a WhatsApp AI Chatbot in 15 Minutes β For Small Businesses
Twilio + OpenAI/Sarvam for a multilingual chatbot β with a no-code option too
WhatsApp has 500M+ users in India β your customers are already there. Manual replies are expensive and time-gated (what happens when a customer messages at 2am?). An AI chatbot gives you 24/7 presence, and with the right stack you can be live in 15 minutes.
Decision: Code vs No-Code
No-Code Path (Faster, But Limited)
- BotPenguin (Indian, starts Rs 1,500/mo)
- WATI (Rs 2,800/mo)
- Interakt (Rs 999/mo, basic tier)
Pros: drag-drop, templates, 2-hour setup Cons: hard to customise, recurring cost, shallow AI depth
Code Path (More Work, Infinitely Flexible)
- Twilio WhatsApp Business API + your backend + AI API
- One-time setup effort, then infinite flexibility
- Cost: Rs 0.80-1.20 per conversation (Twilio) + AI costs
We'll cover the code path because its ceiling is the highest.
Prerequisites
- WhatsApp Business Account (verified with business docs)
- Twilio account with WhatsApp enabled
- OpenAI/Claude/Sarvam API key
- Server (Cloudflare Workers' free tier works, or Render/Railway)
Step 1 β Twilio Setup (5 min)
- Sign up at twilio.com/console
- Messaging β Try WhatsApp β scan the QR with your WhatsApp Business
- Note your Account SID + Auth Token
- You get a Sandbox number; production needs Facebook Business Manager approval (1-2 days)
For development, the Sandbox WhatsApp number is perfect.
Step 2 β FastAPI Webhook (5 min)
# main.py
from fastapi import FastAPI, Form
from twilio.twiml.messaging_response import MessagingResponse
from openai import OpenAI
import os
app = FastAPI()
openai_client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
conversations = {} # In production: use Redis / PostgreSQL
@app.post("/whatsapp")
async def whatsapp_webhook(
From: str = Form(...),
Body: str = Form(...),
):
user_id = From # e.g., "whatsapp:+919876543210"
user_message = Body
# Load history
history = conversations.get(user_id, [])
history.append({"role": "user", "content": user_message})
# Call OpenAI
completion = openai_client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{
"role": "system",
"content": "You are a customer support agent for Acme Corp. Respond in the user's language (Hindi/English/mixed). Keep replies concise β WhatsApp messages should be short."
},
*history
],
max_tokens=200
)
ai_response = completion.choices[0].message.content
# Save history (truncate to last 10 messages)
history.append({"role": "assistant", "content": ai_response})
conversations[user_id] = history[-10:]
# Return the Twilio response
resp = MessagingResponse()
resp.message(ai_response)
return str(resp)
Step 3 β Deploy (5 min)
Option A: Cloudflare Workers
wrangler deploy
Free tier: 100k requests/day β enough for most small businesses.
Option B: Render
# render.yaml
services:
- type: web
name: whatsapp-bot
env: python
buildCommand: pip install -r requirements.txt
startCommand: uvicorn main:app --host 0.0.0.0 --port $PORT
Note your public URL (e.g., https://mybot.onrender.com).
Step 4 β Connect Twilio To Your URL
Twilio Console β WhatsApp Sandbox β "When a message comes in" β paste your URL + /whatsapp β save.
Test: send "Hi" to the Twilio WhatsApp number β the AI replies in seconds.
Enhance With Tool Use
A simple chatbot is boring. Add real business actions:
TOOLS = [
{
"type": "function",
"function": {
"name": "check_order_status",
"description": "Check the status of an order by order ID",
"parameters": {
"type": "object",
"properties": {
"order_id": {"type": "string"}
},
"required": ["order_id"]
}
}
},
{
"type": "function",
"function": {
"name": "schedule_demo",
"description": "Schedule a demo call",
"parameters": {
"type": "object",
"properties": {
"name": {"type": "string"},
"phone": {"type": "string"},
"preferred_time": {"type": "string"}
},
"required": ["name", "phone"]
}
}
}
]
# In the completion call:
completion = openai_client.chat.completions.create(
model="gpt-4o-mini",
messages=[...],
tools=TOOLS,
tool_choice="auto"
)
# Handle tool calls (check_order_status DB lookup, etc.)
This turns your chatbot into something genuinely useful β checking orders, booking demos, capturing leads.
Multilingual Handling
Indian audiences may speak 10+ languages. A strong system prompt:
You are multilingual. Detect the user's language and respond in the same language:
- Hindi (Devanagari or romanized)
- Tamil, Telugu, Bengali, Marathi, Gujarati, Kannada, Malayalam, Punjabi
- English
Match their register. Use polite forms (formal 'aap' in Hindi, formal 'neenga' in Tamil).
For stronger regional fluency, swap OpenAI for Sarvam AI β better with Indian languages.
Cost Analysis (1000 messages/day)
- Twilio: Rs 1/conversation Γ 1000 = Rs 1,000/day
- OpenAI GPT-4o-mini: ~Rs 0.05/msg Γ 1000 = Rs 50/day
- Server: Rs 0 (CF Workers free) or Rs 500/mo (Render)
Monthly: ~Rs 30,500 for 30k conversations
Versus a human agent: Rs 15,000-25,000/month for one agent with 8-hour coverage.
AI: 24/7, 10x volume, same cost.
Common Pitfalls
- Rate limiting: Twilio's free tier is low β upgrade when you scale
- Long responses: WhatsApp truncates; keep under 1,000 chars
- Conversation drift: save only the last 10 messages; summarize older ones
- Sensitive info: credit cards, passwords β never expose to the LLM; redact before sending
- Fallback path: always offer "Talk to a human agent?"
Moving To Production
- Facebook Business verification (1-2 days)
- Twilio Sandbox β production number
- WhatsApp-approved message templates for proactive notifications
- Add analytics (message volume, conversion rate, satisfaction)
- Build an admin dashboard (log of messages, human-takeover button)
No-Code Alternative
If you don't want to code:
- Zapier + OpenAI + WhatsApp: a Zapier flow
WhatsApp message β OpenAI β reply. Rs 2,000-5,000/mo depending on volume. - Make.com (formerly Integromat): similar, slightly cheaper
Scale-Up Patterns
- Queue system: Redis + worker for async processing
- Conversation branching: quick replies, button flows (Twilio supports these)
- Persistent memory: save customer info to your CRM automatically
- Voice messages: WhatsApp audio β STT β LLM β TTS back
A WhatsApp chatbot is the single-highest-ROI AI investment for Indian businesses. 15 minutes of setup, 24/7 value.
More For Business
ChatGPT for GST Filing and Accounting β A Small Business Handbook
A practical guide to using ChatGPT for routine GST compliance. HSN lookups, invoice templates, and a monthly filing checklist β without needing a CA consultation for every question.
AI-Assisted Blogging For Indian Audiences β A Complete SEO Workflow
A complete workflow for SEO-driven content in Hindi / Hinglish for Indian audiences. Draft with AI, polish by hand, add structured data. Ranking tactics that actually work.