Hints Webhook

This webhook is designed to train bots based on conversations between agents and clients. A bot can then send these hints to agents. Such hints contain possible options for responding to clients and can be quite useful and effective in agents’ work.

The bot sends messages if the thread is owned by a user with the Operator role (i.e., an agent).

You need to enable the setting to train the bot based on the client-agent conversations.

Script:

INSERT INTO settings (ID, key, value) VALUES (nextval('settings_id_seq'), 'bot.connect.training.chat.enabled', 'true');

You also need to add a webhook for the required bot in the admin WP.

Request Parameters

ParameterTypeDescription
actionboolean (required) TRAINING
textstring (required)Client or agent message for the bot training
clientIdstring (optional)External client ID (only for authorized clients). 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
receivedAtstring (required)Time when the message was received. The date is in the UTC pattern: yyyy-MM-dd’T’HH:mm:ss.SSS’Z’
attachmentsarray of object (optional)Fields:

url – File URL, a string up to 4,000 characters
name – File name, a string up to 1,000 characters
type – File MIME type, a string up to 256 characters
size – File size in bytes, an integer
messageIndexint(required)The index of the message within the thread
messageOwnerstring (required)Message creator (CLIENT/OPERATOR)
channelInfoobject (required)Information about the channel from which the message was received
idstringChannel ID
channelTypestringChannel type (WEB, MOBILE, EMAIL, VIBER, TELEGRAM, VIBERPA, FACEBOOK, VKONTAKTE, YANDEX, WHATSAPP, APPLE_BUSINESS_CHAT)
authorizedbooleantrue – authorized, false – unauthorized

HTTP Request

POST <url for webhook training> HTTP/1.1
Content-Type: application/json
{
   "operator":{
      "id":3,
      "name":"Maria",
      "role":"OPERATOR",
      "maxThreads":6,
      "freeSlots":0,
      "photoUrl":null
   },
   "messageIndex":7,
   "messageOwner":"CLIENT",
   "action":"TRAINING",
   "clientId":"1111",
   "threadsClientId":218,
   "sessionId":"249",
   "receivedAt":"2021-03-25T03:12:28.825Z",
   "text":"asdf",
   "channelInfo":{
      "id":1,
      "channelType":"WEB",
      "authorized":true
   },
   "attachments":[
   ],
   "clientData":{
      "locale":"ru"
   },
   "sender":"ThreadsAPI"
}

Example of a Successful HTTP Response

For the “async” responses, status 202 (Accepted) is expected; for “sync” responses, status 200 (OK) and a message are expected.

{
   "sessionId":"1",
   "messageIndex":"1",
   "hints":[
      {
         "text":"hint 1",
         "score":0.4
      },
      {
         "text":"hint 2",
         "score":0.6
      }
   ]
}
ParameterTypeDescription
sessionIdstring (optional)Internal thread ID
messageIndexinteger (required)The index of the message within the thread
messageOwnerstring (required)Message creator (CLIENT/OPERATOR)
hintsarray of object (optional)Bot hints for agents.

Fieldstext – The hint message
score – Hint’s scoring number