How to Build a Multilingual WhatsApp AI Support Bot for Indian E-Commerce
In the Indian e-commerce landscape, customer communication lives on WhatsApp. However, providing 24/7 support in regional languages (Hindi, Hinglish, Tamil, Marathi) often requires expensive human agent teams or rigid, rule-based chatbots that frustrate buyers.
In this tutorial, we will build an intelligent, multi-turn WhatsApp customer support agent that handles order inquiries, returns, and FAQs in multiple Indian languages using Python, Twilio, and Velona's unified AI gateway. At the end you will see exactly what each reply costs in rupees.
Prerequisites and Architecture
To build this assistant, you will need:
- A Velona Account with a funded wallet (starts at just ₹10 via UPI).
- A Twilio Sandbox account for WhatsApp messaging.
- Python 3.10+ installed locally or on a cloud server (FastAPI + Uvicorn).
pip install fastapi uvicorn twilio requests python-multipart
Step 1: Set Up Your Velona Gateway and Wallet
Before making API calls, complete your initial setup:
- Sign in to your Velona Wallet Dashboard and top up ₹10 or more using GPay, PhonePe, or RuPay.
- Navigate to API Key Management and create a new production key.
- Set a spending budget on the key so a bug or a spam burst can never drain your wallet.
New to API keys? Follow how to get your first AI API key on Velona first.
Step 2: Build the FastAPI Webhook Backend
When a customer messages your WhatsApp business number, Twilio sends an HTTP POST webhook to your server. We will catch this request, process the text with a fast, low-cost model via Velona, and return a response back to WhatsApp.
import os
import requests
from fastapi import FastAPI, Form, Response
from twilio.twiml.messaging_response import MessagingResponse
app = FastAPI()
VELONA_API_KEY = os.environ["VELONA_API_KEY"]
VELONA_ENDPOINT = "https://velona.in/gateway/v1/inference/run"
MODEL = "openai/gpt-4o-mini"
SYSTEM_PROMPT = """You are an empathetic, polite AI support assistant for 'IndiKart E-Commerce'.
Respond in the exact language used by the customer (English, Hindi, Hinglish, or Tamil).
Keep your answers under 3 sentences suitable for WhatsApp messaging."""
def ask_velona(turns):
res = requests.post(
VELONA_ENDPOINT,
headers={
"Authorization": f"Bearer {VELONA_API_KEY}",
"Content-Type": "application/json",
},
json={"model": MODEL, "turns": turns},
timeout=30,
)
res.raise_for_status()
# The native endpoint returns the reply text in data.output
return res.json()["data"]["output"]
@app.post("/whatsapp")
async def whatsapp_webhook(Body: str = Form(...), From: str = Form(...)):
turns = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": Body},
]
ai_response = ask_velona(turns)
twiml = MessagingResponse()
twiml.message(ai_response)
return Response(content=str(twiml), media_type="application/xml")
Run it with uvicorn main:app --port 8000, expose it with a tunnel such as ngrok, and paste the public URL plus /whatsapp into the Twilio sandbox webhook setting.
Prefer the OpenAI SDK? Velona also exposes an OpenAI-compatible endpoint at https://velona.in/v1, so OpenAI(base_url="https://velona.in/v1", api_key=...) works with the same model IDs. See using an AI API with Python.
Step 3: Select the Right Model for Cost and Language Quality
For customer support bots, response speed and cost per message matter more than deep reasoning. These models handle Hindi and Hinglish well and are cheap enough to answer every message:
| Model ID | ₹ per 1M input / output tokens | Good for |
|---|---|---|
deepseek/deepseek-v4-flash | ₹2.90 / ₹5.80 | Lowest cost, high volume FAQs |
openai/gpt-4o-mini | ₹15.54 / ₹62.17 | Reliable Hinglish, good default |
google/gemini-2.5-flash | ₹31.08 / ₹259.02 | Regional languages, reads product images |
anthropic/claude-haiku-4.5 | ₹103.61 / ₹518.05 | Most careful tone for complaints |
Prices are from the Velona pricing page at the time of writing and are billed in rupees. Test the same customer message across models side by side in the Model Evaluator before you pick one.
Step 4: Remember the Conversation
Stateless bots forget what the customer said a minute ago ("mera order kahan hai?" followed by "and the other one?"). The simplest fix is to keep the last few turns per phone number and send them with each request:
from collections import defaultdict
HISTORY = defaultdict(list) # phone number -> list of turns
MAX_TURNS = 6 # keep it short to keep cost low
@app.post("/whatsapp")
async def whatsapp_webhook(Body: str = Form(...), From: str = Form(...)):
history = HISTORY[From]
history.append({"role": "user", "content": Body})
turns = [{"role": "system", "content": SYSTEM_PROMPT}] + history[-MAX_TURNS:]
ai_response = ask_velona(turns)
history.append({"role": "assistant", "content": ai_response})
twiml = MessagingResponse()
twiml.message(ai_response)
return Response(content=str(twiml), media_type="application/xml")
In production, store this history in Redis or your database instead of a Python dict so it survives restarts.
Velona also offers Memory Sessions, which store context server-side. You create a session in the dashboard and pass its mem_... ID as "velona": {"memory_session": "mem_..."} on the native endpoint. They suit a single long-running assistant (an internal knowledge bot, for example) better than thousands of short customer threads, so for this bot the per-customer history above is the better fit.
Step 5: Testing and Debugging
When developing webhooks, you often need to format JSON payloads, inspect authorization tokens, or validate regex patterns. Velona's free developer tools handle that without consuming your wallet balance.
Want to try different system prompts live in your browser before deploying? Use the Free Public Chat Playground.
What This Bot Costs in Rupees
A typical WhatsApp exchange is about 300 input tokens (system prompt plus message) and 100 output tokens. With six turns of history it grows to about 1,200 input tokens. Here is what that costs per reply:
| Model | Single message | With history | Replies per ₹10 (with history) |
|---|---|---|---|
| DeepSeek V4 Flash | ₹0.0014 | ₹0.0041 | about 2,400 |
| GPT-4o Mini | ₹0.011 | ₹0.025 | about 400 |
| Gemini 2.5 Flash | ₹0.035 | ₹0.063 | about 150 |
| Claude Haiku 4.5 | ₹0.083 | ₹0.18 | about 55 |
So a store handling 1,000 support chats a month on GPT-4o Mini spends roughly ₹25 on AI. Every request shows its exact rupee cost on your usage page.
Conclusion
By connecting Twilio with Velona's INR-native AI gateway, you can deploy a multilingual WhatsApp customer support bot in under an hour, pay for it with UPI, and never deal with international card declines.
Ready to deploy your AI bot? Create a free Velona account, top up ₹10 and get your API key in a couple of minutes.