Skip to content

WhatsApp Integration

Overview

As we cannot reach WhatsApp Business API directly by ourselves we use WhatsApp API Partner gupshup.

We create an app in gupshup and connect it with a mobile phone number and then put a callback URL setting in this app (e.g. https://easyreport.mycompany.com/webhooks/whatsapp/webhook).

Then when the end-user writes to this number in WhatsApp, WhatsApp Partner knows how to process this message and redirects to our provided URL.

Such an example of integration with different services is called a Webhook.

gupshup-integration-with-Easy-Report-instance

API usage

After we get this request in Easy Report server, we process it and can send several requests to endpoints of gupshup API.

Send message

See here

POST https://api.gupshup.io/sm/api/v1/msg

Headers:

Attribute Type Required Description
Accept string yes application/json
Content-Type string yes x-www-form-urlencoded
apikey string yes Our account API key

Body:

Attribute Type Required Description
channel string yes whatsapp
source string yes Registered WhatsApp Business API phone number
destination string yes User's phone number
message json yes Different json objects depending on message type (quick_reply, text, image, list)
src.name string yes The Gupshup app name registered against the phone number provided in the API.

Response:

Send message API requests received by gupshup are processed asynchronously, and hence we will always get an HTTP_SUCCESS(200 to 299) response range if the API request made is correct.

Response body:

Attribute Type Description
status string The API call was successfully made and the request is submitted.
messageId string It is the unique identifier for a message. We can track message status via the DLR message events obtained on the webhook.
Mark inbound message as read

See here

PUT https://api.gupshup.io/wa/app/:app_id/msg/:msg_id/read

Headers:

Attribute Type Required Description
apikey string yes Our account API key

Parameters:

Attribute Type Required Description
app_id integer yes Unique identifier for an app
msg_id integer yes Inbound message Id

Body:

Empty

Response:

200 OK