Receiving Messages

This method helps your server to read a client’s response message in chat. For example, if a client receives an HSM message with chat buttons, when they click on one of them, the payload parameter is returned (the code button that was set when a template was created for the HSM message).

You can test receiving messages to a test phone number using the edna API for the WhatsApp channel without registering your channel first. To do this, go to the Testing tab on the Integration page.

Connection URL

Only the HTTPS protocol is supported, so the address must start with HTTPS, port 443.

In order for your server to be able to read response messages, you should specify your system’s API endpoint during registration, which will handle incoming POST requests from the edna API.

Request Example

An example of a received text message.

{
    "id": 101,
    "subject": "test_subject_WA",
    "subjectId": 234,
    "subscriber": {
        "id": 202,
        "identifier": "79000000000"
    },
    "userInfo": {
        "userName": "alex",
        "firstName": null,
        "lastName": null,
        "avatarUrl": null
    },
    "messageContent": {
        "type": "TEXT",
        "attachment": null,
        "location": null,
        "caption": null,
        "text": "Thank you for your help",
        "payload": null,
        "story": null,
        "items": null
    },
    "receivedAt": "2022-04-29T15:30:08Z"
}

An example of a received message that is a response to a message with an interactive menu.

{
    "id": 102,
    "subject": "test_subject_WA",
    "subjectId": 234,
    "subscriber": {
        "id": 202,
        "identifier": "79000000000"
    },
    "userInfo": {
        "userName": "alex",
        "firstName": null,
        "lastName": null,
        "avatarUrl": null
    },
    "messageContent": {
        "type": "LIST_PICKER",
        "attachment": null,
        "location": null,
        "caption": null,
        "text": null,
        "payload": null,
        "story": null,
        "items": [
            {
                "identifier": "01",
                "title": "item 1",
                "subtitle": null
            }
        ]
    },
    "receivedAt": "2022-04-29T15:27:40Z"
}

An example of an incoming message with the PRODUCT value in the messageContent.type parameter.

{
    "id": 803101,
    "subject": "test_subject_WA",
    "subjectId": 47610,
    "subscriber": {
        "id": 4633047,
        "identifier": "79997776655"
    },
    "userInfo": {
        "userName": "John Smith",
        "firstName": null,
        "lastName": null,
        "avatarUrl": null
    },
    "messageContent": {
        "type": "PRODUCT",
        "attachment": null,
        "location": null,
        "caption": null,
        "text": "Hello",
        "payload": null,
        "story": null,
        "items": null,
        "contact": null,
        "product": {
            "id": "321",
            "catalogId": "123"
        },
        "catalog": null,
        "order": null
    },
    "receivedAt": "2024-08-05T08: 24: 14Z",
    "replyOutMessageId": null,
    "replyOutMessageExternalRequestId": null,
    "replyInMessageId": null
} 

An example of an incoming message with the ORDER value in the messageContent.type parameter.

{
    "id": 804201,
    "subject": "test_subject_WA",
    "subjectId": 47610,
    "subscriber": {
        "id": 4633047,
        "identifier": "79997776655"
    },
    "userInfo": {
        "userName": "John Smith",
        "firstName": null,
        "lastName": null,
        "avatarUrl": null
    },
    "messageContent": {
        "type": "ORDER",
        "attachment": null,
        "location": null,
        "caption": null,
        "text": null,
        "payload": null,
        "story": null,
        "items": null,
        "contact": null,
        "product": null,
        "catalog": null,
        "order": {
            "catalogId": "1022121105031922",
            "products": [
                {
                    "id": "111222",
                    "quantity": 2,
                    "price": 5,
                    "currency": "USD"
                }
            ]
        }
    },
    "receivedAt": "2024-08-05T12:44:22Z",
    "replyOutMessageId": null,
    "replyOutMessageExternalRequestId": null,
    "replyInMessageId": null
} 

An example callback for an incoming message with the referral parameter. Allows you to get information about where the customer started a conversation in WhatsApp.

{
    "id": 115611,
    "subject": "test_WA",
    "subjectId": 195,
    "subscriber": {
        "id": 1111111,
        "identifier": "35000000000"
    },
    "userInfo": {
        "userName": "Anna",
        "firstName": null,
        "lastName": null,
        "avatarUrl": null
    },
    "messageContent": {
        "type": "TEXT",
        "attachment": null,
        "location": null,
        "referral": {
            "body": "This is a great product",
            "headline": "Our new product",
            "sourceId": "123",
            "sourceType": "ad",
            "sourceUrl": "https://www.fb.com"
        },
        "caption": null,
        "text": "text for test",
        "payload": null,
        "story": null,
        "items": null,
        "contact": null,
        "product": null,
        "catalog": null,
        "order": null
    },
    "receivedAt": "2024-01-11T11:20:00Z",
    "replyOutMessageId": null,
    "replyOutMessageExternalRequestId": null,
    "replyInMessageId": null
}

Request Parameters

ParameterData typeDescription
idlongThe request ID.
subjectstringThe subject.
subjectIdlongThe subject ID. To retrieve the ID, use the channel-profile method.
subscriberobject The sender information.
subscriber.idlongThe sender identifier.
subscriber.identifierstringThe sender phone number.
userInfoobjectThe sender information.
userInfo.userNamestringThe first name.
userInfo.firstNamestringThe last name.
userInfo.lastNamestringThe patronymic.
userInfo.avatarUrlstringThe avatar.
messageContentobjectThe message information.
messageContent.textstring
(optional)
The message text.
messageContent.typestringThe type of content in the message: text, button, image, document, audio, video, product, or order.
messageContent.captionstring
(optional)
The title.
messageContent.payloadstring
(optional)
The button code specified when creating an HSM template.
messageContent.itemsobject The array of parameters that are returned to the response to a message with an interactive menu. If the received message is not a response to a message with an interactive menu, then messageContent.items is null.
messageContent.items.titlestring (required)The title of the element of the original interactive menu.
messageContent.items.subtitlestring (optional)The subtitle of the element of the interactive menu.
messageContent.items.identifierinteger (required)The element ID for the entire message. This ID is returned to the client’s response message.
messageContent.locationobject (optional)The location address.
messageContent.attachmentobject (optional)Null or attachment data.
messageContent.attachment.urlstring
(optional)
The URL of the attached image/document/video.
messageContent.attachmentnamestring
(optional)
The name of the attached image/document/video.
messageContent.attachmentsizestring
(optional)
The attachment size.
messageContent.contactobject (optional)The contact card consisting of the following fields: first name, last name, phone number.
contact.firstNamestring
(optional)
The name in the contact card.
contact.lastNamestring
(optional)
The last name in the contact card.
contact.phoneNumberstring
(optional)
The phone number in the contact card.
receivedAtstringThe date and time when the message was received.
replyInMessageIdlongThe internal identifier of the user’s quoted message. The user quotes message sent to the company.
replyOutMessageIdlongThe internal identifier of the company’s quoted message. The user quotes a message received from the company.
replyOutMessageExternalRequestIdlongThe external identifier of the company’s quoted message that it specifies when sending an outgoing message via the API if the user quoted a message received from the company.
You can change the set of items that are returned as a result of the request. To do this, use the required items from the list.

Response Parameters

ParametersData typeDescription
messageContent.referralobjectThe information obtained from a hidden link or advertisement (Viber Bot, WhatsApp).
messageContent.referral.bodystringThe advertisement text associated with the message.
messageContent.referral.headlinestringThe advertisement header associated with the message.
messageContent.referral.sourceIdstringThe ID of the advertisement or Facebook post.
messageContent.referral.sourceTypestringThe advertisement source type. Possible values:
ad: advertisement;
post: post.
messageContent.referral.sourceUrlstringThe URL of the advertisement that the user viewed.