πŸ’ΌFor Businessbeginner

Build a WhatsApp AI Chatbot in 15 Minutes β€” For Small Businesses

Twilio + OpenAI/Sarvam for a multilingual chatbot β€” with a no-code option too

AutoKaam EditorialΒ·Β·9 min read
WhatsApp chat interface

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

  1. WhatsApp Business Account (verified with business docs)
  2. Twilio account with WhatsApp enabled
  3. OpenAI/Claude/Sarvam API key
  4. Server (Cloudflare Workers' free tier works, or Render/Railway)

Step 1 β€” Twilio Setup (5 min)

  1. Sign up at twilio.com/console
  2. Messaging β†’ Try WhatsApp β†’ scan the QR with your WhatsApp Business
  3. Note your Account SID + Auth Token
  4. 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

  1. Rate limiting: Twilio's free tier is low β€” upgrade when you scale
  2. Long responses: WhatsApp truncates; keep under 1,000 chars
  3. Conversation drift: save only the last 10 messages; summarize older ones
  4. Sensitive info: credit cards, passwords β€” never expose to the LLM; redact before sending
  5. Fallback path: always offer "Talk to a human agent?"

Moving To Production

  1. Facebook Business verification (1-2 days)
  2. Twilio Sandbox β†’ production number
  3. WhatsApp-approved message templates for proactive notifications
  4. Add analytics (message volume, conversion rate, satisfaction)
  5. 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.

#WhatsApp#Chatbot#Twilio#OpenAI#Business Automation