Message Webhook

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.

ParameterTypeDescription
actionboolean (required)MESSAGE
textstring (required)Client messages for bot processing
clientIdstring (optional)External client ID (for authorized clients only). The parameter has been deprecated, use threadsClientId instead.
threadsClientIdlong (optional)Internal client ID (applicable for both authorized and non-authorized clients)
sessionIdstring (optional)Internal thread ID
questionIdnumber (optional)edna internal ID of the client’s message
questionIndexnumber (optional)Index of the client’s message in the thread
channelInfoobject (required)Information about the channel
channelTypestringChannel type (WEBMOBILEEMAILVIBER
TELEGRAMVIBERPAFACEBOOKVKONTAKTE,
YANDEXWHATSAPPAPPLE_BUSINESS_CHAT)
authorizedbooleantrue – authorized, false – unauthorized
platformstring (optional)Only for the MOBILE channel. Type: iOSAndroid
clientDatadictionary (optional)Client data (see the Customize clientData in Webhook Content article)
segmentationInfomap<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).
receivedAtstring (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’
attachmentsarray 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
senderstring (required)Information about the sender, always ThreadsAPI
settingsobject (optional)Additional settings for the message
settings.maskedboolean (optional)Parameter that is used to mask digits in the linked client message (true – masked, false – not masked)
metaDataobject (optional)Data that is sent to the bot when the voice message recognition functionality is enabled.
metaData.speechTextbooleanRecognized text of the voice message
metaData.scoreintegerRecognition quality (digit from 0 to 100)
metaData.resultStatusstringRecognition status. Possible values:

 processing
 success
 noInput
 maxSpeech
 noMatch
 error
payloadstring (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
    }
}