Build a text chat interface with WebSockets. Establish connections, send messages, receive agent responses, and handle conversation lifecycle. What you’ll learn: Connection setup, message exchange, response handling, and conversation cleanup.Documentation Index
Fetch the complete documentation index at: https://docs.blackbox.dasha.ai/llms.txt
Use this file to discover all available pages before exploring further.
Testing requires a valid API key. Generate a web integration token from your agent’s Web Integrations settings in the Dasha BlackBox dashboard before starting.
Prerequisites
Before you start, ensure you have:- A Dasha BlackBox agent with chat enabled
- A web integration token (from Dashboard → Agent → Web Integrations)
- The
AllowWebChatfeature enabled on your web integration
Connection flow
Connection flow
Text chat follows this message sequence:
Step 1: Establish connection
Connect to the WebSocket endpoint and send theinitialize message:
Example: WebSocket connection for chat
Example: WebSocket connection for chat
connection event when the agent session is ready:
Example: Connection event response
Example: Connection event response
Step 2: Send messages
Use theincomingChatMessage type to send text messages:
Example: Send chat message
Example: Send chat message
IncomingChatMessage schema
| Field | Type | Required | Description |
|---|---|---|---|
type | "incomingChatMessage" | Yes | Message type identifier |
content | string | Yes | Text message content |
timestamp | string (ISO 8601) | Yes | Message timestamp |
channelId | string | null | No | Optional channel identifier |
Step 3: Receive messages
Handle incoming messages from the server:Example: Handle incoming messages
Example: Handle incoming messages
TextHistoryMessage schema
| Field | Type | Description |
|---|---|---|
type | "text" | Message type identifier |
timestamp | string (ISO 8601) | Message timestamp |
content.source | "assistant" | "user" | Message sender |
content.text | string | null | Message text content |
content.name | string | null | Optional sender name |
content.type | "potential" | "confident" | "final" | Recognition confidence (user messages) |
content.segmentId | string | Segment identifier (user messages) |
TextHistoryMessage example
TextHistoryMessage example
Step 4: End conversation
Send aterminate message and wait for the conversation result:
Example: End conversation gracefully
Example: End conversation gracefully
ConversationResultHistoryMessage example
ConversationResultHistoryMessage example
Next steps
Message Reference
Complete schema documentation for all WebSocket messages
Voice Call Implementation
Add WebRTC voice calls to your integration
Tool Execution
Handle agent tool calls via WebSocket
Error Handling
Handle connection errors and edge cases