Chat actions
After creating the chat, Usedesk will send requests to the address specified when configuring the API channel at the "Redirect url” field.
To enable chat related requests, check the corresponding checkboxes (requests should arrive for those that were checked) at the widget's settings page (Channels → Chat channel → "Request Settings" section). It can be:
- A new chat: the request indicates the creation of a new chat, about the first message at it.
- All chat messages: the request indicates the creation of all subsequent messages in the chat.
- Chat resume: the request indicates that the chat was reopened by a new message if the chat was finished before.
All requests are based on the same request body with the "chat_id" reference parameter. If "chat_id" has already been created with one of the requests, then new messages and the resumption of chat work in the necessary chat, based on the reference parameter.
When an incoming/outgoing message is sent in a chat, the system sends a webhook that contains:
Parameter | Value |
---|---|
chat_id | chat id |
text | message text |
client_id | client id |
client | Client information. Contains parameters:
|
from | A message was written on behalf of:
Important: if a message is sent via a rule (bot), a new message webhook will not be sent. A webhook will be sent to update the request. |
platform | The type of channel from which the chat was created. Possible types: usedesk_tg — telegram |
secret | application id |
id | ticket's id |
status_id | ticket status id
|
subject | ticket subject |
client_id | client's id |
assignee_id | id executor (agent) |
group | id of the executor's group |
last_updated_at | date of the last ticket changes |
channel_id | channel's id |
client's e-mail address (from which he wrote) | |
published_at | date of ticket creation |
company_id | Company (account) id from where the webhook came from |
additional_id | additional ticket ID |
message | the text of the first request message |
custom_fields | List of fields and their values. Sent only when at least one of the additional fields.
|
custom_blocks | List of add. system blocks, which contains parameters:
|
state | if the chat status changes
If the chat status has not changed — "null" |
{ "chat_id": "1962066", "text": "hi", "client_id": "4476034", "from": "client", "platform": "", "secret": "***", "ticket": { "id":"10264808", "status_id":"8", "subject":"Cashew is a nut", "client_id":"4367802", "assignee_id":null, "group":null, "last_updated_at":"2018-05-11 14:17:12", "channel_id":"4242", "email":null, "published_at":"2018-05-11 14:17:12", "company_id":"155568", "additional_id":"", "message":"This is unbelievable." } }