Create a WhatsApp Notification Subscription With Webhooks
System Webhooks are triggered when an event occurs on a WABA or a phone number. You can now subscribe to these webhooks to get notifications for changes to your WhatsApp Business Account settings. You receive a system webhook notification when:
- There is an update in the message template status.
- There is an update in the phone number status.
- There is an update on the account review status (e.g. - OBA Approved).
- There is an update to the account status (e.g. - WABA ban)
This code snippet shows how to receive these notifications using a webhook.
Example
Find the description for all variables used in each code snippet below:
| Key | Description |
|---|---|
VONAGE_API_KEY | Your Vonage API key (see it on your dashboard). |
VONAGE_API_SECRET | Your Vonage API secret (also available on your dashboard). |
CHANNEL_MANAGER_WHATSAPP_NOTIFICATION_WEBHOOK_URL_WEB | A custom webhook URL that is setup to accept POST requests. |
Prerequisites
If you do not have an application you can create one. Make sure you also configure your webhooks.
Run your code
Save this file to your machine and run it:
Try it out
When you run the code you will be subscribed to updates for changes to your WhatsApp business account, and you will begin to receive notifications at your custom webhook URL.