Proactive Chat
With Proactive chats, agents can send a message to your customer first. You can utilize proactive chats to send marketing or announcement messages to a specific customer. When a customer replies to an agent's message, the proactive chat automatically changes to a general ticket and is assigned to an available agent within a ticket's team based on auto ticket routing.
Resource Representation
Here's what a Proactive Chat resource looks like:
| Property name | Type | Description |
|---|---|---|
id | int | The unique ID of the proactive chat. |
project | int | The unique ID of a Desk project where the chat belongs. |
message | string | The content of the message. |
attachments | array of objects | Indicates an array of descriptors for the files attached to the initial message. This property is omitted when there is no attachment. |
attachments[].url | string | Indicates the file's download URL. This URL may not be publicly accessible. See |
attachments[].fileName | string | Indicates the file name. |
attachments[].fileType | string | Indicates the file's MIME type. |
attachments[].fileSize | integer | Indicates the file size in bytes. |
attachments[].requireAuth | boolean | Indicates whether downloading the file requires authentication. |
attachments[].thumbnails | array | Contains the file's thumbnails. |
messageCount | int | The count of messages within the chat. |
createdBy | object | Information about the agent who created the chat. |
assignedGroup | object | Information about the group where the chat is assigned. |
sentCount | int | The number of chats sent out. |
respondedCount | int | The number of chats that received responses. |
closedCount | int | The number of chats that have been closed/resolved. |
customersList | string | A string representation of customer IDs included in the chat. |
createdAt | string | The date time when the proactive chat was created, in ISO 8601 format. |
updatedAt | string | The last time the proactive chat was updated, in ISO 8601 format. |
priority | string | The priority of the proactive chat. Valid values are LOW, MEDIUM, HIGH, URGENT. |
Actions
-
Endpoints are relative to the base URL allocated to your application. In this document, the
/proactive_chatsendpoint is prefixed byhttps://desk-api-{application_id}.sendbird.com/platform/v1. -
It is recommended to urlencode parameter values in API URLs, such as
{proactive_id}.
List of Actions
| Action | HTTP request |
|---|---|
| |
| |
| |
|
Create Proactive Chat
Initiates a new Proactive Chat with customers. The initial message can include up to five files and a caption. A request with files can go to only one customer. A request without files can include up to ten customers.
Proactive chat must be enabled for your application. Every request, with or without files, must specify valid customers, an active agent, and an active group. To attach files, your Sendbird application must also have access to the Bot Interface.
HTTP Request
Note: If you are using Delight AI agent with Delight Desk, the endpoint for your API request should start with
https://desk-api-{application_id}.svc.delight.ai/platform/v1instead ofhttps://desk-api-{application_id}.sendbird.com/platform/v1. For more details, refer to our Delight AI agent guide.
Request Body
Authenticate with the SENDBIRDDESKAPITOKEN header. For a request without a file, use application/json. To attach files, use multipart/form-data and send each file's binary in a file field. Repeat the file field for each file. Pre-uploaded URLs and JSON file references aren't supported.
Include the following properties in your request body:
Properties
| Required | Type | Description |
|---|---|---|
message | string | Specifies the message content. With files, this is the caption sent with the files. You can send an empty string, but you must include the |
groupKey | string | The key of the group where the chat should be assigned. |
customerIds | array of integers | Specifies the customer IDs to start the chat with. Without a file, specify up to ten customers. With files, specify exactly one customer. In multipart requests, send a JSON array string, such as |
agentId | int | The ID of the agent who will be handling the chat. |
| Optional | Type | Description |
|---|---|---|
priority | string | Specifies the priority level of the chat. Acceptable values are |
file | binary | Specifies a file to attach to the initial message. The file can't be empty. Use |
File attachments
The attachment limits are the following:
Attachment limits
| Item | Requirement |
|---|---|
Files per request | Up to five files. |
Customers per attachment request | Exactly one customer. |
File field name |
|
File size | Each file must be greater than zero bytes. The total size of all files can't exceed 10 MiB, or 10,485,760 bytes. |
Desk doesn't restrict attachments by file extension or MIME type.
The following example uses placeholder credentials and example IDs. Replace them with your application's values and provide local files. Let curl or your FormData client generate the multipart boundary instead of manually setting the Content-Type header.
Desk uses a separate Bot user for each application, and creates it if it doesn't exist. The Bot sends the files and caption together as one FILE message. When the request includes more than one file, client SDKs receive the message as a MultipleFilesMessage. The agentId field is required, but the sender displayed in Chat is the Bot rather than that agent's profile. Check that your customer SDK and UI render the files and caption of a FILE message, including messages with several files.
Desk creates the Bot with the nickname File delivery and the default profile image, and customers see this name in the chat. To change the nickname or image, go to Settings > Desk > General > Proactive chat in Sendbird Dashboard and click Edit bot profile under Messenger. The link opens the Bot's page under Users, and it requires permission to view users. Desk doesn't overwrite an existing Bot, so your changes are kept. Because client SDKs cache user information, the change can take some time to appear in chats that are already open.
Initial messages without a file and follow-up messages are sent as admin messages, or ADMM. File attachment support applies only to the initial message. Follow-up messages support text only.
Successful Response
If successful, this action returns HTTP 200 and a JSON representation of the created Proactive Chat. The response includes attachments when the initial message has files and omits the property otherwise.
The following example shows only part of a response with attachments:
Attachment errors
Errors use the {"code":"...","detail":"..."} response format. Validation errors for required fields, customers, agents, and groups also apply to attachment requests.
Attachment errors
| HTTP status | Code | Description |
|---|---|---|
400 | deskp400114 | Indicates invalid attachment input, such as multiple customers, more than five files, an empty file, an incorrect file field name, a JSON file reference, or files in a follow-up message. The text in the |
400 | deskp400115 | Indicates that Desk can't prepare the attachment Bot for the application. The most common cause is that the application doesn't have access to the Bot Interface. Other errors or timeouts from Chat can also return this code. Desk doesn't send the message without the files. Once the cause is resolved, the next attachment request works without further action. |
413 | deskp413500 | Indicates that the total size of the files exceeds 10 MiB, or 10,485,760 bytes. |
502 | deskp502500 | Indicates that file upload or delivery failed and the message is confirmed not to have been sent. |
502 | deskp502501 | Indicates that the delivery result is unknown. The detail is |
For deskp502501, the message may already have been sent. Don't automatically retry the request. This API doesn't support idempotency keys or delivery lookup by request ID, so you can't confirm an unknown result through the API.
Get Proactive Chat
Retrieves information about a specific Proactive Chat.
HTTP Request
Parameters
Include the {proactive_id} parameter in the URL path.
Required
| Parameter name | Type | Description |
|---|---|---|
proactive_id | int | The ID of the specific Proactive Chat. |
Request Body
No request body needed.
Successful Response
If successful, the server returns the Proactive Chat resource as a JSON object in the response body.
The resource includes the attachments property when the initial message has files. Otherwise, the property doesn't appear. To learn more about the descriptor fields and download authentication, refer to Resource Representation.
List tickets of Proactive Chat
Retrieves a list of tickets of the Proactive Chat.
HTTP Request
Parameters
Include the following parameters in the request:
Parameters
| Required | Type | Description |
|---|---|---|
proactive_id | int | The ID of the specific Proactive Chat. |
| Optional | Type | Description |
|---|---|---|
limit | int | Number of results to return per page. |
offset | int | The initial index from which to return the results. |
Successful Response
If successful, this action returns a list of ticket resources that were initiated by a Proactive Chat as a JSON object in the response body.
Send a follow-up message
Send a follow-up message to a specific Proactive Chat ticket.
HTTP Request
Parameters
Include the following parameters in the request:
Required
| Parameter name | Type | Description |
|---|---|---|
proactive_id | int | The ID of the specific Proactive Chat. |
ticket_id | int | The ID of the specific ticket of the Proactive Chat. |
Request Body
Include the following properties in your request body:
Required
| Property name | Type | Description |
|---|---|---|
message | string | The content of the follow-up message. |
Follow-up messages support text only. If the request includes files, the action fails with a 400 error and the deskp400114 code, and the message isn't sent.
Successful Response
If successful, this action returns a JSON representation of the follow-up message in the response body.