All posts
Build a WhatsApp bot with TokenBazaar in 20 lines
Guides 10 min read· Jul 12, 2026· By Guides

Build a WhatsApp bot with TokenBazaar in 20 lines

Wire a business WhatsApp number to GPT-5 in under 15 minutes with Twilio + TokenBazaar.

You need three things: a Twilio WhatsApp sandbox, a TokenBazaar key, and a tiny webhook. The whole app fits on your laptop screen.

The webhook#

python
from fastapi import FastAPI, Form
from openai import OpenAI

app = FastAPI()
ai = OpenAI(api_key="sk-tb-...", base_url="https://tokenbazaar.in/api/public")

@app.post("/wa")
def wa(Body: str = Form(...)):
    r = ai.chat.completions.create(
        model="gpt-5.4-mini",
        messages=[{"role": "user", "content": Body}],
    )
    return {"reply": r.choices[0].message.content}

Point Twilio's inbound webhook at /wa. Every message from your customers now round-trips through GPT-5.4 Mini.

Adding memory#

Store the last N turns per WhatsApp number in a small Redis or SQLite. See multi-turn memory patterns.

WhatsApp chatbot screenshot
Cost: about $0.50 per 100 messages on Gemini 3 Flash, or $2.00 on GPT-5.4 Mini.

Models in this article

Review current prices, specifications and source-linked benchmarks.

Ready to build?

Grab a key, keep your OpenAI SDK, and pay only for what you use.

Start free