> ## Documentation Index
> Fetch the complete documentation index at: https://docs.splox.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Listen to Chat Events (SSE)

> Streams real-time chat updates via Server-Sent Events. Subscribes to the chat's Redis channel and streams workflow request updates and node execution events for the chat session. Keepalive every 3 seconds, 30-minute timeout.

Streams real-time events for a chat session via Server-Sent Events (SSE). This is the recommended way to receive live updates when running a workflow through a chat.

## Usage

<CodeGroup>
  ```bash cURL theme={null}
  curl -N -H "Authorization: Bearer YOUR_TOKEN" \
    https://app.splox.io/api/v1/chat-internal-messages/{chat_id}/listen
  ```

  ```python Python theme={null}
  from splox import SploxClient

  client = SploxClient(api_key="YOUR_API_KEY")

  for event in client.chats.listen("CHAT_ID"):
      if event.is_keepalive:
          continue
      if event.node_execution:
          print(f"[{event.node_execution.status}] {event.node_execution.node_id}")
      if event.workflow_request and event.workflow_request.status == "completed":
          print("Done!")
          break
  ```

  ```typescript Node.js theme={null}
  import Splox from "splox";

  const client = new Splox("YOUR_API_KEY");

  const stream = await client.chats.listen("CHAT_ID");
  for await (const event of stream) {
    if (event.isKeepalive) continue;
    if (event.node_execution) {
      console.log(`[${event.node_execution.status}] ${event.node_execution.node_id}`);
    }
    if (event.workflow_request?.status === "completed") {
      console.log("Done!");
      break;
    }
  }
  ```

  ```go Go theme={null}
  client := splox.NewClient("YOUR_API_KEY")
  iter, err := client.Chats.Listen(ctx, "CHAT_ID")
  if err != nil {
      log.Fatal(err)
  }
  defer iter.Close()

  for iter.Next() {
      ev := iter.Event()
      if ev.IsKeepalive {
          continue
      }
      if ev.NodeExecution != nil {
          fmt.Printf("[%s] %s\n", ev.NodeExecution.Status, ev.NodeExecution.NodeID)
      }
      if ev.WorkflowRequest != nil && ev.WorkflowRequest.Status == "completed" {
          fmt.Println("Done!")
          break
      }
  }
  ```
</CodeGroup>

## How It Works

1. Subscribes to the chat's Redis PubSub channel
2. Streams workflow request status updates and node execution events
3. Sends keepalive messages every 3 seconds
4. Checks workflow status every 5 seconds
5. Connection times out after 30 minutes

## Response Format

Standard SSE format. Events contain workflow request and node execution updates:

```
data: {"workflow_request":{"id":"...","status":"in_progress",...},"node_execution":{"id":"...","status":"completed",...}}

data: keepalive

data: {"is_active":false,"type":"workflow_status"}
```

## Event Types

| Event                  | Description                                                                             |
| ---------------------- | --------------------------------------------------------------------------------------- |
| Workflow + Node update | Contains `workflow_request` and/or `node_execution` fields with current status and data |
| Keepalive              | Literal string `keepalive` sent every 3 seconds                                         |
| Workflow status        | `{"is_active":false,"type":"workflow_status"}` when a workflow stops                    |

## Notes

<Info>
  **Authentication required:** Users can only listen to their own chats.
</Info>

<Warning>
  **Connection timeout:** SSE connections timeout after 30 minutes. Reconnect if needed.
</Warning>

<Tip>
  The keepalive messages every 3 seconds prevent connection drops from proxies and load balancers.
</Tip>


## OpenAPI

````yaml GET /chat-internal-messages/{chatId}/listen
openapi: 3.1.0
info:
  title: Splox API
  description: >-
    Run workflows, manage chats, receive events, and monitor execution via the
    Splox API
  version: 1.0.0
  contact:
    name: Splox Support
    email: support@splox.io
    url: https://community.splox.io
servers:
  - url: https://app.splox.io/api/v1
    description: Production API
security: []
tags:
  - name: MCP
    description: Discover MCP servers, manage connections, and execute MCP tools
  - name: Workflows
    description: List, get, and inspect workflows, versions, and nodes
  - name: Workflow Requests
    description: Run workflows, monitor execution, and retrieve results
  - name: Events
    description: Receive external events via Event Hub webhooks
  - name: Chats
    description: Manage chat sessions for workflow interactions
paths:
  /chat-internal-messages/{chatId}/listen:
    get:
      tags:
        - Chats
      summary: Listen to Chat Messages (SSE)
      description: >-
        Streams real-time chat updates via Server-Sent Events. Subscribes to the
        chat's Redis channel and streams workflow request updates and node
        execution events for the chat session. Keepalive every 3 seconds,
        30-minute timeout.
      operationId: listenChatMessages
      parameters:
        - name: chatId
          in: path
          required: true
          description: Chat ID
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: >-
            SSE stream of chat events. Includes workflow request status updates
            and node execution events for the chat session.
          content:
            text/event-stream:
              schema:
                type: string
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API token generated from your Splox account settings. Create tokens at
        https://app.splox.io/account?tab=settings

````