Skip to main content

WebSocket server events

This page lists every WebSocket event that the server emits, with its payload structure.

Event session:created​

Response to a successful session creation. The server sends this event when it establishes a new session with the client. The event contains the configuration and the context information of the session.

FieldTypeDescription
session_idstringUnique identifier for the session
is_service_deskbooleanWhether this is a service desk session
is_conversationbooleanWhether this is a conversation session
is_handoverbooleanWhether this is a handover session
assignee_agent_idstringID of the assigned agent
assignee_brain_idstringID of the assigned AI agent
assignee_collection_idstringID of the assigned knowledge base
sourceobjectSource information object. It includes keep_alive and brain_inactivity_timeout in seconds.
contextContextObjectSession context information

Example payload:

{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"is_service_desk": true,
"is_conversation": true,
"is_handover": false,
"assignee_agent_id": "550e8400-e29b-41d4-a716-446655440000",
"assignee_brain_id": "550e8400-e29b-41d4-a716-446655440000",
"assignee_collection_id": "550e8400-e29b-41d4-a716-446655440000",
"source": {
"integration_id": "550e8400-e29b-41d4-a716-446655440000",
"channel": "web",
"opt_out": false,
"is_test": false,
"account_id": "550e8400-e29b-41d4-a716-446655440000",
"brain_id": "550e8400-e29b-41d4-a716-446655440000",
"brain_parent_id": "550e8400-e29b-41d4-a716-446655440000",
"brain_version": 1,
"desk_id": "550e8400-e29b-41d4-a716-446655440000",
"session_timeout": 3600,
"brain_inactivity_timeout": 300,
"keep_alive": 30,
"account_slug": "example-account",
"department_id": "550e8400-e29b-41d4-a716-446655440000"
},
"context": {
"user_id": "550e8400-e29b-41d4-a716-446655440000",
"language": "en"
}
}

Event session:leader​

Identifies the leader connection for a session (for sticky sessions). Load-balanced environments use this event to designate the connection that maintains the session state.

FieldTypeDescription
session_idstringUnique identifier for the session
leader_idstringID of the leader connection

Example payload:

{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"leader_id": "550e8400-e29b-41d4-a716-446655440000"
}

Event session:closed​

The server emits this event when a session closes successfully. The event confirms that the server ended the session and cleaned up its state.

FieldTypeDescription
session_idstringUnique identifier for the session
timestampintegerOptional timestamp of when the session was closed
statusstringAlways closed

Example payload:

{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"timestamp": 1678901234,
"status": "closed"
}

Event session:expired​

Indicates that a session expired and that the client cannot reconnect to it. The server sends this event when it ends a session that stayed inactive for too long.

FieldTypeDescription
session_idstringUnique identifier for the session
leader_idstringID of the leader connection

Example payload:

{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"leader_id": "550e8400-e29b-41d4-a716-446655440000"
}

Event conversation:member_join​

The server emits this event when an AI agent or a human agent joins the conversation. The event notifies all participants that a new member entered the conversation.

FieldTypeDescription
session_idstringUnique identifier for the session
author_idstringID of the joining member
desk_idstringID of the desk
author_namestringName of the joining member
timestampintegerOptional timestamp of when the member joined
author_typestringEither brain or agent

Example payload:

{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"author_id": "550e8400-e29b-41d4-a716-446655440000",
"desk_id": "550e8400-e29b-41d4-a716-446655440000",
"author_name": "John Doe",
"timestamp": 1678901234,
"author_type": "agent"
}

Event conversation:member_leave​

The server emits this event when an AI agent or a human agent leaves the conversation. The event notifies all participants that a member left the conversation.

FieldTypeDescription
session_idstringUnique identifier for the session
author_idstringID of the leaving member
desk_idstringID of the desk
author_namestringName of the leaving member
timestampintegerOptional timestamp of when the member left
author_typestringEither brain or agent

Example payload:

{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"author_id": "550e8400-e29b-41d4-a716-446655440000",
"desk_id": "550e8400-e29b-41d4-a716-446655440000",
"author_name": "John Doe",
"timestamp": 1678901234,
"author_type": "agent"
}

Event conversation:closed​

The server emits this event when a conversation is resolved. The event indicates that the conversation is complete. Do not expect more messages.

FieldTypeDescription
session_idstringUnique identifier for the session
keep_aliveintegerOptional keep-alive interval in seconds
timestampintegerOptional timestamp of when the conversation was closed
agent_idstringOptional ID of the agent who closed the conversation
agent_namestringOptional name of the agent who closed the conversation
statusstringAlways closed

Example payload:

{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"keep_alive": 30,
"timestamp": 1678901234,
"agent_id": "550e8400-e29b-41d4-a716-446655440000",
"agent_name": "John Doe",
"status": "closed"
}

Event conversation:reopened​

The server emits this event when the user reopens a closed conversation. The event indicates that the resolved conversation is active again and can receive new messages.

FieldTypeDescription
session_idstringUnique identifier for the session
keep_aliveintegerOptional keep-alive interval in seconds
timestampintegerOptional timestamp of when the conversation was reopened
agent_idstringOptional ID of the agent who reopened the conversation
agent_namestringOptional name of the agent who reopened the conversation
statusstringAlways open

Example payload:

{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"keep_alive": 30,
"timestamp": 1678901234,
"agent_id": "550e8400-e29b-41d4-a716-446655440000",
"agent_name": "John Doe",
"status": "open"
}

Event message:brain_received​

A response from the AI agent. This event contains the AI agent's response to a user message, with any structured data or media to display to the user.

FieldTypeDescription
session_idstringUnique identifier for the session
contextContextObjectOptional context information
outputOutputObjectResponse output object
timestampintegerTimestamp of when the message was received
brain_languagestringLanguage of the AI agent response
request_idstringID of the request that generated this response

OutputObject structure​

FieldTypeDescription
responsesarrayArray of response objects
debugobjectOptional debug information

Example payload:

{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"context": {
"user_id": "550e8400-e29b-41d4-a716-446655440000",
"language": "en"
},
"output": {
"responses": [
{
"type": "text",
"text": "Hello! How can I help you today?",
"show_typing": true,
"duration": 2000
}
],
"debug": {
"collection": {
"collection_id": "550e8400-e29b-41d4-a716-446655440000",
"request_code": 200,
"response_code": 200,
"external_urls": [
{
"external_url": "https://example.com",
"name": "Example Documentation",
"document_id": "550e8400-e29b-41d4-a716-446655440000",
"datasource_id": "550e8400-e29b-41d4-a716-446655440000"
}
]
}
}
},
"timestamp": 1678901234,
"brain_language": "en",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}

Event message:received​

A message from a human agent. This event contains the message, with any attachments or media to display to the user.

FieldTypeDescription
session_idstringUnique identifier for the session
fromobjectInformation about the sender
toobjectInformation about the recipient
bodyobjectMessage content
timestampintegerOptional timestamp of when the message was received
contextContextObjectOptional context information

Example payload:

{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"from": {
"agent_id": "550e8400-e29b-41d4-a716-446655440000",
"team_id": "550e8400-e29b-41d4-a716-446655440000",
"agent_name": "John Doe",
"agent_avatar": "https://example.com/avatar.jpg"
},
"to": {
"user_id": "550e8400-e29b-41d4-a716-446655440000"
},
"body": {
"text": "Hello! How can I assist you today?",
"attachments": [
{
"type": "image",
"mime_type": "image/jpeg",
"id": "550e8400-e29b-41d4-a716-446655440000",
"url": "https://example.com/image.jpg",
"title": "Example Image",
"filename": "example.jpg"
}
]
},
"timestamp": 1678901234,
"context": {
"user_id": "550e8400-e29b-41d4-a716-446655440000",
"language": "en"
}
}

Event message:compose​

Indicates a typing event from the AI agent or a human agent. Use this event to show a typing indicator in the UI while the author composes a message.

FieldTypeDescription
session_idstringUnique identifier for the session
author_idstringID of the author
desk_idstringOptional ID of the desk
author_namestringOptional name of the author
timestampintegerOptional timestamp of the typing event
author_typestringEither brain, agent, or visitor
actionstringEither start or stop

Example payload:

{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"author_id": "550e8400-e29b-41d4-a716-446655440000",
"desk_id": "550e8400-e29b-41d4-a716-446655440000",
"author_name": "John Doe",
"timestamp": 1678901234,
"author_type": "agent",
"action": "start"
}

Event message:delivered​

A message reached the server. This event confirms that the server received the message and processes it.

FieldTypeDescription
session_idstringUnique identifier for the session
author_typestringEither brain, agent, or visitor
timestampintegerTimestamp of when the message was delivered

Example payload:

{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"author_type": "agent",
"timestamp": 1678901234
}

Event message:read​

A message is marked as read. This event indicates that the recipient viewed the message.

FieldTypeDescription
session_idstringUnique identifier for the session
author_typestringEither brain, agent, or visitor
timestampintegerTimestamp of when the message was read

Example payload:

{
"session_id": "550e8400-e29b-41d4-a716-446655440000",
"author_type": "agent",
"timestamp": 1678901234
}