A verification request provides security for your bot and data by providing a secret token upon configuration.
When you try to add a new webhook, a verification request is sent to your backend. You should answer this request by returning the required parameters and confirming that it comes from a trusted source and is configured properly.
A verification request is sent by ChatBot, which uses the GET request when you add a new webhook. It contains two parameters:
-
challenge — a unique string of characters associated with your request.
-
token — a verification token that you can set when you create a new webhook in ChatBot.
See our documentation for more information on webhooks and check the object definitions.
Adjust the provided code examples to match your needs.
See our documentation for more information on webhooks and check the object definitions.
Adjust the provided code examples to match your needs.
How to handle the verification request
To pass the verification process successfully, you should return the value of the challenge parameter and verify the token entered in ChatBot with the one set in your backend.
While configuring a new webhook, ChatBot sends a verification request to ensure that your webhook is up and running.
app.get('/', (req, res) => {
// check if verification token is correct
if (req.query.token !== 'your-token-here') {
res.writeHead(401);
return res.end();
}
// return challenge to ChatBot
return res.end(req.query.challenge);
});
Once the verification request is handled, you can add your webhook to ChatBot. If you want to learn more about setting up your first webhook, check out this article.
Read more: