Setting a Webhook to receive message using WhatsApp API

Setting a Webhook to receive message using WhatsApp API

Introduction

Webhooks are one of a few ways web applications can communicate with each other. It allows you to send real-time data from one application to another whenever a given event occurs. 

Whenever a message comes from a client to a business number, the WhatsApp Business API client sees the event, collects the data, and immediately sends a notification (user-defined HTTP callbacks) to the webhook URL specified in the application settings.

Only HTTPS webhook URLs on port 443 are valid.

It is important that your webhook returns an HTTPS 200 OK response to any notifications. Otherwise, we consider that notification as failed and try again after a short delay.

Only use asynchronous handling of callbacks - acknowledge immediately after receiving the callback, then process.

Set Webhook URL

The webhook URL is a URL where the WhatsApp Business API sends the notifications to, triggered by specific events.

You can set the webhook using the next request:

  • URL:  https://waba.mindbehind.com/v1/settings/application
  • Method: PATCH
  • Headers:
    • Content-Type: should be "application/json" and it's required
    • MB-API-KEY: authorization key, and it's required
  • Body:

webhook-png-1

Get Webhook URL

If the webhook URL is already set up as described above, you can send a GET request to get the URL through the next request:

  • URL:  https://waba.mindbehind.com/v1/configs/webhook
  • Method: GET
  • Headers:
    • Content-Type: should be "application/json" and its required
    • MB-API-KEY: authorization key, and it's required

 

 

    • Related Articles

    • Use of WhatsApp sandbox API

      We provide a developer-friendly test environment, for anyone who wants to check out the usage of our WhatsApp API. The WhatsApp API allows for direct-like access to the WhatsApp Business API. Sandbox Base Path: https://waba-sandbox.mindbehind.com ...
    • WhatsApp Cloud API

      Currently, MindBehind has support for two types of WhatsApp accounts. On-Prem and Cloud API. Cloud API is a feature where Meta will be storing the WhatsApp account details and numbers, for user interested in using Cloud API number kindly register on ...
    • Integrating WhatsApp Business API with Dialogflow

      Personalized Dialogflow Assistant Dialogflow application is a Google framework that provides NLP / NLU (Natural Language Processing / Natural Language Understanding). Dialogflow enables you to create an Intelligent Assistant and manage what the ...
    • Sending messages through WhatsApp API

      Introduction Message API calls are sent to the /v1/messages endpoint regardless of message type, but the content of the JSON message body differs for each type of message (text, image, etc.). See the following documentation for information regarding ...
    • Authorizing requests to WhatsApp API

      Introduction Every request to the WhatsApp API needs to be authorized using an API Key authentication. Adding the MB-API-KEY in the header with your unique API Key as a value is enough to gain permission. Every API Key is connected with one phone ...