How to Set Webhook Url to Receive Delivery Reports / Message Statues From Meta For Your WhatsApp API
Setting Up a Webhook URL
Go to your channel's webhook option and click "Add webhook."
Navigate to the webhook.site, click the edit icon.
Set the status code to
200
.Choose the Content Type as
"text/html"
.In the Content field, enter: $request.query.challange$
Save the changes.
Click "Add webhook."
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
PreviousHow to Send Messages Via API For your Official WhatsApp Number ( Postman ) ?NextHow To Create Qr Code For Your WhatsApp API Number ?
Last updated
Was this helpful?