WhatsApp Business API Integration in Mobile Application
WhatsApp Business API — not WhatsApp Business App on phone. Cloud API (hosted by Meta) or On-Premises for businesses with verified account wanting to send notifications, conduct conversations, automate communication via WhatsApp. All integration — server-side, mobile app acts as management interface.
WhatsApp Cloud API Architecture
Meta transitioned to Cloud API in 2022 — hosted solution without On-Premises instance. Message send:
POST https://graph.facebook.com/v19.0/{PHONE_NUMBER_ID}/messages
Authorization: Bearer {ACCESS_TOKEN}
Content-Type: application/json
{
"messaging_product": "whatsapp",
"to": "380991234567",
"type": "template",
"template": {
"name": "order_shipped",
"language": { "code": "ru" },
"components": [
{
"type": "body",
"parameters": [
{ "type": "text", "text": "Ivan" },
{ "type": "text", "text": "#98765" },
{ "type": "text", "text": "today 2:00 PM – 6:00 PM" }
]
}
]
}
}
Templates (template) — mandatory for initial outbound. Freeform text sendable only within 24 hours of last user message (customer service window). Each template must be Meta-approved — usually 1–3 workdays.
Template Categories and Restrictions
| Category | Examples | Marketing Limits |
|---|---|---|
UTILITY |
Order status, OTP, payment reminder | None |
AUTHENTICATION |
Verification code | Strict format |
MARKETING |
Promotions, offers | Explicit opt-in required |
Marketing templates require explicit opt-in — user must consent to marketing via WhatsApp. Send without opt-in violates Meta policy, account block risk.
Webhooks: Inbound Messages and Statuses
Webhooks configured in Meta Developer Console. Backend receives POST on endpoint:
// Incoming message from user
{
"entry": [{
"changes": [{
"value": {
"messages": [{
"from": "380991234567",
"type": "text",
"text": { "body": "When's delivery?" },
"timestamp": "1711440000"
}]
}
}]
}]
}
// Outbound message delivery status
{
"statuses": [{
"id": "wamid.XXXXX",
"status": "delivered",
"timestamp": "1711440060",
"recipient_id": "380991234567"
}]
}
Important: webhook endpoint must verify via Meta (GET with hub.challenge) and handle POST in < 5 seconds — otherwise Meta retries, eventually disables webhook.
Mobile Part: Dialog Interface
Mobile app here — operator or admin interface:
// iOS — load conversation history
struct WhatsAppConversation: Identifiable, Decodable {
let id: String
let contactPhone: String
let contactName: String?
let lastMessage: WhatsAppMessage
let unreadCount: Int
let windowExpiresAt: Date? // 24-hour window
}
// Display window status
var isWithinServiceWindow: Bool {
guard let expires = windowExpiresAt else { return false }
return Date() < expires
}
If isWithinServiceWindow == false — show warning, can't send arbitrary message, suggest template selection.
Business Account Verification
WhatsApp Business API requires verified Business Manager at Meta. Process: create Meta Business Manager → verify business (documents) → create WhatsApp Business Account → get phone. Can't use same number in WhatsApp Business App — API only.
Verification days to weeks. Blocking stage — develop parallel in test mode (sandbox with limited numbers).
Timeline
WhatsApp Cloud API integration, template creation and registration, webhook handler, mobile dialog UI with service window support — 8–12 workdays (not including Meta account verification time).







