Where to Find the Webhook URL?
How to set up a webhook URL to receive real-time data from our API
Last updated
How to set up a webhook URL to receive real-time data from our API
Last updated
To set up a webhook URL, you'll need to configure a server endpoint that can handle incoming HTTP requests from our API. This allows your application to receive real-time data, such as message updates, directly from WhatsApp.
You can set up a webhook on any server that can handle HTTP requests
Check the Platformโs Documentation: Most hosting services, even small ones, offer a way to handle HTTP requests. You should look for documentation or tutorials on how to set up a web application or endpoint on your hosting platform.
Create the Webhook Script: As with any server, you need to create a script that can handle HTTP POST requests. This script will be responsible for processing and responding to incoming data from the webhook. We have written more about this in the articles here: Receive messages
Deploying the script: Once the script is ready, it needs to be uploaded to the hosting platform. Depending on the platform, this could be uploading via FTP, using a version control system such as Git, or other deployment tools provided by the hosting service.
Get a public URL: Once the script is running on the hosting platform, the platform should provide a public URL for the deployed endpoint. This URL is what you will use as the URL of the webhook.
Test the webhook: Before using the webhook in production, it is worth testing it to make sure that it works correctly and that the platform handles requests correctly. We've written about how to do this here:
You can use popular cloud platforms to get a webhook link. Below, we provide instructions for setting up a webhook on three popular platforms โ Firebase, AWS, and Heroku.
Firebase offers Cloud Functions functionality, allowing you to run your bot without worrying about server infrastructure. In our opinion, this is the most optimal option.
Create a project in Firebase Console;
Install Firebase CLI, following the instructions;
Initialize Firebase in your project directory with the command firebase init;
Deploy your bot using the command firebase deploy --only functions.
AWS Lambda offers the ability to run code in response to triggers from other AWS services, making it a good choice for a bot.
Register or log in to AWS Management Console;
Create a new Lambda function through the AWS console, selecting API Gateway as the trigger;
Upload your bot's code into the Lambda function;
Configure the API Gateway to interact with your bot and the outside world.
Heroku offers an easy-to-use platform for hosting applications, which can automatically deploy code from your Git repository.
Create an account on Heroku;
Install Heroku CLI and log in;
Create a new Heroku app through the console or using the command heroku create;
Link your Git repository to Heroku and perform deployment with the commands git push heroku master;
Set the webhook URL provided by Heroku
When developing a WhatsApp bot, you might want to test it locally before deploying it to a server.
The simplest way to do this is to use tools like Ngrok, which creates a secure tunnel to your localhost, allowing you to provide access to your local server from the internet.
For more information on how to configure and test Webhook locally, see the article: How to test Webhook locally?
Especially for this purpose, we offer you a special endpoint that allows you to simulate any callback on any event. Thus, you can check if your link is available for our API, as well as see the format of the callback itself.