You can clone our sample callback app using Glitch to create a public callback URL on Glitch's servers that you can use to test Webhooks. The purpose of creating the Glitch project is that it writes webhook payloads to a log file that you can view in real-time as webhooks are triggered.
This guide is part of a multiple step process and you must have completed a number of these steps before you start configuring your sample app endpoint using Glitch. You must have completed the following:
Full instructions for getting started with WhatsApp Business Cloud API so you can send your first test message is located at Get Started With the WhatsApp Business Cloud API.
.env
file, update the value of the WEBHOOK_VERIFY_TOKEN
to a random string of your choosing. Then, you can optionally, copy the value of your temporary/permanent access token from WhatsApp > API Setup in your App Dashboard and paste that value for GRAPH_API_TOKEN
.
/webhook
at the end of the URL to get your complete callback URL. It will look something like https://<project-name>.glitch.me/webhook
.Now that your endpoint is ready, you need to return to your App Dashboard.
https://<project-name>.glitch.me/webhook
) for Callback URL and ("HAPPY") for Verify token.
To confirm that a Webhook notification was triggered, go back to Glitch and select LOGS and the output should look like the following image.
The complete Webhook notification payload should look like the following:{ "object": "whatsapp_business_account", "entry": [ { "id": "0", "changes": [ { "field": "messages", "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": "16505551111", "phone_number_id": "123456123" }, "contacts": [ { "profile": { "name": "test user name" }, "wa_id": "16315551181" } ], "messages": [ { "from": "16315551181", "id": "ABGGFlA5Fpa", "timestamp": "1504902988", "type": "text", "text": { "body": "this is a text message" } } ] } } ] } ] }
server.js
in the left navigation to for the Webhook endpoint implementation.
https://<project-name.glitch.me/webhook
.
Incoming webhook: {"messages":[{"from":"1234567890","id":"ABGGhSkIc2B_Ago-sDy5BNm-1gI5","text":{"body":"Hi"},"timestamp":"1529381066","type":"text"}]} Incoming webhook: {"statuses":[{"id":"gBGGhSkIc2B_AgkXDygfSDwgG5s","recipient_id":"1234567890","status":"sent","timestamp":"1529381072"}]} Incoming webhook: {"statuses":[{"id":"gBGGhSkIc2B_AgkXDygfSDwgG5s","recipient_id":"1234567890","status":"delivered","timestamp":"1529381072"}]} Incoming webhook: {"statuses":[{"id":"gBGGhSkIc2B_AgkXDygfSDwgG5s","recipient_id":"1234567890","status":"read","timestamp":"1529381076"}]}