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
Parameter | Type | Description |
action | boolean (required) | • TRAINING |
text | string (required) | Client or agent message for the bot training |
clientId | string (optional) | External client ID (only for authorized clients). 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 |
receivedAt | string (required) | Time when the message was received. The date is in the UTC pattern: yyyy-MM-dd’T’HH:mm:ss.SSS’Z’ |
attachments | array 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 |
messageIndex | int(required) | The index of the message within the thread |
messageOwner | string (required) | Message creator (CLIENT /OPERATOR ) |
channelInfo | object (required) | Information about the channel from which the message was received |
id | string | Channel ID |
channelType | string | Channel type (WEB , MOBILE , EMAIL , VIBER , TELEGRAM , VIBERPA , FACEBOOK , VKONTAKTE , YANDEX , WHATSAPP , APPLE_BUSINESS_CHAT ) |
authorized | boolean | true – 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 } ] }
Parameter | Type | Description |
sessionId | string (optional) | Internal thread ID |
messageIndex | integer (required) | The index of the message within the thread |
messageOwner | string (required) | Message creator (CLIENT /OPERATOR ) |
hints | array of object (optional) | Bot hints for agents. • Fieldstext – The hint message• score – Hint’s scoring number |