Go to Channels → Webhook and click Add Webhook.- Open webhook.site in a new tab and click New to generate a test webhook.
- Click the Edit option and configure the response:
- Status Code = 200
- Content Type = text/html
- Content = $request.query.challange$
- Save the changes and copy the unique webhook URL.
- Go back to Channels → Webhook, paste the URL, and give your webhook a title.
- Select the required channel events (incoming messages, calls, outgoing messages, etc.).
- Click Add Webhook to save.
- Once confirmed, incoming webhook events will start appearing instantly.
- Make sure your server URL responds with the challenge query, otherwise verification will fail.
It is Important that your server URL responds with the Challange Query
PHP Code For Webhook Challenge Response #
Copy to clipboard
<?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 #
Copy to clipboard
app.get('/your_webhook_endpoint',(req, res) => {
try {
res.send(req.query['challange']);
} catch (error) {
res.send(error.message);
}
});