Channel API

Besides the standard web channel, CTLive can be enhanced with additional channels using Rest API. The protocol implemented is the following. The following protocol is based on the protocol implemented by Infobip (https://dev-old.infobip.com/whatsapp-business-messaging/incoming-whatsapp-messages)

NewMessage

Used to notify for a new incoming message. It can be a text message or a multimedia message.

To send a new message call the following URL

POST https://<hostname>/imchannel/message

Text Message

There are two ways how incoming messages can be forwarded to the client's end-point. They can be delivered with or without contact name.

Example of incoming message without contact name:

{ "results": [ { "from": "385919998888", "to": "1234", "integrationType": "WHATSAPP", "receivedAt": "2019-07-19T11:21:27.861+0000", "messageId": "ABEGOFl3VCQoAhAqnlmSd2FKPOaraEaS0rPQ", "pairedMessageId": null, "message": { "type": "TEXT", "text": "Support hello" } } ] }

Example of the incoming message with the contact name:

{ "results": [ { "from": "385919998888", "to": "1234", "integrationType": "WHATSAPP", "receivedAt": "2019-07-19T11:23:26.998+0000", "messageId": "ABEGOFl3VCQoAhBalbc6rTQT6mgS29EmGZ7a", "pairedMessageId": null, "message": { "type": "TEXT", "text": "Support hello" }, "contact": { "name": "Frank" } } ] }

Notes:

Parameter names

Type

Description

Parameter names

Type

Description

from

string

From Identifier

to

string

To identifier

integrationType

string

channel name

receivedAt

string

Timestamp indicating when the message has been received by the platform

messageId

string

unique identifier for message. In case of network problem it’s possibile to resend the same message with the same messageID.

pairedMessageID

string

reference to another message for “quote” feature

message.type

string

TEXT for text messages

message.text

string

content of the text message

contact.name

string

name linked with the from identifier if available

Image message

An image message is identified bu type “IMAGE” and the payload is transferred through a URL called by CTLive when the message is received. Url is requested using GET only once, because after that, it’s stored for any use.

{ "results": [ { "from": "385919998888", "to": "1234", "integrationType": "WHATSAPP", "receivedAt": "2018-09-10T11:27:17.980+0000", "messageId": "ABEGOFkWA5EBAgo6B82cNiWIAMKC", "message": { "type": "IMAGE", "caption": "Image Caption", "url": "https://{base_url}/123455" } } ] }

Document message  

Document message is very similar to image message, except for the type “DOCUMENT”. The caption is intended to be used for the filename.

Outbound Message

Outbound messages are sent by CTLive to a configurable URL with Basic authentication with a specific payload for each message type. The scenarioKey it’s a specific id linked with the account to be used as source number.

Text message

Response format 

If successful, the response header HTTP status code will be 200 OK and the message will be sent. 

If you try to send the message without authorization, you will receive a 401 Unauthorized error. 

Image message

If you would like to send WhatsApp messages containing text and image, please check the example provided below.

Parameter

Type

Description

Parameter

Type

Description

text

string

Text of the message that will be sent.

imageUrl

string

URL of the image sent

Document message  

If you would like to send messages containing document file, please check the example provided below. 

Parameter

Type

Description

Parameter

Type

Description

text

string

Name of the file that will be sent.

fileUrl

string

URL of the file sent

Template text message  

If you would like to send a template text message, please check the example provided below. 

Template image message

If you would like to send a template image message, please check the example provided below. 

Template document message

If you would like to send a template document message, please check the example provided below. 

Delivery Message

CTLive can be informed about the delivery status of outbound messages posting the following URL https://<hostname>/imchannel/message

Seen Reports

CTLive can be informed about the seen status of outbound messages posting the following URL https://<hostname>/imchannel/message