Desk Platform API v1
Desk Platform API
Desk Platform API
Version 1

Proactive Chat

Copy link

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

Copy link

Here's what a Proactive Chat resource looks like:

Property nameTypeDescription

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[].requireAuth.

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

Copy link
  • Endpoints are relative to the base URL allocated to your application. In this document, the /proactive_chats endpoint is prefixed by https://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

Copy link
ActionHTTP request

Create Proactive Chat

POST /proactive_chats
Initiates a new Proactive Chat.

Get Proactive Chat

GET /proactive_chats/{proactive_id}
Retrieves information about a specific Proactive Chat.

List Tickets of Proactive Chat

GET /proactive_chats/{proactive_id}/tickets
Retrieves a list of tickets of the Proactive Chat.

Send a follow-up message

POST /proactive_chats/{proactive_id}/tickets/{ticket_id}/follow_up_message
Send a follow-up message for a ticket of a specific Proactive Chat.


Create Proactive Chat

Copy link

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

Copy link
POST https://desk-api-{application_id}.sendbird.com/platform/v1/proactive_chats

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/v1 instead of https://desk-api-{application_id}.sendbird.com/platform/v1. For more details, refer to our Delight AI agent guide.

Request Body

Copy link

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
RequiredTypeDescription

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 message field.

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 [12345], or repeat the customerIds field once for each ID.

agentId

int

The ID of the agent who will be handling the chat.

OptionalTypeDescription

priority

string

Specifies the priority level of the chat. Acceptable values are LOW, MEDIUM, HIGH, and URGENT. (Default: MEDIUM)

file

binary

Specifies a file to attach to the initial message. The file can't be empty. Use multipart/form-data and the exact field name file, and repeat the field for each file. You can attach up to five files with a total size of up to 10 MiB, or 10,485,760 bytes.

File attachments

Copy link

The attachment limits are the following:

Attachment limits
ItemRequirement

Files per request

Up to five files.

Customers per attachment request

Exactly one customer.

File field name

file, repeated for each file.

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.

curl -X POST 'https://desk-api-{application_id}.sendbird.com/platform/v1/proactive_chats' \
  -H 'SENDBIRDDESKAPITOKEN: {desk_api_token}' \
  --form-string 'message=Here are your files.' \
  --form-string 'customerIds=[12345]' \
  --form-string 'groupKey=customer-support' \
  --form-string 'agentId=67890' \
  -F 'file=@guide.pdf;type=application/pdf' \
  -F 'file=@photo.png;type=image/png'

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

Copy link

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:

{
    "id": 12345,
    "message": "Here are your files.",
    "attachments": [
        {
            "url": "https://storage.example.com/guide.pdf",
            "fileName": "guide.pdf",
            "fileType": "application/pdf",
            "fileSize": 1024,
            "requireAuth": false,
            "thumbnails": []
        },
        {
            "url": "https://storage.example.com/photo.png",
            "fileName": "photo.png",
            "fileType": "image/png",
            "fileSize": 2048,
            "requireAuth": false,
            "thumbnails": []
        }
    ]
}

Attachment errors

Copy link

Errors use the {"code":"...","detail":"..."} response format. Validation errors for required fields, customers, agents, and groups also apply to attachment requests.

Attachment errors
HTTP statusCodeDescription

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 detail field depends on the validation error.

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 Proactive attachment delivery status is unknown. Do not retry this request.

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

Copy link

Retrieves information about a specific Proactive Chat.

HTTP Request

Copy link
GET https://desk-api-{application_id}.sendbird.com/platform/v1/proactive_chats/{proactive_id}

Parameters

Copy link

Include the {proactive_id} parameter in the URL path.

Required
Parameter nameTypeDescription

proactive_id

int

The ID of the specific Proactive Chat.

Request Body

Copy link

No request body needed.

Successful Response

Copy link

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

Copy link

Retrieves a list of tickets of the Proactive Chat.

HTTP Request

Copy link
GET https://desk-api-{application_id}.sendbird.com/platform/v1/proactive_chats/{proactive_id}/tickets

Parameters

Copy link

Include the following parameters in the request:

Parameters
RequiredTypeDescription

proactive_id

int

The ID of the specific Proactive Chat.

OptionalTypeDescription

limit

int

Number of results to return per page.

offset

int

The initial index from which to return the results.

Successful Response

Copy link

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

Copy link

Send a follow-up message to a specific Proactive Chat ticket.

HTTP Request

Copy link
POST https://desk-api-{application_id}.sendbird.com/platform/v1/proactive_chats/{proactive_id}/tickets/{ticket_id}/follow_up_message

Parameters

Copy link

Include the following parameters in the request:

Required
Parameter nameTypeDescription

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

Copy link

Include the following properties in your request body:

Required
Property nameTypeDescription

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

Copy link

If successful, this action returns a JSON representation of the follow-up message in the response body.