How to Set Webhook Url to Receive Delivery Reports / Message Statues From Meta For Your WhatsApp API

Setting Up a Webhook URL

  1. Go to your channel's webhook option and click "Add webhook."

  2. Navigate to the webhook.site, click the edit icon.

  3. Set the status code to 200.

  4. Choose the Content Type as "text/html".

  5. In the Content field, enter: $request.query.challange$

  6. Save the changes.

  7. Click "Add webhook."

  8. Once the webhook is confirmed, you'll start receiving incoming webhooks.

It is Important that your server url responds with the Challange Query

PHP Code For Webhook Challange Response

<?php
//Check if method is GET
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    //Check if query contains the challange parameter
    if (isset($_GET['challange'])) {
        //Get parameter value
        $challenge = $_GET['challange'];
        echo $challenge;
    } else {
        //No Parameter Found
        echo "no challange";
    }
}
?>

Node JS Code For Webhook Challange Response

app.get('/your_webhook_endpoint',(req, res) => {
  try {
    res.send(req.query['challange']);
  } catch (error) {
    res.send(error.message);
  }
});

Video Tutorial

Last updated

Powered By Automations