Startup India · DPIITNVIDIA Inception
WabotOpen app

Build a WhatsApp bot in Python

Use the Wabot API, free for 7 days, to send WhatsApp messages from Python and reply to incoming ones with a small Flask app. The bot runs on your own number, with no Business API approval.

How the bot works

  1. 1A customer messages your number
  2. 2Wabot posts it to your webhook
  3. 3Your Python code picks a reply
  4. 4Wabot sends it from your number

Send a WhatsApp message with Python

Install requests (pip install requests), copy your API key from the Wabot dashboard and call /send.

import requests

API_KEY = "YOUR_KEY"        # Wabot dashboard > API
MY_NUMBER = "919812345678"  # the number you linked

def send(to, text):
    r = requests.post(
        "https://api.wabot.online/send",
        headers={"X-API-Key": API_KEY},
        json={"number": MY_NUMBER, "to": to, "message": text, "isGroup": "N"},
        timeout=30,
    )
    r.raise_for_status()

send("919876543210", "Hello from Python!")

Start a 7-day free trial and send your first message from Python in minutes.

Start free trial

Receive and reply with a Flask webhook

Set your webhook URL and token in Wabot. Each incoming message arrives as JSON with the sender, chat, message text, type and the sender’s name; the token comes in the Authorization header. Delivery and read receipts arrive at the same URL with type "receipt".

Webhook fieldWhat it holds
phoneYour linked number
chatThe chat it came from: [email protected] or a group ID
senderWho sent it
messageThe text
typetext, image, audio, document, reaction, receipt and more
nameThe sender’s WhatsApp name
isGrouptrue for group messages
from flask import Flask, request, abort

app = Flask(__name__)
TOKEN = "YOUR_WEBHOOK_TOKEN"  # the token you saved with your webhook URL

@app.post("/whatsapp")
def incoming():
    if request.headers.get("Authorization") != TOKEN:
        abort(401)
    m = request.get_json()
    if m.get("type") != "text" or m.get("isGroup"):
        return "", 204  # receipts, media and groups: ignore
    number = m["chat"].split("@")[0]
    text = m["message"].strip().lower()
    if text in ("hi", "hello"):
        send(number, f"Hi {m['name']}! Reply 1 for prices or 2 to talk to us.")
    elif text == "1":
        send(number, "Try it free for 7 days: https://wabot.online")
    return "", 204

Get your API key free for 7 days

Link your number, copy your key and send your first message from Python. 7-day free trial, no card.

7-day free trial · No card · Your own WhatsApp number

Frequently asked questions

Is the WhatsApp API free for Python bots?

You can build and test it free for 7 days: the trial includes the API and up to 1,000 messages a day per number. After that, every paid plan includes the API with no per-message fees.

Do I need the WhatsApp Business API?

No. Wabot links your existing number as a device, so there is no Meta approval or template review.

Can I use pywhatkit or Selenium instead?

You can, but they drive WhatsApp Web in a browser on your computer, which has to stay open. An API keeps working from a server.

How do I stop the bot replying to itself or to receipts?

Ignore events where type is "receipt", and messages where sender is your own linked number (the phone field). Reply only to messages from other people and the bot won’t loop.

Where should I host the Flask app?

Anywhere with a public HTTPS URL: a small VPS, Render, Railway or a serverless function. For local testing, expose your laptop with a tunnel such as ngrok and use that URL as the webhook.

More from Wabot