---
title: "WebSocket client events"
description: "Look up every event that a client emits over a WebSocket connection, with its payload fields and the server responses to expect."
---

# WebSocket client events

> Look up every event that a client emits over a WebSocket connection, with its payload fields and the server responses to expect.

This page lists all supported events emitted by the client over a WebSocket connection and the
expected server responses.

## Event `session:create`

Create a new session. This event initializes a new conversation session with the server, including
optional context and authentication information.

| Field            | Type          | Description                                                                                                                                                          |
| ---------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `context`        | ContextObject | Optional context information                                                                                                                                         |
| `identity_token` | string        | Optional authentication token. Required when the integration has [`require_identity_token`](/docs/integrations/web/web-getting-started#require-an-identity-token) on |
| `timestamp`      | integer       | Required timestamp of the request                                                                                                                                    |
| `is_test`        | boolean       | Optional flag indicating if this is a test session                                                                                                                   |
| `opt_out`        | boolean       | Optional. When `true`, Moveo does not store analytics data for this session                                                                                          |

Example payload:

```json
{
  "context": {
    "user_id": "550e8400-e29b-41d4-a716-446655440000",
    "language": "en",
    "browser": "Chrome",
    "os": "Windows"
  },
  "identity_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "timestamp": 1678901234,
  "is_test": false,
  "opt_out": false
}
```

### Server responses

- On success [`session:created`](https://docs.moveo.ai/api/websocket/server-events.md#event-sessioncreated)
- On failure
  - `session:create:error`
  - `session:create:error:invalid_identity_token`
  - `session:create:error:invalid_private_key`
  - `session:create:error:invalid_aes_claims`
  - `session:create:error:failed_aes_descryption`

## Event `session:context:update`

Used after initial form submission or reconnection. This event updates the session context with new
information.

| Field        | Type          | Description                      |
| ------------ | ------------- | -------------------------------- |
| `session_id` | string        | Required session identifier      |
| `context`    | ContextObject | Required context information     |
| `timestamp`  | integer       | Required timestamp of the update |

Example payload:

```json
{
  "session_id": "550e8400-e29b-41d4-a716-446655440000",
  "context": {
    "user_id": "550e8400-e29b-41d4-a716-446655440000",
    "language": "en",
    "department": "support",
    "priority": "high"
  },
  "timestamp": 1678901234
}
```

### Server responses

- On success `session:context:updated`
- On failure `session:context:update:error`

## Event `session:reconnect`

Reconnect using a previously stored session ID. This event attempts to restore a previous session.

| Field            | Type    | Description                                                                                                                                                                                                                      |
| ---------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `session_id`     | string  | Required session identifier                                                                                                                                                                                                      |
| `timestamp`      | integer | Required timestamp of reconnect                                                                                                                                                                                                  |
| `identity_token` | string  | Required when the integration [requires an identity token](/docs/integrations/web/web-getting-started#require-an-identity-token) and the session started with a token. A JWT for the same user (`sub`) that started the session. |

Example payload:

```json
{
  "session_id": "550e8400-e29b-41d4-a716-446655440000",
  "timestamp": 1678901234,
  "identity_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
}
```

### Server responses

- On success `session:reconnected`
- On failure `session:reconnect:error`
- When the server refuses the identity token: [`session:expired`](https://docs.moveo.ai/api/websocket/server-events.md#event-sessionexpired)

## Event `session:overview`

Check for available live agents and estimated wait times. This event retrieves information about
current service availability.

| Field        | Type   | Description                 |
| ------------ | ------ | --------------------------- |
| `session_id` | string | Required session identifier |

Example payload:

```json
{
  "session_id": "550e8400-e29b-41d4-a716-446655440000"
}
```

### Server responses

- On success `session:overview`
- On failure `session:overview:error`

## Event `session:close`

Sent when the user ends the session. This event gracefully terminates the current session.

| Field        | Type   | Description                 |
| ------------ | ------ | --------------------------- |
| `session_id` | string | Required session identifier |

Example payload:

```json
{
  "session_id": "550e8400-e29b-41d4-a716-446655440000"
}
```

### Server responses

- On success `session:closed`
- On failure `session:status:error`

## Event `session:rating`

Submit a session rating. This event allows users to provide feedback about their session experience.

| Field        | Type    | Description                                 |
| ------------ | ------- | ------------------------------------------- |
| `session_id` | string  | Required session identifier                 |
| `timestamp`  | integer | Required timestamp of the rating            |
| `rating`     | integer | Required rating value (0–10)                |
| `feedback`   | string  | Optional feedback text (max 280 characters) |

Example payload:

```json
{
  "session_id": "550e8400-e29b-41d4-a716-446655440000",
  "timestamp": 1678901234,
  "rating": 9,
  "feedback": "The agent was very helpful and resolved my issue quickly."
}
```

### Server responses

- On success `session:rated`
- On failure `session:rating:error`

## Event `session:activity`

Indicates active user interaction. This event keeps the session alive by showing user activity.

| Field        | Type    | Description                    |
| ------------ | ------- | ------------------------------ |
| `session_id` | string  | Required session identifier    |
| `timestamp`  | integer | Required timestamp of activity |

Example payload:

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

### Server responses

- On success: no response.
- On failure `session:activity:error`

## Event `session:history:sync`

Used after reconnecting to retrieve past messages. This event synchronizes the conversation history.

| Field        | Type    | Description                 |
| ------------ | ------- | --------------------------- |
| `session_id` | string  | Required session identifier |
| `timestamp`  | integer | Required timestamp of sync  |

Example payload:

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

### Server responses

- On success `session:history:synced`
- On failure `session:history:sync:error`

## Event `conversation:reopen`

Reopen a resolved live agent conversation. This event reactivates a previously closed conversation.

| Field        | Type   | Description                 |
| ------------ | ------ | --------------------------- |
| `session_id` | string | Required session identifier |

Example payload:

```json
{
  "session_id": "550e8400-e29b-41d4-a716-446655440000"
}
```

### Server responses

- On success `conversation:reopened`
- On failure `session:status:error`

## Event `message:send`

Send a message (text or media). This event allows users to send messages and attachments to the
conversation.

| Field        | Type          | Description                       |
| ------------ | ------------- | --------------------------------- |
| `input`      | object        | Message content and attachments   |
| `session_id` | string        | Required session identifier       |
| `context`    | ContextObject | Optional context information      |
| `timestamp`  | integer       | Required timestamp of the message |

Example payload:

```json
{
  "input": {
    "text": "Hello, I need help with my account",
    "type": "text",
    "attachments": [
      {
        "type": "image",
        "mime_type": "image/jpeg",
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "url": "https://example.com/image.jpg",
        "title": "Account Screenshot",
        "filename": "screenshot.jpg"
      }
    ]
  },
  "session_id": "550e8400-e29b-41d4-a716-446655440000",
  "context": {
    "user_id": "550e8400-e29b-41d4-a716-446655440000",
    "language": "en"
  },
  "timestamp": 1678901234
}
```

To run a dialog node in place of a message, send `trigger_node_id` in `input`, without `text`:

```json
{
  "input": { "trigger_node_id": "YOUR_NODE_ID" },
  "session_id": "550e8400-e29b-41d4-a716-446655440000",
  "timestamp": 1678901234
}
```

You can send `attachments` with a `trigger_node_id`. A `trigger_node_id` with `text` returns
`app:error:invalid_payload`.

### Server responses

- On success: the server does not respond to the connection that sent the event. It responds to the
  other open connections for this session with a `message:send:sync` event. Its payload is the same
  as the payload of the `message:send` event.
- On failure `message:send:error`

## Event `message:read`

Mark a message as read. This event indicates that a message has been viewed by the user.

| Field        | Type    | Description                 |
| ------------ | ------- | --------------------------- |
| `session_id` | string  | Required session identifier |
| `timestamp`  | integer | Required timestamp of read  |

Example payload:

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

### Server responses

- On success: no response.
- On failure `message:read:error`

## Event `message:delivered`

Confirm message delivery. This event acknowledges that a message has been received by the client.

| Field        | Type    | Description                    |
| ------------ | ------- | ------------------------------ |
| `session_id` | string  | Required session identifier    |
| `timestamp`  | integer | Required timestamp of delivery |

Example payload:

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

### Server responses

- On success: no response.
- On failure `message:delivered:error`

## Event `message:compose`

Indicate whether the user is typing. This event shows typing indicators to other participants.

| Field        | Type    | Description                            |
| ------------ | ------- | -------------------------------------- |
| `session_id` | string  | Required session identifier            |
| `action`     | string  | Required: `start` or `stop`            |
| `timestamp`  | integer | Required timestamp of the typing event |

Example payload:

```json
{
  "session_id": "550e8400-e29b-41d4-a716-446655440000",
  "action": "start",
  "timestamp": 1678901234
}
```

### Server responses

- On success: no response.
- On failure `message:compose:error`

## Event `message:rating`

Rate a specific AI message. This event allows users to provide feedback on individual AI responses.

| Field        | Type    | Description                      |
| ------------ | ------- | -------------------------------- |
| `session_id` | string  | Required session identifier      |
| `timestamp`  | integer | Required timestamp of the rating |
| `request_id` | string  | Required ID of the rated message |
| `value`      | integer | Required rating value (-1 or 1)  |

Example payload:

```json
{
  "session_id": "550e8400-e29b-41d4-a716-446655440000",
  "timestamp": 1678901234,
  "request_id": "550e8400-e29b-41d4-a716-446655440000",
  "value": 1
}
```

### Server responses

- On success `message:rated`
- On failure `message:rating:error`

## Event `file:upload_url:create`

Request a signed upload URL for a file. This event initiates the file upload process.

| Field           | Type   | Description                     |
| --------------- | ------ | ------------------------------- |
| `session_id`    | string | Required session identifier     |
| `file_type`     | string | Required type of file           |
| `file_id`       | string | Required unique file identifier |
| `original_name` | string | Required original filename      |

Example payload:

```json
{
  "session_id": "550e8400-e29b-41d4-a716-446655440000",
  "file_type": "jpg",
  "file_id": "550e8400-e29b-41d4-a716-446655440000",
  "original_name": "example.jpg"
}
```

### Server responses

- On success `file:upload_url:created`
- On failure `file:upload_url:create:error`

## Event `file:download_url:create`

Request a signed download URL for a file. This event initiates the file download process.

| Field           | Type   | Description                     |
| --------------- | ------ | ------------------------------- |
| `session_id`    | string | Required session identifier     |
| `file_id`       | string | Required unique file identifier |
| `file_name`     | string | Required name of the file       |
| `original_name` | string | Required original filename      |

Example payload:

```json
{
  "session_id": "550e8400-e29b-41d4-a716-446655440000",
  "file_id": "550e8400-e29b-41d4-a716-446655440000",
  "file_name": "example.jpg",
  "original_name": "example.jpg"
}
```

### Server responses

- On success `file:download_url:created`
- On failure `file:download_url:create:error`
