Many developers struggle because:
- Webhook verification fails
- Messages don’t arrive
- App is unpublished
- Wrong PHP response
This guide explains everything step by step, with a working PHP example.


💡 What Is a WhatsApp Cloud API Webhook?
A Webhook is a URL on your server where WhatsApp (Meta) sends events like:
- Incoming messages
- Message delivered
- Message read
- Message failed
WhatsApp Cloud API is officially provided by Meta Platforms.
Without a webhook:
❌ You can send messages
❌ But you cannot receive messages
🧩 Events You Receive via Webhook
Once configured, your webhook receives:
- messages → Incoming user messages
- statuses → Sent / delivered / read
- errors → Delivery or policy errors
These events come as JSON payloads.
✅ Requirements Before Webhook Setup
Make sure you already have:
- WhatsApp Cloud API app created
- WhatsApp Business Account (WABA)
- Real phone number added
- App published (important!)
- HTTPS URL (SSL mandatory)
⚠️ Unpublished apps receive only test webhooks, not real messages.
🪜 Step-by-Step: WhatsApp Cloud API Webhook Setup
✅ STEP 1: Create Webhook URL (PHP File)
Create a file like:
https://yourdomain.com/whatsapp_webhook.php
This file will handle:
- Webhook verification
- Incoming messages
✅ STEP 2: Webhook Verification (Very Important)
When you add a webhook in Meta dashboard, Meta sends:
- hub.mode
- hub.verify_token
- hub.challenge
Your server must echo the challenge.
✅ PHP Webhook Verification Example
<?php $verify_token = "MY_VERIFY_TOKEN"; // same token you enter in Meta dashboard if ($_SERVER['REQUEST_METHOD'] === 'GET') { if ( isset($_GET['hub_mode']) && $_GET['hub_mode'] === 'subscribe' && $_GET['hub_verify_token'] === $verify_token ) { echo $_GET['hub_challenge']; exit; } }
✔ If this works → webhook gets verified successfully.


✅ STEP 3: Add Webhook in Meta Dashboard
- Go to Meta Developers Dashboard
- Open your WhatsApp app
- Go to Webhooks
- Add:
- Callback URL → your PHP file
- Verify Token → same as PHP
- Subscribe to WhatsApp events
✅ STEP 4: Receive WhatsApp Messages (POST Request)
Once verified, WhatsApp sends POST requests.
📩 PHP Example – Receive Incoming Messages
<?php $input = file_get_contents("php://input"); $data = json_decode($input, true); // Log raw webhook data file_put_contents("webhook_log.txt", $input . PHP_EOL, FILE_APPEND); if (isset($data['entry'][0]['changes'][0]['value']['messages'][0])) { $message = $data['entry'][0]['changes'][0]['value']['messages'][0]; $from = $message['from']; // user phone number $text = $message['text']['body'] ?? ''; // Example: simple auto reply trigger if (strtolower($text) === 'hi') { // trigger reply from your send-message API } } // Always return 200 OK http_response_code(200); echo "EVENT_RECEIVED";
✔ WhatsApp expects HTTP 200
✔ Otherwise, it will retry and may disable webhook
⚠️ Common Webhook Problems & Fixes
❌ Messages Not Coming?
- App not published
- Wrong webhook URL
- HTTPS missing
- PHP error / echo output
❌ Verification Failed?
- Verify token mismatch
- PHP not echoing challenge
- Extra spaces / output
❌ Only Test Events?
- App still in Development mode
👉 Publish the app
🔐 Security Best Practices
✔ Use HTTPS only
✔ Store tokens in .env
✔ Validate payload structure
✔ Don’t echo anything extra
✔ Log webhook data for debugging
🧠 Webhook + WhatsApp Automation Flow
Typical flow used by CRMs:
1️⃣ User sends message
2️⃣ Webhook receives message
3️⃣ Save message in DB
4️⃣ Show in CRM inbox
5️⃣ Trigger auto reply / bot
6️⃣ Send reply via API
This is how WhatsApp CRM systems are built.
🏢 How Anjok Technologies Helps
Anjok Technologies provides:
✔ WhatsApp Cloud API setup
✔ Webhook verification & debugging
✔ PHP / Laravel webhook code
✔ Message automation logic
✔ Error fixing (131042, token issues, etc.)
✔ White-label WhatsApp CRM integration
We don’t just explain — we implement and fix.
📞 Contact Anjok Technologies
📱 +91 80729 70517
🌐 anjoktechnologies.in
👉 Ask for WhatsApp Cloud API Webhook Setup Support