For a synchronous response, the status 200
(OK) must be set, and the response body is required; for an asynchronous response, the status 202
(Accepted) must be set.
If there are several messages from the client at the time of the webhook call, {edna} can send them as separate messages or as one message with the combined text of all messages. This behavior is determined by the bot.message.concat
setting. By default, messages are sent as separate messages.
Parameter | Type | Description |
action | boolean (required) | MESSAGE |
text | string (required) | Client messages for bot processing |
clientId | string (optional) | External client ID (for authorized clients only). The parameter has been deprecated, use threadsClientId instead. |
threadsClientId | long (optional) | Internal client ID (applicable for both authorized and non-authorized clients) |
sessionId | string (optional) | Internal thread ID |
questionId | number (optional) | edna internal ID of the client’s message |
questionIndex | number (optional) | Index of the client’s message in the thread |
channelInfo | object (required) | Information about the channel |
channelType | string | Channel type (WEB , MOBILE , EMAIL , VIBER , TELEGRAM , VIBERPA , FACEBOOK , VKONTAKTE ,YANDEX , WHATSAPP , APPLE_BUSINESS_CHAT ) |
authorized | boolean | true – authorized, false – unauthorized |
platform | string (optional) | Only for the MOBILE channel. Type: iOSAndroid |
clientData | dictionary (optional) | Client data (see the Customize clientData in Webhook Content article) |
segmentationInfo | map<String, String> | Additional parameters for changing segmentation (used within both custom and out-of-the-box segments). The segmentation parameter personal_manager is available out-of-the-box. If the agent’s login was passed in this parameter and the route for the segment with this parameter is configured in the system, the client’s threads are distributed via the corresponding route to personal managers (agents). |
receivedAt | string (required) | Time when the message was received. Thу date is in the UTC pattern as follows: yyyy-MM-dd’T’HH:mm:ss.SSS’Z’ |
attachments | array of object (optional) | Attachment details: • url – File URL, string up to 4,000 characters• name – File name, string up to 1,000 characters• type – File MIME type, string up to 256 characters• size – File size in bytes, integer |
sender | string (required) | Information about the sender, always ThreadsAPI |
settings | object (optional) | Additional settings for the message |
settings.masked | boolean (optional) | Parameter that is used to mask digits in the linked client message (true – masked, false – not masked) |
metaData | object (optional) | Data that is sent to the bot when the voice message recognition functionality is enabled. |
metaData.speechText | boolean | Recognized text of the voice message |
metaData.score | integer | Recognition quality (digit from 0 to 100) |
metaData.resultStatus | string | Recognition status. Possible values: • processing • success • noInput • maxSpeech • noMatch • error |
payload | string (optional) | The code of the button that the client clicked/tapped. |
HTTP Request
POST <url for webhook message> HTTP/1.1 Content-Type: application/json { "action":"MESSAGE", "threadsClientId":1, "sessionId":"1", "questionId":43, "questionIndex":null, "receivedAt":"2018-11-13T13:13:11.876Z", "text":"Message", "channelInfo":{ "channelType":"MOBILE", "authorized":true }, "platform":"Android", "attachments":[ { "url":"hhtp://...", "name":"test.jpg", "type":"image/jpeg", "size":256 } ], "clientData":{ "phone":"79000000000" }, "sender":"ThreadsAPI" }
Example of a Successful HTTP Response
For an “async” response, status 202(Accepted) is expected; for a “sync” response, status 200(OK) and a message are expected.
{ "action":"MESSAGE", "threadsClientId":1, "sessionId":"1", "questionId":43, "questionIndex":null, "receivedAt":"2018-11-13T13:13:11.756Z", "text":"Message", "segmentationInfo": { "key":"value" }, "attachments":[ { "url":"https://...", "name":"test.jpg", "type":"image/jpeg", "size":256 } ], "sender":"ThreadsAPI", "settings" : { "masked" : true } }