Skip to main content
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.
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 AllowWebChat feature enabled on your web integration
Text chat follows this message sequence:

Step 1: Establish connection

Connect to the WebSocket endpoint and send the initialize message:
The server responds with a connection event when the agent session is ready:

Step 2: Send messages

Use the incomingChatMessage type to send text messages:

IncomingChatMessage schema


Step 3: Receive messages

Handle incoming messages from the server:

TextHistoryMessage schema


Step 4: End conversation

Send a terminate message and wait for the conversation result:

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