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:

ParameterValue

chat_id

chat id
textmessage text
client_idclient id
client

Client information. Contains parameters:

  • id
  • name — name
  • avatar — avatar
  • note — note
  • emails — email address
  • phones — phone
  • additional_ids — additional ID
from

A message was written on behalf of:

  • user — agent
  • client — client

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

secretapplication id
idticket's id
status_id

ticket status id


List of possible statuses:
1 (open)
2 (completed)
3 (closed)
4 (deleted)
5 (on hold)
6 (pending)
7 (spam)
8 (new)
9 (mailing)

subject

ticket subject

client_idclient's id
assignee_idid executor (agent)
groupid of the executor's group
last_updated_atdate of the last ticket changes
channel_idchannel's id
emailclient's e-mail address (from which he wrote)
published_atdate of ticket creation
company_idCompany (account) id from where the webhook came from
additional_idadditional ticket ID
messagethe text of the first request message
custom_fields

List of fields and their values. Sent only when at least one of the additional fields.
Contains parameters:

  • id — additional fields id
  • name — name of additional field
  • value — value of the additional field
custom_blocks

List of add. system blocks, which contains parameters:

  • name — the name of the block
  • url — url of the block
  • secret_key — secret token of the block
state

if the chat status changes

  • new — new
  • reopened — reopened
  • closed — closed

If the chat status has not changed — "null"


Example of a response from server
{
    "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."
    }
}