RTM API Reference
Introduction
Versioning
This document describes the Customer Chat Real-Time Messaging API v3.2. This is the legacy version. We encourage you to migrate to the latest stable version. Read more about versioning...
What is RTM API
Real-Time Messaging API (RTM API) is based on a websocket-like connection. Client can send a request message that results in getting a response message. It's also possible to get push messages.
When to use RTM API
If you're wondering which API to use - Customer Chat RTM API or Web API, keep on reading.
Real-Time Messaging API allows for building stateful integrations that require logging in and maintaining the connection. Since connection maintenance is required, the implementation might be more challenging than with Web API.
Customer Chat RTM API enables communication in real time. It supports pushes like sneak peek
, typing indicator
, and other. Web API doesn’t have equivalent webhooks, which means you won't be informed about certain events using Web API.
Also, the RTM API will be a better choice if you want to avoid time delays or presume significant traffic.
Not what you're looking for? Perhaps, you need to use Customer Chat Web API instead.
Access
The basics on authorization and server pinging in the Customer Chat RTM API.
Authorization
Customer authorization is handled with access tokens. Find out how to get an access token from Customer authorization flow. You need to authorize within 30 seconds from establishing the connection. Otherwise, the connection will be closed. Given that the connection is continuosly maintained, you only need to authorize once.
Server pinging
After successful authorization, the client needs to ping the server every 15 seconds. Otherwise, the connection will be closed after about 30 seconds of inactivity. Until authorization is completed, ping is a no-op.
Use one of these 2 ways of pinging the server:
- Protocol message with the ping action
For web applications and backend integrations (e.g. in Python, Go). Send the following request every 15 seconds:
{
"action": "ping",
"payload": {}
}
After pinging the server, the client will receive a response with the ping
action. Thanks to that, the client can make sure the connection is still alive.
- The control frame ping in the websocket protocol
For backend integrations; unavailable in web browsers. Read more about the control frame ping.
Data centers
LiveChat system operates in two data centers: dal
(USA) and fra
(Europe). The default data center is dal
.
For backend applications, you can specify the region in the request header. The mechanism is the same as in Customer Chat Web API reference. It doesn't work for frontend applications, though. Instead, frontend apps connect to a region different than the default one by specifying the region suffix in the URL.
fra
: wss://api-fra.livechatinc.com/v3.2/customer/rtm/ws
dal
: wss://api.livechatinc.com/v3.2/customer/rtm/ws
Events
One of the data structures are events. They are sent to a chat via the send_event
method.
Apart from events, there are also Properties, Users, and Other common data structures.
These are the available event types:
File
The File event informs about an uploaded file.
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
custom_id | no | string | |
type | yes | string | file |
properties | no | object | Properties |
url | yes | string | Has to point to the LiveChat CDN. It's recommended to use the URL returned by upload_file . |
Response
Field | Returned | Notes |
---|---|---|
id | always | |
custom_id | optionally | |
created_at | always | Date & time format with a resolution of microseconds, UTC string . |
type | always | |
author_id | always | |
properties | optionally | |
name | always | |
url | always | |
thumbnail_url , thumbnail2x_url | only for images | |
content_type | always | |
size , width , height | only for images |
{
"id": "0affb00a-82d6-4e07-ae61-56ba5c36f743",
"custom_id": "31-0C-1C-07-DB-16",
"created_at": "2017-10-12T15:19:21.010200Z",
"type": "file",
"author_id": "b7eff798-f8df-4364-8059-649c35c9ed0c",
"properties": {
"property_namespace": {
"property_name": "property_value"
}
},
"name": "image25.png",
"url": "https://example.com/image25.png",
"thumbnail_url": "https://example.com/thumbnail.png",
"thumbnail2x_url": "https://example.com/thumbnail2x.png",
"content_type": "image/png",
"size": 123444,
"width": 640,
"height": 480
}
Filled form
The Filled form event contains data from a form (prechat or postchat survey).
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
custom_id | no | string | |
type | yes | string | filled_form |
properties | no | object | Properties |
form_id | yes | string | |
fields | yes | array | The fields a form contains. See filled form fields for details. |
Response
Field | Returned | Notes |
---|---|---|
id | always | |
custom_id | optionally | |
created_at | always | Date & time format with a resolution of microseconds, UTC string . |
type | always | |
author_id | always | |
properties | optionally | |
form_id | always | |
fields | always | An array of filled form fields |
{
"id": "0affb00a-82d6-4e07-ae61-56ba5c36f743",
"custom_id": "31-0C-1C-07-DB-16",
"created_at": "2017-10-12T15:19:21.010200Z",
"type": "filled_form",
"author_id": "b7eff798-f8df-4364-8059-649c35c9ed0c",
"properties": {
"property_namespace": {
"property_name": "property_value"
}
},
"form_id": "1473433500211",
"fields": [
{
"type": "name",
"id": "154417206262603539",
"label": "Your name",
"answer": "Thomas Anderson"
},
{
"type": "email",
"id": "154417206262601584",
"label": "Your email",
"answer": "t.anderson@example.com"
},
{
"type": "radio",
"id": "154417206262602571",
"label": "Chat purpose",
"answer": {
"id": "0",
"label": "Support"
}
},
{
"type": "checkbox",
"id": "154417206262604640",
"label": "Company industry",
"answers": [
{
"id": "0",
"label": "automotive"
},
{
"id": "1",
"label": "it"
}
]
},
{
"type": "group_chooser",
"id": "154417206262605324",
"label": "Choose department",
"answer": {
"id": "2",
"group_id": 1,
"label": "Marketing"
}
}
]
}
Message
The Message event contains text message to other chat users.
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
custom_id | no | string | |
text | yes | string | Max. raw text size is 16 KB (one UTF-8 char like emoji 😁 can use up to 4 B); to send more, split text into several messages. |
type | yes | string | message |
properties | no | object | Properties |
postback | no | object | Indicates that the message event was generated in response to a rich message event. |
postback.id | yes | string | ID of the postback from the rich message event. |
postback.thread_id | yes | string | ID of the thread with the rich message event. |
postback.event_id | yes | string | ID of the rich message event. |
postback.type | no | string | Should be used together with postback.value (when one of them is present, the other is required). |
postback.value | no | string | Should be used together with postback.type (when one of them is present, the other is required). |
Response
Field | Returned | Notes |
---|---|---|
id | always | |
custom_id | optionally | |
created_at | always | Date & time format with a resolution of microseconds, UTC string . |
type | always | message |
author_id | always | |
text | always | |
postback | optionally | Appears in a message only when triggered by a rich message. |
postback.id | always | |
postback.thread_id | always | |
postback.event_id | always | |
postback.type | optionally | Appears only if postback.value is present. |
postback.value | optionally | Appears only if postback.type is present. |
properties | optionally | Properties |
{
"id": "0affb00a-82d6-4e07-ae61-56ba5c36f743",
"custom_id": "31-0C-1C-07-DB-16",
"created_at": "2017-10-12T15:19:21.010200Z",
"type": "message",
"author_id": "b7eff798-f8df-4364-8059-649c35c9ed0c",
"text": "hello there",
"postback": {
"id": "action_call",
"thread_id": "K600PKZON8",
"event_id": "75a90b82-e6a4-4ded-b3eb-cb531741ee0d",
"type": "phone",
"value": "790034890"
},
"properties": {
"property_namespace": {
"property_name": "property_value"
}
}
}
Rich message
Rich message event contains rich message data structure. Read more in a document dedicated to Rich messages.
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
custom_id | no | string | You can give your RM a custom ID. |
type | yes | string | Event type: rich_message |
properties | no | object | The properties data structure |
template_id | yes | string | Defines how every Rich Message will be presented. Values: cards , sticker , or quick_replies . |
elements | no | array | Can contain up to 10 element objects. |
elements.title | yes | string | Displays formatted text on RMs. |
elements.subtitle | yes | string | Displays formatted text on RMs. |
elements.image | yes | image | Displays images on RMs. Required param: url ; Optional params: name , content_type , size , width , height . |
elements.buttons | no | array | Displays buttons. Can contain up to 13 button objects. |
elements.buttons.text | yes | string | Text displayed on a button. |
elements.buttons.type | yes | string | Defines the behavior after a user clicks the button. Should be used together with elements.buttons.value . Possible values: webview , message , url , phone . More... |
elements.buttons.value | yes | string | Should be used together with elements.buttons.type . You can use this field to give the rich message of a webview type (a Moment) a custom title. More... |
elements.buttons.webview_height | yes | string | Required only for the webview buttontype . Possible values: compact , full , tall . |
elements.buttons.postback_id | yes | string | A description of the sent action. Describes the action sent via send_rich_message_postback . More... |
elements.buttons.user_ids | yes | array | Describes users that sent the postback with "toggled": true . |
Response
Field | Returned | Notes |
---|---|---|
id | always | Generated server-side |
custom_id | optionally | |
type | always | |
author_id | always | Generated server-side |
created_at | always | Date & time format with a resolution of microseconds, UTC string . Generated server-side. |
properties | optionally | |
template_id | always | |
elements | optionally | |
elements.title | always | |
elements.subtitle | always | |
elements.image | always | |
elements.buttons | optionally | |
elements.buttons.text | always | |
elements.buttons.type | always | |
elements.buttons.value | always | |
elements.buttons.webview_height | always | Unless button type is different than webview . |
elements.buttons.postback_id | always | |
elements.buttons.user_ids | always |
{
"id": "0affb00a-82d6-4e07-ae61-56ba5c36f743",
"custom_id": "31-0C-1C-07-DB-16",
"type": "rich_message",
"author_id": "b7eff798-f8df-4364-8059-649c35c9ed0c",
"created_at": "2017-10-12T15:19:21.010200Z",
"properties": {
"property_namespace": {
"property_name": "property_value"
}
},
"template_id": "cards",
"elements": [
{
"title": "Lorem ipsum dolor.",
"subtitle": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"image": {
"name": "image25.png",
"url": "https://example.com/image25.png",
"content_type": "image/png",
"size": 123444,
"width": 640,
"height": 480
},
"buttons": [
{
"text": "yes",
"postback_id": "action_yes",
"user_ids": [
"b7eff798-f8df-4364-8059-649c35c9ed0c"
]
},
{
"text": "no",
"postback_id": "action_no",
"user_ids": []
},
{
"type": "phone",
"text": "value",
"value": "790034890",
"webview_height": "tall",
"postback_id": "action_call",
"user_ids": []
}
]
}
]
}
Custom
Custom event is an event with customizable payload.
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
custom_id | no | string | You can give the event a custom ID. |
type | yes | string | Event type: custom |
content | no | object | The content you define |
properties | no | object | The properties data structure |
Response
Field | Returned | Notes |
---|---|---|
id | always | Generated server-side |
custom_id | optionally | |
type | always | |
author_id | always | Generated server-side |
created_at | always | Date & time format with a resolution of microseconds, UTC string ; generated server-side |
content | optionally | |
properties | optionally |
{
"id": "0affb00a-82d6-4e07-ae61-56ba5c36f743",
"custom_id": "31-0C-1C-07-DB-16",
"type": "custom",
"author_id": "b7eff798-f8df-4364-8059-649c35c9ed0c",
"created_at": "2017-10-12T15:19:21.010200Z",
"content": {
"custom": {
"nested": "json"
}
},
"properties": {
"property_namespace": {
"property_name": "property_value"
}
}
}
System message
System message event is a native system event sent in specific situations.
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
custom_id | no | string | You can give the system message a custom ID. |
type | yes | string | system_message |
text | no | string | Text displayed to recipients |
system_message_type | yes | string | System message type |
text_vars | no | object | Variables used in the text |
Response
Field | Returned | Notes |
---|---|---|
id | always | Generated server-side |
custom_id | optionally | |
type | always | |
created_at | always | Date & time format with a resolution of microseconds, UTC string ; generated server-side |
text | optionally | |
system_message_type | always |
{
"id": "0affb00a-82d6-4e07-ae61-56ba5c36f743",
"custom_id": "31-0C-1C-07-DB-16",
"created_at": "2017-10-12T15:19:21.010200Z",
"type": "system_message",
"text": "hello there",
"system_message_type": "routing.assigned",
"text_vars": {
"agent": "John Doe"
}
}
Users
Users are another important data structure. Within this data structure type, we can distinguish:
Customer
{
"id": "b7eff798-f8df-4364-8059-649c35c9ed0c",
"type": "customer",
"name": "Thomas Anderson",
"email": "t.anderson@example.com",
"avatar": "https://example.com/avatar.png",
"session_fields": [
{
"custom_key": "custom_value"
},
{
"another_custom_key": "another_custom_value"
}
],
"present": true,
"events_seen_up_to": "2017-10-12T15:19:21.010200Z"
}
Field | Req./Opt. | |
---|---|---|
avatar | optional | |
email | optional | |
name | optional | |
session_fields | optional | An array of custom object-enclosed key:value pairs. Available for the session duration. |
events_seen_up_to | optional | RFC 3339 datetime string; the timestamp of the most recent event seen by the Customer—all the previous events are considered seen. |
Agent
{
"id": "b5657aff34dd32e198160d54666df9d8",
"type": "agent",
"name": "Agent Smith",
"avatar": "cdn.livechatinc.com/avatars/1.png",
"present": true,
"events_seen_up_to": "2017-10-12T15:19:21.010200Z"
}
Other common structures
Apart from Events and Users, there are also other common data structures you might work with. Those are:
Access
{
"access": {
"group_ids": [
1,
2
]
}
}
Field | Req./Opt. | Note |
---|---|---|
group_ids | required | group 0 means that all agents can see it. |
Chats
{
"id": "PJ0MRSHTDG",
"threads": [
{
"id": "QA1B38GHGI",
"created_at": "2020-05-07T07:11:28.288340Z",
"active": false,
"user_ids": [
"bbb67d600796e9f277e360e842418833",
"b7eff798-f8df-4364-8059-649c35c9ed0c"
],
"events": [
{
"id": "QA1B38GHGI_1",
"created_at": "2020-05-14T07:22:40.269000Z",
"type": "message",
"properties": {
"source": {
"client_id": "0805e283233042b37f460ed8fbf22160"
}
},
"text": "hello",
"author_id": "bbb67d600796e9f277e360e842418833",
"custom_id": "1589440960204.71699349177"
},
{
"id": "QA1B38GHGI_3",
"created_at": "2020-05-14T08:18:44.015000Z",
"type": "system_message",
"text": "The chat was closed because Agent Smith had lost internet connection",
"system_message_type": "routing.archived_disconnected",
"text_vars": {
"agent": "Agent Smith"
}
}
],
"properites": {
"property_namespace": {
"property_name": "property_value"
}
},
"access": {
"group_ids": [
0
]
},
"previous_thread_id": "K600PKZOM8",
"next_thread_id": "K600PKZOO8"
}
],
"users": [
{
"id": "b7eff798-f8df-4364-8059-649c35c9ed0c",
"type": "customer",
"present": true
},
{
"id": "bbb67d600796e9f277e360e842418833",
"name": "Agent Smith",
"events_seen_up_to": "2020-05-14T07:22:37.287496Z",
"type": "agent",
"present": false,
"avatar": "https://cdn.livechatinc.com/cloud/?uri=https://livechat.s3.amazonaws.com/default/avatars/a7.png",
"job_title": "Support Agent"
}
],
"access": {
"group_ids": [
0
]
},
"properites": {
"property_namespace": {
"property_name": "property_value"
}
}
}
Field | Req./Opt. | |
---|---|---|
properties | optional | |
access | optional |
Chat summaries
Chat summary is similar to the Chat data structure. The difference is that Chat contains a thread
object, while Chat summary includes last_event_per_type
.
{
"id": "PJ0MRSHTDG",
"last_thread_id": "QA1B38GHGI",
"last_thread_created_at": "2020-05-08T08:22:21.128420Z",
"users": [
{
"id": "b7eff798-f8df-4364-8059-649c35c9ed0c",
"type": "customer",
"present": true
},
{
"id": "bbb67d600796e9f277e360e842418833",
"name": "Agent Smith",
"events_seen_up_to": "2020-05-14T07:22:37.287496Z",
"type": "agent",
"present": false,
"avatar": "https://cdn.livechatinc.com/cloud/?uri=https://livechat.s3.amazonaws.com/default/avatars/a7.png",
"job_title": "Support Agent"
}
],
"last_event_per_type": {
"message": {
"thread_id": "QA1B38GHGI",
"thread_order": 1,
"thread_created_at": "2020-05-14T07:22:30.779000Z",
"event": {
"id": "QA1B38GHGI_1",
"created_at": "2020-05-14T07:22:40.269000Z",
"type": "message",
"properties": {
"property_namespace": {
"property_name": "property_value"
}
},
"text": "Hello",
"author_id": "bbb67d600796e9f277e360e842418833",
"custom_id": "1589440960204.71699349177"
}
},
"system_message": {
"thread_id": "QA1B38GHGI",
"thread_order": 1,
"thread_created_at": "2020-05-14T07:22:30.779000Z",
"event": {
"id": "QA1B38GHGI_3",
"created_at": "2020-05-14T08:18:44.015000Z",
"type": "system_message",
"text": "The chat was closed because Agent Smith had lost internet connection",
"system_message_type": "routing.archived_disconnected",
"text_vars": {
"agent": "Agent Smith"
}
}
}
},
"properites": {
"property_namespace": {
"property_name": "property_value"
}
},
"access": {
"group_ids": [
0
]
},
"active": false
}
Filled form fields
A component of the Filled form event.
{
"fields": [
{
"type": "name",
"id": "154417206262603539",
"label": "Your name",
"answer": "Thomas Anderson"
},
{
"type": "email",
"id": "154417206262601584",
"label": "Your email",
"answer": "t.anderson@example.com"
},
{
"type": "radio",
"id": "154417206262602571",
"label": "Chat purpose",
"answer": {
"id": "0",
"label": "Support"
}
},
{
"type": "checkbox",
"id": "154417206262604640",
"label": "Company industry",
"answers": [
{
"id": "0",
"label": "automotive"
},
{
"id": "1",
"label": "it"
}
]
},
{
"type": "group_chooser",
"id": "154417206262605324",
"label": "Choose department",
"answer": {
"id": "2",
"group_id": 1,
"label": "Marketing"
}
}
]
}
Field | Required | Data type | Notes |
---|---|---|---|
fields | yes | array of objects | The fields a form contains. |
type | yes | string | Possible values: checkbox , email , name , question , textarea , group_chooser , radio , select |
id | yes | string | Field id, for all field types |
label | yes | string | Field label; for all field types |
answer | yes | any | For all field types |
answer.id | yes | string | An identifier of each option a Customer can choose. For all field types. |
answer.label | yes | string | Answer label; for all field types |
answer.group_id | yes | number | For group_chooser |
Properties
Properties are key-value storages. They can be set within a chat, a thread, or an event. You can read more about properties in the Configuration API document.
{
"properties": {
"0805e283233042b37f460ed8fbf22160": {
"string_property": "string value"
}
}
}
Threads
{
"id": "K600PKZON8",
"active": true,
"user_ids": [
"b7eff798-f8df-4364-8059-649c35c9ed0c"
],
"events": [
{
"id": "QA1B38GHGI_1",
"created_at": "2020-05-14T07:22:40.269000Z",
"type": "message",
"properties": {
"property_namespace": {
"property_name": "property_value"
}
},
"text": "hello",
"author_id": "b7eff798-f8df-4364-8059-649c35c9ed0c",
"custom_id": "1589440960204.71699349177"
}
],
"properties": {
"property_namespace": {
"property_name": "property_value"
}
},
"access": {
"group_ids": [
0
]
},
"queue": {
"position": 42,
"wait_time": 1337,
"queued_at": "2020-05-07T07:11:28.288340Z"
},
"previous_thread_id": "K600PKZOM8",
"next_thread_id": "K600PKZOO8",
"created_at": "2020-05-07T07:11:28.288340Z"
}
Field | Req./Opt. | Note |
---|---|---|
access | optional | |
active | required | Possible values: true (thread is still active) or false (thread no longer active). |
events | optional | |
properties | optional | |
queue | optional | Present only if the chat is in the queue. The wait time for an available agent is approximated in seconds. |
previous_thread_id | optional | Present only if there is a preceding thread. |
next_thread_id | optional | Present only if there is a following thread. |
created_at | required | Date & time format with a resolution of microseconds, UTC string . Generated server-side. |
Methods
The API endpoint |
---|
wss://api.livechatinc.com/v3.2/customer/rtm/ws |
When connecting to the Customer Chat RTM API, clients have to send over the required query string parameters.
Required parameter | Data type | Notes |
---|---|---|
license_id | integer | LiveChat account ID |
Available methods
GENERAL RTM API REQUEST FORMAT
{
"request_id": "<request_id>", // optional
"action": "<action>",
"payload": {
// optional
}
}
{
"request_id": "<request_id>", // optional
"action": "<action>",
"type": "response",
"success": true,
"payload": {
// optional
}
}
Chats
List Chats
It returns summaries of the chats a Customer participated in.
Specifics
Action | list_chats |
Web API equivalent | list_chats |
Push message | - |
Request
Parameter | Required | Type | Notes |
---|---|---|---|
limit | No | number | Default: 10, maximum: 25 |
sort_order | No | string | Possible values: asc , desc (default). Chat summaries are sorted by the creation date of its last thread. |
page_id | No | string |
Response
Field | Data type | Notes |
---|---|---|
total_chats | number | An estimated number. The real number of found chats can slightly differ. |
next_page_id | string | In relation to page_id specified in the request. Appears in the response only when there's the next page. |
previous_page_id | string | In relation to page_id specified in the request. Appears in the response only when there's the previous page. |
chats_summary | array | Array of Chat summary data structures. |
REQUEST
{
"action": "list_chats",
"payload": {}
}
{
"request_id": "<request_id>", // optional
"action": "list_chats",
"type": "response",
"success": true,
"payload": {
"next_page_id": "MTUxNzM5ODEzMTQ5Ng==",
"chats_summary": [{
"id": "PJ0MRSHTDG",
"last_thread_id": "K600PKZON8",
"last_thread_created_at": "2020-05-08T08:22:21.128420Z",
"last_event_per_type": {
"message": {
"thread_id": "K600PKZON9",
"thread_created_at": "2020-05-07T07:11:28.288340Z",
"event": {
"id": "Q298LUVPRH_1",
"created_at": "2019-12-09T12:01:18.909000Z",
"type": "message",
"text": "hello world",
"author_id": "b7eff798-f8df-4364-8059-649c35c9ed0c"
}
}
},
"users": [{
"id": "b7eff798-f8df-4364-8059-649c35c9ed0c",
"type": "customer",
"present": true
}, {
"id": "b5657aff34dd32e198160d54666df9d8",
"name": "Agent Smith",
"type": "agent",
"present": true,
"avatar": "https://example.com/avatar.png",
"job_title": "Support Agent"
}],
"access": {
"group_ids": [0]
},
"properties": {
// "Properties" object
},
"active": true
}],
"total_chats": 1
}
}
List Threads
It returns threads that the current Customer has access to in a given chat.
Specifics
Action | list_threads |
Web API equivalent | list_threads |
Push message | - |
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
chat_id | Yes | string | |
sort_order | No | string | Possible values: asc - oldest threads first and desc - newest threads first (default). |
limit | No | number | Default: 3, maximum: 100 |
page_id | No | string | |
min_events_count | No | number | Range: 1-100; Specifies the minimum number of events to be returned in the response. It's the total number of events, so they can come from more than one thread. You'll get as many latest threads as needed to meet the min_events_count condition. |
You cannot use both limit
and min_events_count
at the same time.
REQUEST
{
"action": "list_threads",
"payload": {
"chat_id": "PWJ8Y4THAV"
}
}
{
"request_id": "<request_id>",
"action": "get_chat",
"type": "response",
"success": true,
"payload": {
"threads": [{
"id": "K600PKZON8",
"created_at": "2019-12-17T07:57:41.512000Z",
"active": true,
"user_ids": [
"b7eff798-f8df-4364-8059-649c35c9ed0c",
"bbb67d600796e9f277e360e842418833"
],
"events": [{
"id": "Q20N9CKRX2_1",
"created_at": "2019-12-17T07:57:41.512000Z",
"recipients": "all",
"type": "message",
"text": "Hello",
"author_id": "bbb67d600796e9f277e360e842418833"
}],
"properties": {
// "Property" object
},
"access": {
"group_ids": [0]
},
"previous_thread_id": "K600PKZOM8", // optional
"next_thread_id": "K600PKZOO8" // optional
}],
"found_threads": 42,
"next_page_id": "MTUxNzM5ODEzMTQ5Ng==", // optional
"previous_page_id": "MTUxNzM5ODEzMTQ5Nw==" // optional
}
}
Get Chat
Specifics
Action | get_chat |
Web API equivalent | get_chat |
Push message | - |
Request
Parameter | Required | Data type | |
---|---|---|---|
chat_id | Yes | string | |
thread_id | No | string | Default: the latest thread (if exists) |
REQUEST
{
"action": "get_chat",
"payload": {
"chat_id": "PJ0MRSHTDG",
"thread_id": "K600PKZON8"
}
}
{
"request_id": "<request_id>",
"action": "get_chat",
"type": "response",
"success": true,
"payload": {
"id": "PJ0MRSHTDG",
"thread": {
"id": "K600PKZON8",
"created_at": "2020-05-07T07:11:28.288340Z",
"active": true,
"user_ids": [
"b7eff798-f8df-4364-8059-649c35c9ed0c",
"b5657aff34dd32e198160d54666df9d8"
],
"events": [{
"id": "Q20N9CKRX2_1",
"created_at": "2019-12-17T07:57:41.512000Z",
"type": "message",
"text": "Hello",
"author_id": "b5657aff34dd32e198160d54666df9d8"
}],
"properties": {
"0805e283233042b37f460ed8fbf22160": {
"string_property": "string_value"
}
},
"access": {
"group_ids": [0]
},
"previous_thread_id": "K600PKZOM8",
"next_thread_id": "K600PKZOO8"
},
"users": [{
"id": "b7eff798-f8df-4364-8059-649c35c9ed0c",
"type": "customer",
"present": true
}, {
"id": "b5657aff34dd32e198160d54666df9d8",
"name": "Agent Smith",
"type": "agent",
"present": true,
"avatar": "https://example.com/avatar.jpg",
"job_title": "Support Agent"
}],
"access": {
"group_ids": [0]
},
"properties": {
"0805e283233042b37f460ed8fbf22160": {
"string_property": "string_value"
}
}
}
}
Start Chat
Starts a chat.
Specifics
Action | start_chat |
Web API equivalent | start_chat |
Push message | incoming_chat |
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
chat | No | object | |
chat.properties | No | object | Initial chat properties |
chat.access | No | object | Chat access to set, default: all agents. |
chat.users | No | array | List of existing users. Only one user is allowed (type customer ). |
chat.thread | No | object | |
chat.thread.events | No | array | Initial chat events array |
chat.thread.properties | No | object | Initial thread properties |
continuous | No | bool | Starts chat as continuous (online group is not required); default: false . |
Response
Field | Data type | Notes |
---|---|---|
chat_id | string | |
thread_id | string | |
event_ids | []string | Returned only when the chat was started with initial events. Returns only the IDs of user-generated events; server-side generated events are not included in the array. |
REQUEST
{
"action": "start_chat",
"payload": {}
}
{
"request_id": "<request_id>", // optional
"action": "start_chat",
"type": "response",
"success": true,
"payload": {
"chat_id": "PJ0MRSHTDG",
"thread_id": "PGDGHT5G"
}
}
Activate Chat
Used to restart an archived chat.
Specifics
Action | activate_chat |
Web API equivalent | activate_chat |
Push message | incoming_chat |
Request
Parameter | Required | Type | Notes |
---|---|---|---|
chat | Yes | object | |
chat.id | Yes | string | The ID of the chat that will be activated. |
chat.access | No | object | Chat access to set, default: all agents. |
chat.properties | No | object | Initial chat properties |
chat.thread | No | object | |
chat.thread.events | No | array | Initial chat events array |
chat.thread.properties | No | object | Initial thread properties |
continuous | No | bool | Sets a chat to the continuous mode. When unset, leaves the mode unchanged. |
Response
Field | Data type | Notes |
---|---|---|
thread_id | string | |
event_ids | []string | Returned only when the chat was activated with initial events. Returns only the IDs of user-generated events; server-side generated events are not included in the array. |
REQUEST
{
"action": "activate_chat",
"payload": {
"chat": {
"id": "PWJ8Y4THAV"
}
}
}
{
"request_id": "<request_id>", // optional
"action": "activate_chat",
"type": "response",
"success": true,
"payload": {
"thread_id": "Z8AGR5OUW"
}
}
Deactivate Chat
Deactivates a chat by closing the currently open thread. Sending messages to this thread will no longer be possible.
Specifics
Action | deactivate_chat |
Web API equivalent | deactivate_chat |
Push message | incoming_event and chat_deactivated |
Request
Parameter | Required | Data type | |
---|---|---|---|
chat_id | Yes | string |
REQUEST
{
"action": "deactivate_chat",
"payload": {
"chat_id": "PJ0MRSHTDG"
}
}
{
"request_id": "<request_id>", // optional
"action": "deactivate_chat",
"type": "response",
"success": true,
"payload": {
// no response payload
}
}
Events
Send Event
Sends an Event object. Use this method to send a message by specifying the Message event type in the request.
The method updates the requester's events_seen_up_to
as if they've seen all chat events.
Specifics
Action | send_event |
Web API equivalent | send_event |
Push message | incoming_event |
Request
Parameters | Required | Data type | Notes |
---|---|---|---|
chat_id | Yes | string | Id of the chat you want to send the message to. |
event | Yes | object | The Event object |
attach_to_last_thread | No | bool | The flag is ignored for active chats. For inactive chats: true – the event will be added to the last thread; false – the request will fail. Default: false . |
REQUEST
{
"action": "send_event",
"payload": {
"chat_id": "PW94SJTGW6",
"event": {
"type": "message",
"text": "hello world",
"recipients": "all"
}
}
}
{
"request_id": "<request_id>", // optional
"action": "send_event",
"type": "response",
"success": true,
"payload": {
"event_id": "K600PKZON8"
}
}
Send Rich Message Postback
Specifics
Action | send_rich_message_postback |
Web API equivalent | send_rich_message_postback |
Push message | incoming_rich_message_postback * |
*) incoming_rich_message_postback
will be sent only for active threads.
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
chat_id | Yes | string | |
event_id | Yes | string | |
postback | Yes | object | |
postback.id | Yes | string | Postback name of the button |
postback.toggled | Yes | bool | Postback toggled, true or false |
thread_id | Yes | string |
REQUEST
{
"action": "send_rich_message_postback",
"payload": {
"chat_id": "PJ0MRSHTDG",
"thread_id": "K600PKZON8",
"event_id": "a0c22fdd-fb71-40b5-bfc6-a8a0bc3117f7",
"postback": {
"id": "Method URL_yes",
"toggled": true
}
}
}
{
"request_id": "<request_id>", // optional
"action": "send_rich_message_postback",
"type": "response",
"success": true,
"payload": {
//no response payload
}
}
Send Sneak Peek
Sends a sneak peek to a chat.
Specifics
Action | send_sneak_peek |
Web API equivalent | send_sneak_peek |
Push message | - |
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
chat_id | Yes | string | Id of the chat to send a sneak peek to. |
sneak_peek_text | Yes | string | Sneak peek text |
REQUEST
{
"action": "send_sneak_peek",
"payload": {
"chat_id": "PJ0MRSHTDG",
"sneak_peek_text": "hello world"
}
}
{
"request_id": "<request_id>", // optional
"action": "send_sneak_peek",
"type": "response",
"success": true,
"payload": {
// no response payload
}
}
Properties
Update Chat Properties
Specifics
Action | update_chat_properties |
Web API equivalent | update_chat_properties |
Push message | chat_properties_updated |
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
chat_id | Yes | string | Id of the chat you to set a property for. |
properties | Yes | object | Chat properties to set. You should stick to the general properties format and include namespace, property name and value. |
REQUEST
{
"action": "update_chat_properties",
"payload": {
"chat_id": "Q1GZ3FNAT9",
"properties": {
"0805e283233042b37f460ed8fbf22160": {
"string_property": "Chat property value updated by Customer"
}
}
}
}
{
"request_id": "<request_id>", // optional
"action": "update_chat_properties",
"type": "response",
"success": true,
"payload": {
// no response payload
}
}
Delete Chat Properties
Specifics
Action | delete_chat_properties |
Web API equivalent | delete_chat_properties |
Push message | chat_properties_deleted |
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
chat_id | Yes | string | Id of the chat you want to delete properties of. |
properties | Yes | object | Chat properties to delete. |
REQUEST
{
"action": "delete_chat_properties",
"payload": {
"chat_id": "Q1GZ3FNAT9",
"properties": {
"0805e283233042b37f460ed8fbf22160": [
"string_property"
]
}
}
}
{
"request_id": "<request_id>", // optional
"action": "delete_chat_properties",
"type": "response",
"success": true,
"payload": {
// no response payload
}
}
Update Thread Properties
Specifics
Action | update_thread_properties |
Web API equivalent | update_thread_properties |
Push message | thread_properties_updated |
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
chat_id | Yes | string | Id of the chat you want to set properties for. |
thread_id | Yes | string | Id of the thread you want to set properties for. |
properties | Yes | object | Chat properties to set. You should stick to the general properties format and include namespace, property name and value. |
REQUEST
{
"action": "update_thread_properties",
"payload": {
"chat_id": "Q1GZ3FNAT9",
"thread_id": "Q1GZ3FNAU9",
"properties": {
"0805e283233042b37f460ed8fbf22160": {
"string_property": "Thread property value updated by Customer"
}
}
}
}
{
"request_id": "<request_id>", // optional
"action": "update_thread_properties",
"type": "response",
"success": true,
"payload": {
// no response payload
}
}
Delete Thread Properties
Specifics
Action | delete_thread_properties |
Web API equivalent | delete_thread_properties |
Push message | thread_properties_deleted |
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
chat_id | Yes | string | Id of the chat you want to delete the properties of. |
thread_id | Yes | string | Id of the thread you want to delete the properties of. |
properties | Yes | object | Thread properties to delete. |
REQUEST
{
"action": "delete_thread_properties",
"payload": {
"chat_id": "Q1GZ3FNAT9",
"thread_id": "Q1GZ3FNAU9",
"properties": {
"0805e283233042b37f460ed8fbf22160": [
"string_property"
]
}
}
}
{
"request_id": "<request_id>", // optional
"action": "delete_thread_properties",
"type": "response",
"success": true,
"payload": {
// no response payload
}
}
Update Event Properties
Specifics
Action | update_event_properties |
Web API equivalent | update_event_properties |
Push message | event_properties_updated |
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
chat_id | Yes | string | Id of the chat you want to set properties for. |
thread_id | Yes | string | Id of the thread you want to set properties for. |
event_id | Yes | string | Id of the event you want to set properties for. |
properties | Yes | object | Chat properties to set. You should stick to the general properties format and include namespace, property name and value. |
REQUEST
{
"action": "update_event_properties",
"payload": {
"chat_id": "Q1GZ3FNAT9",
"thread_id": "Q1GZ3FNAU9",
"event_id": "Q1GZ3FNAU9_1",
"properties": {
"0805e283233042b37f460ed8fbf22160": {
"string_property": "Event property value updated by Customer"
}
}
}
}
{
"request_id": "<request_id>", // optional
"action": "update_event_properties",
"type": "response",
"success": true,
"payload": {
// no response payload
}
}
Delete Event Properties
Specifics
Action | delete_event_properties |
Web API equivalent | delete_event_properties |
Push message | event_properties_deleted |
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
chat_id | Yes | string | Id of the chat you want to delete the properties of. |
thread_id | Yes | string | Id of the thread you want to delete the properties of. |
event_id | Yes | string | Id of the event you want to delete the properties of. |
properties | Yes | object | Event properties to delete. |
REQUEST
{
"action": "delete_event_properties",
"payload": {
"chat_id": "Q1GZ3FNAT9",
"thread_id": "Q1GZ3FNAU9",
"event_id": "Q1GZ3FNAU9_1",
"properties": {
"0805e283233042b37f460ed8fbf22160": [
"string_property"
]
}
}
}
{
"request_id": "<request_id>", // optional
"action": "delete_event_properties",
"type": "response",
"success": true,
"payload": {
// no response payload
}
}
Customers
Update Customer
Specifics
Action | update_customer |
Web API equivalent | update_customer |
Push message | customer_updated |
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
name | No | string | |
email | No | string | |
avatar | No | string | URL of the Customer's avatar. |
session_fields | No | []object | An array of custom object-enclosed key:value pairs. Respects the order of items. |
At least one optional parameter needs to be included in the request payload.
REQUEST
{
"action": "update_customer",
"payload": {
"name": "Thomas Anderson",
"email": "t.anderson@example.com",
"avatar": "example.com/avatars/1.png",
"session_fields": [{
"custom_key": "custom_value"
}, {
"another_custom_key": "another_custom_value"
}]
}
}
{
"request_id": "<request_id>", // optional
"action": "update_customer",
"type": "response",
"success": true,
"payload": {
// no response payload
}
}
Update Customer Page
Specifics
Action | update_customer_page |
Web API equivalent | - |
Push message | customer_page_updated |
Agent and referrer are updated by default using the browser’s headers.
Request
Parameter | Required | Data type | |
---|---|---|---|
url | Yes | string | |
title | No | string |
REQUEST
{
"action": "update_customer_page",
"payload": {
"url": "https://livechatinc.com/pricing"
}
}
{
"request_id": "<request_id>", // optional
"action": "update_customer_page",
"type": "response",
"success": true,
"payload": {
// no response payload
}
}
Set Customer Session Fields
Specifics
Action | set_customer_session_fields |
Web API equivalent | set_customer_session_fields |
Push message | customer_updated |
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
session_fields | Yes | []object | An array of custom object-enclosed key:value pairs. Respects the order of items. Max keys: 100 |
Agent and referrer are updated by default using the browser’s headers.
REQUEST
{
"action": "set_customer_session_fields",
"payload": {
"session_fields": [{
"custom_key": "custom_value"
}, {
"another_custom_key": "another_custom_value"
}],
}
}
{
"request_id": "<request_id>", // optional
"action": "set_customer_session_fields",
"type": "response",
"success": true,
"payload": {
// no response payload
}
}
Get Customer
Returns the info about the Customer requesting it.
Specifics
Action | get_customer |
Web API equivalent | get_customer |
Push message | - |
Response
name | Customer's name. Returned only if set. |
email | Customer's email. Returned only if set. |
avatar | Customer's avatar. Returned only if set. |
session_fields | An array of custom object-enclosed key:value pairs. Returned only if set. Available for the session duration. |
REQUEST
{
"action": "get_customer",
"payload": {
"session_fields": [{
"custom_key": "custom_value"
}, {
"another_custom_key": "another_custom_value"
}],
}
}
{
"request_id": "<request_id>", // optional
"action": "get_customer",
"type": "response",
"success": true,
"payload": {
"id": "b7eff798-f8df-4364-8059-649c35c9ed0c",
"type": "customer",
"name": "Thomas Anderson", // optional
"email": "t.anderson@example.com", // optional
"avatar": "https://example.com/avatars/1.jpg", // optional
"session_fields": [{ // optional
"custom_key": "custom_value"
}, {
"another_custom_key": "another_custom_value"
}]
}
}
Status
Login
It returns the initial state of the current Customer.
Specifics
Action | login |
Web API equivalent | - |
Push message | - |
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
token | Yes | string | OAuth token from the Customer's account |
customer | No | object | |
customer.avatar | No | string | The URL of the Customer's avatar |
customer.email | No | string | |
customer.name | No | string | |
customer.session_fields | No | []object | An array of custom object-enclosed key:value pairs. Respects the order of items. |
customer_page.title | No | string | |
customer_page.url | No | string | |
customer_side_storage * | No | object | A map in the "key": "value" format |
is_mobile | No | bool | Informs if logging in is performed from a mobile device. |
group_id | No | number | |
referrer | No | string | |
application | No | object | Application info |
application.name | No | string | Application name |
application.version | No | string | Application version |
application.channel_type | No | string | Application channel type |
*) We use customer_side_storage
to keep some data on the client side. You should pass a map from the customer_side_storage_updated
push payload to this field.
REQUEST
{
"action": "login",
"payload": {
"token": "Bearer dal:test_1fgTbfXmgthj4cZSA"
}
}
{
"request_id": "<request_id>", // optional
"action": "login",
"type": "response",
"success": true,
"payload": {
"customer": {
"id": "a0c22fdd-fb71-40b5-bfc6-a8a0bc3117f5",
"name": "Thomas Anderson",
"email": "t.anderson@example.com",
"avatar": "https://example.com/avatar.png",
"session_fields": [{
"custom_key": "custom_value"
}, {
"another_custom_key": "another_custom_value"
}],
"statistics": {
"chats_count": 2,
"threads_count": 9,
"visits_count": 15,
"page_views_count": 40,
"greetings_shown_count": 20,
"greetings_accepted_count": 1
}
},
"has_active_thread": true,
"chats": [{
"chat_id": "PJ0MRSHTDG",
"has_unread_events": true
}],
"greeting": {
"accepted": true, // Customer has seen the greeting
"id": 342543723,
"unique_id": "e35a4fb4106d87e550fe1af480639058",
"addon": "email",
"event": {
// "Event > Message" object
// or
// "Event > Rich message" object
},
"agent": {
"id": "b5657aff34dd32e198160d54666df9d8",
"name": "Agent Smith",
"type": "agent",
"avatar": "https://example.com/avatar.png",
"job_title": "Support Agent",
"is_bot": false
},
"displayed_first_time": true
},
"__priv_dynamic_config": {
"online_groups_ids": [1, 3],
"customer_groups": {
"monitoring": {
"id": 1,
"static_config_url": "/licence/1520/get_static_config.121.1808829.94.95.39446.4011.2385.398.160.552.58.337.44320.js",
"language_config_url": "/licence/1520/v2/localization.en.121.004b8e014f50ea0c6ad6227162f7d18f_40d391a9adcdbf190e62fcd21c865bf2.js"
}
}
}
}
}
List Group Statuses
Specifics
Action | list_group_statuses |
Web API equivalent | list_group_statuses |
Push message | - |
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
all | No | bool | If set to true , you will get statuses of all the groups. |
group_ids | No | array | A table of a groups' IDs |
One of the optional parameters needs to be included in the request payload.
Response
Group Not Found | If you send group_id of a group that doesn't exists, the id won't be included in the resposne payload. |
REQUEST
{
"action": "list_group_statuses",
"payload": {
"all": true
}
}
{
"request_id": "<request_id>", // optional
"action": "list_group_statuses",
"type": "response",
"success": true,
"payload": {
"groups_status": {
//1,2,3 are group ids, online/offline/online_for_queue are statuses of the groups
1: "online",
2: "offline",
3: "online_for_queue"
}
}
}
Other
Get Form
Returns an empty ticket form of a prechat or postchat survey.
Specifics
Action | get_form |
Web API equivalent | get_form |
Push message | - |
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
group_id | Yes | number | Id of the group from which you want the form. |
type | Yes | string | Form type. Possible values: prechat or postchat . |
Response
Field | Notes |
---|---|
enabled | If enabled: false , the form object is not returned. Prechat/postchat survey disabled in the LiveChat Agent App UI. |
form | The form object |
REQUEST
{
"action": "get_form",
"payload": {
"group_id": 0,
"type": "prechat"
}
}
{
"form": {
"id": "157986144052005549",
"fields": [
{
"id": "157986144052003238",
"type": "header",
"label": "Welcome to our LiveChat! Please fill in the form below before starting the chat."
},
{
"id": "157986144052008371",
"type": "name",
"label": "Name:",
"required": false
},
{
"id": "157986144052005782",
"type": "email",
"label": "E-mail:",
"required": false
},
{
"id": "157986144052009331",
"type": "group_chooser",
"label": "Choose a department:",
"required": true,
"options": [
{
"id": "0",
"group_id": 1,
"label": "Marketing"
},
{
"id": "1",
"group_id": 2,
"label": "Sales"
},
{
"id": "2",
"group_id": 0,
"label": "General"
}
]
}
]
},
"enabled": true
}
Get Predicted Agent
Gets the predicted Agent - the one the Customer will chat with when the chat starts.
Specifics
Action | get_predicted_agent |
Web API equivalent | get_predicted_agent |
Push message | - |
REQUEST
{
"action": "get_predicted_agent",
"payload": {}
}
{
"request_id": "<request_id>", // optional
"action": "get_predicted_agent",
"type": "response",
"success": true,
"payload": {
"id": "b5657aff34dd32e198160d54666df9d8",
"name": "Agent Smith",
"avatar": "https://example.avatar/example.com",
"is_bot": false,
"job_title": "support hero",
"type": "agent"
}
}
Get URL Info
It returns the info on a given URL.
Specifics
Action | get_url_info |
Web API equivalent | get_url_info |
Push message | - |
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
url | Yes | string | Valid website URL |
Response
Field | Data type | Notes |
---|---|---|
image_url | string | URL of the minified image hosted on the LiveChat's CDN |
image_original_url | string | URL of the original image |
REQUEST
{
"action": "get_url_info",
"payload": {
"url": "https://livechatinc.com"
}
}
{
"request_id": "<request_id>", // optional
"action": "get_url_info",
"type": "response",
"success": true,
"payload": {
"title": "LiveChat | Live Chat Software and Help Desk Software",
"description": "LiveChat - premium live chat software and help desk software for business. Over 24 000 companies from 150 countries use LiveChat. Try now, chat for free!",
"image_url": "https://example.com/image.png",
"image_original_url": "https://example-original-url.com/image.png",
"image_width": 200,
"image_height": 200,
"url": "https://livechatinc.com"
}
}
Mark Events As Seen
Specifics
Action | mark_events_as_seen |
Web API equivalent | mark_events_as_seen |
Push message | events_marked_as_seen |
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
chat_id | Yes | string | |
seen_up_to | Yes | string | RFC 3339 date-time format |
Response
No response payload (200 OK
).
REQUEST
{
"action": "mark_events_as_seen",
"payload": {
"chat_id": "PJ0MRSHTDG",
"seen_up_to": "2017-10-12T15:19:21.010200Z"
}
}
Accept Greeting
Marks an incoming greeting as seen.
How it's implemented in LiveChat:
The Chat Widget uses this method to inform that a Customer has seen a greeting. Based on that, the Reports section displays the greetings that were actually seen by Customers, not all the sent greetings. If a Customer started a chat from a greeting, but the Accept Method wasn't executed, the greeting is still counted as seen in Reports.
Specifics
Action | accept_greeting |
Web API equivalent | accept_greeting |
Push message | greeting_accepted |
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
greeting_id | Yes | number | ID of the greeting configured within the license to accept. |
unique_id | Yes | string | ID of the greeting to accept. You can get it from the incoming_greeting push. |
REQUEST
{
"action": "accept_greeting",
"payload": {
"greeting_id": 7,
"unique_id": "Q10X0W041P"
}
}
{
"request_id": "<request_id>", // optional
"action": "accept_greeting",
"type": "response",
"payload": {
// no response payload
},
"success": true
}
Cancel Greeting
Cancels a greeting (an invitation to the chat). For example, Customers could cancel greetings by minimizing the chat widget with a greeting.
Specifics
Action | cancel_greeting |
Web API equivalent | cancel_greeting |
Push message | greeting_canceled |
Request
Parameter | Required | Data type | Notes |
---|---|---|---|
unique_id | Yes | string | ID of the greeting to cancel. You can get it from the incoming_greeting push. |
REQUEST
{
"action": "cancel_greeting",
"payload": {
"unique_id": "Q10X0W041P"
}
}
{
"request_id": "<request_id>", // optional
"action": "cancel_greeting",
"type": "response",
"payload": {
// no response payload
},
"success": true
}
Pushes
Here's what you need to know about pushes:
- They are generated primarily by RTM API actions, but also by Web API actions.
- They notify you when specific events occur.
- Can be delivered only in the websocket transport.
- You don't need to register pushes to receive them.
- Their equivalents in Web API are webhooks. Pushes and webhooks have similar payloads.
- There are no retries for pushes. To determine if a customer has seen an event, compare the event's
created_at
parameter with the customer'sevents_seen_up_to
field.
{
"request_id": "<request_id>", // optional, applies only to the requester
"action": "<action>",
"type": "push",
"payload": {
// optional payload
}
}
Chats
incoming_chat
Informs about a chat coming with a new thread. The push payload contains the whole chat data structure. If the chat was started with some initial events, the thread object contains them.
{
"requester_id": "b5657aff34dd32e198160d54666df9d8",
"chat": {
"id": "PJ0MRSHTDG",
"users": [
// array of "User" objects
],
"properties": {
// "Properties" object
},
"access": {
// "Access" object
},
"thread": {
// "Thread" object
},
"transferred_from": {
"group_ids": [ 1 ],
"agent_ids": [ "bbb67d600796e9f277e360e842418833" ]
}
}
}
Specifics
Action | incoming_chat |
Webhook equivalent | incoming_chat |
chat_deactivated
Informs that a chat was deactivated by closing the currently open thread.
{
"chat_id": "PJ0MRSHTDG",
"thread_id": "K600PKZON8",
"user_id": "b7eff798-f8df-4364-8059-649c35c9ed0c" // optional
}
Specifics
Action | chat_deactivated |
Webhook equivalent | chat_deactivated |
Push payload
Field | Notes |
---|---|
user_id | Missing if a thread was closed by the router. |
Chat access
chat_transferred
Informs that a chat was transferred to a different group or to an Agent.
{
"chat_id": "PJ0MRSHTDG",
"thread_id": "K600PKZON8",
"requester_id": "b5657aff34dd32e198160d54666df9d8",
"transferred_to": {
"group_ids": [ 1 ],
"agent_ids": ["b5657aff34dd32e198160d54666df9d8"],
},
"queue": {
"position": 42,
"wait_time": 1337,
"queued_at": "2019-12-09T12:01:18.909000Z"
}
}
Specifics
Action | chat_transferred |
Webhook equivalent | - |
Push payload
Field | Notes |
---|---|
thread_id | Present if the chat is active |
transferred_to | IDs of groups and Agents the chat has been assigned to |
queue | Present if the chat is queued after the transfer |
Chat users
user_added_to_chat
Informs that a user (Customer or Agent) was added to a chat.
This push can be emitted with user.present
set to false
when a user writes to a chat without joining it. You can achieve that via the Send Event method.
{
"chat_id": "PJ0MRSHTDG",
"thread_id": "K600PKZON8",
"user": {
// "User > Customer" or "User > Agent" object
},
"reason": "manual",
"requester_id": "b5657aff34dd32e198160d54666df9d8"
}
Specifics
Action | user_added_to_chat |
Webhook equivalent | user_added_to_chat |
Push payload
Field | Notes |
---|---|
thread_id | Present when a user was added to an active chat. |
reason | Why the user was added. |
requester_id | Present if the user was added by an agent. |
user_removed_from_chat
Informs that a user (Customer or Agent) was removed from a chat.
{
"chat_id": "PJ0MRSHTDG",
"thread_id": "K600PKZON8",
"user_id": "bbb67d600796e9f277e360e842418833",
"reason": "manual",
"requester_id": "b5657aff34dd32e198160d54666df9d8"
}
Specifics
Action | user_removed_from_chat |
Webhook equivalent | user_removed_from_chat |
Push payload
Field | Notes |
---|---|
thread_id | Present when a user was removed from an active chat. |
reason | Why the user was removed. |
requester_id | Present if the user was removed by an agent. |
Events
incoming_event
Informs about an incoming event sent to a chat.
{
"chat_id": "PJ0MRSHTDG",
"thread_id": "K600PKZON8",
"event": {
"id": "Q20163UAHO_2",
"created_at": "2019-12-05T07:27:08.820000Z",
"recipients": "all",
"type": "message",
"properties": {
"0805e283233042b37f460ed8fbf22160": {
"string_property": "string value"
}
},
"text": "Hello",
"author_id": "b5657aff-34dd-32e1-98160d54666df9d8"
}
}
Specifics
Action | incoming_event |
Webhook equivalent | incoming_event |
event_updated
Informs that an event was updated.
{
"chat_id": "123-123-123-123",
"thread_id": "E2WDHA8A",
"event": {
// "Event" object
}
}
Specifics
Action | event_updated |
Webhook equivalent | event_updated |
incoming_rich_message_postback
Informs about an incoming rich message postback. The push payload contains the info on the postback itself, as well as the chat it was sent in.
{
"user_id": "b7eff798-f8df-4364-8059-649c35c9ed0c",
"chat_id": "PJ0MRSHTDG",
"thread_id": "K600PKZON8",
"event_id": "a0c22fdd-fb71-40b5-bfc6-a8a0bc3117f7",
"postback": {
"id": "action_yes",
"toggled": true
}
}
Specifics
Action | incoming_rich_message_postback |
Webhook equivalent | incoming_rich_message_postback |
Properties
chat_properties_updated
Informs about those chat properties that were updated.
{
"chat_id": "Q1GZ3FNAT9",
"properties": {
"0805e283233042b37f460ed8fbf22160": {
"string_property": "Chat property value updated by Customer"
},
// ...
}
}
Specifics
Action | chat_properties_updated |
Webhook equivalent | chat_properties_updated |
Push payload
Field | Notes |
---|---|
properties | Not a full properties object. This push shows only the properties that have been recently updated. |
chat_properties_deleted
Informs about those chat properties that were deleted.
{
"chat_id": "Q1GZ3FNAT9",
"properties": {
"0805e283233042b37f460ed8fbf22160": ["string_property"]
},
// ...
}
Specifics
Action | chat_properties_deleted |
Webhook equivalent | chat_properties_deleted |
Push payload
Field | Notes |
---|---|
properties | Not a full properties object. This push shows only the properties that have been recently updated. |
thread_properties_updated
Informs about those thread properties that were updated.
{
"chat_id": "Q1GZ3FNAT9",
"thread_id": "Q1GZ3FNAU9",
"properties": {
"0805e283233042b37f460ed8fbf22160": {
"string_property": "Thread property value updated by Customer"
},
// ...
}
}
Specifics
Action | thread_properties_updated |
Webhook equivalent | thread_properties_updated |
Push payload
Field | Notes |
---|---|
properties | This is not a full properties object. This push shows only the properties the have been recently updated. |
thread_properties_deleted
Informs about those thread properties that were deleted.
{
"chat_id": "Q1GZ3FNAT9",
"thread_id": "Q1GZ3FNAU9",
"properties": {
"0805e283233042b37f460ed8fbf22160": ["string_property"]
},
// ...
}
Specifics
Action | thread_properties_deleted |
Webhook equivalent | thread_properties_deleted |
Push payload
Field | Notes |
---|---|
properties | Not a full properties object. This push shows only the properties that have been recently updated. |
event_properties_updated
Informs about those event properties that were updated.
{
"chat_id": "Q1GZ3FNAT9",
"thread_id": "Q1GZ3FNAU9",
"event_id": "Q1GZ3FNAU9_1",
"properties": {
"0805e283233042b37f460ed8fbf22160": {
"string_property": "Event property value updated by Customer"
}
}
}
Specifics
Action | event_properties_updated |
Webhook equivalent | event_properties_updated |
Push payload
Field | Notes |
---|---|
properties | Not a full properties object. This push shows only the properties that have been recently updated. |
event_properties_deleted
Informs about those event properties that were deleted.
{
"chat_id": "Q1GZ3FNAT9",
"thread_id": "Q1GZ3FNAU9",
"event_id": "Q1GZ3FNAU9_1",
"properties": {
"0805e283233042b37f460ed8fbf22160": ["string_property"]
},
// ...
}
Specifics
Action | event_properties_deleted |
Webhook equivalent | event_properties_deleted |
Push payload
Field | Notes |
---|---|
properties | This is not a full properties object. This push shows only the properties that have been recently updated. |
Customers
customer_updated
Informs that Customer's data was updated.
{
"customer": {
// "User > Customer" object
}
}
Specifics
Action | customer_updated |
Webhook equivalent | - |
customer_page_updated
Informs that a Customer changed the website - moved to another page of the website, for example by clicking on a link.
{
"url": "https://livechatinc.com/pricing",
"title": "pricing",
"timestamp": 123456789
}
Specifics
Action | customer_page_updated |
Webhook equivalent | - |
customer_side_storage_updated
Informs that a Customer updated the data stored on their side.
{
"customer_side_storage": {
"customer_visits": "1"
}
}
Specifics
Action | customer_side_storage_updated |
Webhook equivalent | - |
Push payload
Field | Notes |
---|---|
customer_side_storage | A map in the key : value format. Map content should be kept on the client side (e.g. in browsers local storages) and sent via login . |
Status
customer_disconnected
Informs that a Customer was disconnected. The payload contains the reason of Customer's disconnection.
{
"reason": "misdirected_connection",
"data": {
// optional
"region": "fra"
}
}
Specifics
Action | customer_disconnected |
Webhook equivalent | - |
Push payload
Field | Notes |
---|---|
reason |
Possible reasons
Type | Notes |
---|---|
access_token_expired | Access token lifetime has elapsed. |
connection_timeout | Has not received ping from the client for some time, or it's been too long since the connection was authorized. |
customer_banned | Customer has been banned. |
customer_temporarily_blocked * | Customer tried reconnecting too many times after the too_many_connections error had occurred. |
inactivity_timeout | Customer didn't chat or change the page in the past 30 minutes. |
internal_error | Internal, unexpected error; reconnecting is advised |
license_not_found | The license with the specified ID doesn't exist. |
license_expired | The license has expired. |
misdirected_connection ** | Customer connected to a server in the wrong region. |
product_version_changed | The product version has changed. |
service_temporarily_unavailable | The Customer Chat API should be available again soon; reconnecting is advised |
too_many_connections | Customer has reached the maximum number of connections. |
too_many_unauthorized_connections | The maximum number of unauthorized connections has been reached. |
unsupported_version | Connecting to an unsupported version of the Customer Chat API. |
*)
The customer_temporarily_blocked
reason can also return the correct timeout in an optional data object. With this piece of information, client is able to figure out how much time a customer should wait before attempting to reconnect again.
**)
The misdirected_connection
reason can also return the correct region in an optional data object. With this piece of information, client is able to figure out where it should be connected.
Other
incoming_typing_indicator
Informs that one of the chat users is currently typing a message. The message hasn't been sent yet. The push payload contains the typing indicator object.
{
"chat_id": "PJ0MRSHTDG",
"thread_id": "K600PKZON8",
"typing_indicator": {
"author_id": "d17cd570-11a9-45c0-45c0-1b020b7586dc",
"recipients": "all",
"timestamp": 1574245378,
"is_typing": true
}
}
Specifics
Action | incoming_typing_indicator |
Webhook equivalent | - |
incoming_multicast
Informs about messages sent via the multicast
method or by the system.
{
"author_id": "b7eff798-f8df-4364-8059-649c35c9ed0c",
"content": {
"example": {
"nested": "json"
}
}
}
Specifics
Action | incoming_multicast |
Webhook equivalent | - |
Push payload
Field | Required | Notes |
---|---|---|
author_id | No | Present only if the push was generated by the Multicast method and not sent from the server. |
content | Yes |
events_marked_as_seen
Informs that a user has seen events up to a specific time.
{
"user_id": "b7eff798-f8df-4364-8059-649c35c9ed0c",
"chat_id": "PJ0MRSHTDG",
"seen_up_to": "2017-10-12T15:19:21.010200Z"
}
Specifics
Action | events_marked_as_seen |
Webhook equivalent | events_marked_as_seen |
incoming_greeting
Informs about an incoming greeting.
{
"action": "incoming_greeting",
"type": "push",
"payload": {
"id": 7,
"unique_id": "Q10O0N5B5D",
"displayed_first_time": true,
"addon": "email",
"event": {
// "Event > Message" object
// or
// "Event > Rich message" object
},
"agent": {
"name": "Agent Smith",
"id": "b5657aff34dd32e198160d54666df9d8",
"avatar": "https://example.com/image25.png",
"job_title": "Support Agent",
"is_bot": false
}
}
}
Specifics
Action | incoming_greeting |
Webhook equivalent | - |
Push payload
Field | Notes |
---|---|
id | ID of the greeting configured within the license. |
unique_id | ID of the greeting that was generated, sent, and cancelled. |
event | Greeting event (Message or Rich message) |
displayed_first_time | true if the greeting was generated for the first time. |
agent | Info about the Agent who sent the greeting. |
addon | Additional greeting property |
greeting_accepted
Informs about a greeting accepted by the Customer.
{
"action": "greeting_accepted",
"type": "push",
"payload": {
"unique_id": "Q40R0832IN"
}
}
Specifics
Action | greeting_accepted |
Webhook equivalent | - |
Push payload
Field | Notes |
---|---|
unique_id | ID of the greeting that was generated, sent, and accepted. |
greeting_canceled
Informs about a greeting rejected by the Customer. Also, the push is sent when a new greeting automatically cancels the currently displayed one.
{
"action": "greeting_canceled",
"type": "push",
"payload": {
"unique_id": "Q10O0N5B5D"
}
}
Specifics
Action | greeting_canceled |
Webhook equivalent | - |
Push payload
Field | Notes |
---|---|
unique_id | ID of the greeting that was generated, sent, and rejected. |
queue_position_updated
Informs about an updated position in the queue and about the wait time.
{
"action": "queue_position_updated",
"type": "push",
"payload": {
"chat_id": "PJ0MRSHTDG",
"thread_id": "K600PKZON8",
"queue": {
"position": 42,
"wait_time": 1337
}
}
}
Specifics
Action | queue_position_updated |
Webhook equivalent | - |
Errors
{
"error": {
"type": "misdirected_request",
"message": "Wrong region",
"data": {
// optional
"region": "dal"
}
}
}
Possible errors
Error type | Default message | Description |
---|---|---|
authentication | Authentication error | An invalid or expired access token. |
authorization | Authorization error | User is not allowed to perform the action. |
chat_inactive | No active chat thread | An action that requires an active thread performed on a chat with no active threads. |
customer_banned | Customer is banned | The customer had been banned. |
greeting_not_found | Greeting not found | |
group_not_found | Group not found | |
group_offline | Group is offline | Thrown in response to Get Predicted Agent. |
group_unavailable | No agent available for group | Thrown in response to Get Predicted Agent. The group is online, but there are no available Agents. |
groups_offline | Groups offline | |
internal | Internal server error | |
license_expired | License expired | The end of license trial or subcription. |
limit_reached | Resource limit reached | Resource cannot be created/modified because the change would exceed the limit |
not_allowed | Not allowed | The action is not allowed. |
not_found | Not found | The requested resource wasn't found. |
pending_requests_limit_reached | Requests limit reached | The limit of pending requests within one websocket connection has been reached. The limit is 10. |
request_timeout | Request timed out | Timeout threshold is 15 seconds. |
service_unavailable | Not accepting new requests | New requests are temporarily not being accepted. |
too_many_requests | Too many requests | The request's rate limit was exceeded. It'll be unblocked automatically after some time. |
unsupported_version | Unsupported version | Unsupported protocol version. |
users_limit_reached | Users limit reached | Displayed on the attempt of logging in. The limit of online Customers for a given license has been reached. |
validation | Wrong format of request | |
wrong_product_version | Wrong product version | License is not LiveChat 3 (probably still LiveChat 2). |
Contact us
If you found a bug or a typo, you can let us know directly on GitHub. In case of any questions or feedback, don't hesitate to contact us at developers@livechat.com. We'll be happy to hear from you!