Receive notifications via Webhook Endpoint#
Beta version
The functionality is in beta. Features may change and may also work unstably.
The Webhook Endpoint technology allows you to receive incoming notifications directly on your server.
This means that the GREEN-API server will call the method published on the side of your server.
The advantages of this technology are the fastest possible receipt of incoming notifications and a high throughput, limited only by the rate at which the notifications are processed on the side of your server.
The disadvantage is the complexity of the implementation.
The GREEN-API server attempts to deliver notifications with an interval of 1 minute. That is why, in order to receive the notifications in time, your server has to be always available to process incoming notifications.
Incoming notifications are stored in the queue for 24 hours.
The webhook sending rate is about 50 notifications per second (20 ms per webhook).
Server setup#
To receive incoming notifications using the Webhook Endpoint technology, you have to do the following:
- publish an IP address on the Internet
- implement the logic of processing the incoming notifications at the specified IP address
- if your server requires it, set the Webhook URL Token
A public IP address#
To receive incoming notifications, a public IP address (endpoint) available from the Internet is required. This way the GREEN-API server will be able to call your server at the specified address and pass the incoming notification.
Our public IP addresses the notifications are sent from#
You can specify the following IP addresses the notifications come to you from in the security settings of your server:
89.169.144.17
158.160.195.0
158.160.47.204
Processing the incoming notifications#
After an incoming call to the IP address of your server, you have to process the received notification.
Instance setup#
Before receiving incoming notifications, you need to set up your instance. Instance settings can be performed in software using the SetSettings method, or online in the console interface.
Setup by the SetSettings method#
To set up receiving incoming notifications using the Webhook Endpoint technology, you have to specify the value of your IP address or of your domain name as the webhookUrl parameter, and, if necessary, the webhookUrlToken for access to your server.
For example:
https://84.211.100.201:3000/green-api/webhook/
It is also required to specify what types of notifications you need to receive. To enable incoming notifications by type, as well as to specify the webhookUrl and webhookUrlToken parameters, use the SetSettings method.
Example of the SetSettings method request body#
{
"webhookUrl": "https://84.211.100.201:3000/green-api/webhook/",
"webhookUrlToken": "dscnsdiuafkascndjhsalbcvatsvcbasn23rfregvfdg54tds",
"outgoingWebhook": "yes",
"outgoingMessageWebhook": "yes",
"outgoingAPIMessageWebhook": "yes",
"stateWebhook": "yes",
"incomingWebhook": "yes",
"incomingMessageStatusWebhook": "yes"
}
Setup in the console#
- Go to the console
- Select the instance whose settings you need to change
- Click the
Changebutton on the instance panel - Specify the value of the
webhookUrlparameterIf authorization on your webhook server is required, specify the
Webhook URL Token. - Turn on the switches for the required types of notifications
- Click the
Save changesbutton to apply the settings.
Receive incoming notifications#
After setting up the instance, you can start receiving notifications.
Debugging incoming notifications#
To debug incoming notifications you can use any free service, for example webhook.site.
The service issues a unique address (URL) that has to be set as the value of the webhookUrl parameter.
A detailed description of the incoming notifications format is given in the Incoming notifications format section.