🚀 New: Anjok Connect WhatsApp Business App — Get Demo ₹500/mo

🔗 WhatsApp Cloud API Webhook Setup – Messages, Verification & PHP Example (2026) Complete Developer Guide | Anjok Technologies

 

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.

https://miro.medium.com/1%2AaKBSLjaPKeleMCsqZaARhw.jpeg

https://cdn.prod.website-files.com/66efa862351a8bef3b48cb70/680b4519b802738ef24cd424_AD_4nXeZz1UU_ixdTrhiD5tQh37QbB0fAdrVZV6MX-kK0vNNG9qE_x5SuOzt8_4lE5zWplSQZ6SPEHNaa1kV7hI0nhlBjIjnk3ew5PVU1itn30IpIYktTGPELv8w6_trf9aYLJCq8o398A.png

https://support.bolddesk.com/kb/attachment/article/15729/inline?token=eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjMzMTQwIiwib3JnaWQiOiIzIiwiaXNzIjoic3VwcG9ydC5ib2xkZGVzay5jb20ifQ.UlCaJi5Sbtbw4xMprhwbfcls6RhNZw_Y3evv8INlL48

💡 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.

https://support.bolddesk.com/kb/attachment/article/15729/inline?token=eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjMzMTQwIiwib3JnaWQiOiIzIiwiaXNzIjoic3VwcG9ydC5ib2xkZGVzay5jb20ifQ.UlCaJi5Sbtbw4xMprhwbfcls6RhNZw_Y3evv8INlL48

https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/1/6/168cafd6abb0e920d245720422bbfcd34c195aad.png

https://miro.medium.com/v2/resize%3Afit%3A1400/1%2AChCU1ajEP7Vtl3nzhmP5rg.png

✅ STEP 3: Add Webhook in Meta Dashboard

  1. Go to Meta Developers Dashboard
  2. Open your WhatsApp app
  3. Go to Webhooks
  4. Add:
    • Callback URL → your PHP file
    • Verify Token → same as PHP
  5. 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