Testing requires a valid API key. All examples in this section require authentication with either a web integration token or API key for Dasha BlackBox.
Base message structure
Base message structure
All WebSocket messages share these common fields:
Client to server messages
Messages you send to the Dasha BlackBox server.initialize
initialize
Start a new conversation with an agent. Send immediately after WebSocket connection opens.
WebCallStartMessage schema
*Either
request (production) or devRequest (development) is required, depending on which endpoint you’re using.
incomingChatMessage
incomingChatMessage
Send a text message to the agent during chat conversations.
IncomingChatMessage schema
sdpAnswer
sdpAnswer
Respond to WebRTC SDP offer for voice calls. Send in response to
sdpInvite message.SdpAnswerMessage schema
websocketToolResponse
websocketToolResponse
Return the result of a tool execution requested via WebSocket. Send in response to
websocketToolRequest message.WebsocketToolResponseMessage schema
terminate
terminate
End the conversation gracefully. Wait for
conversationResult before closing the WebSocket.TerminateMessage schema
Server to client messages
Messages you receive from the Dasha BlackBox server.event
event
System events indicating connection state and lifecycle changes.
EventHistoryMessage schema
Event names
text
Text messages from agent or user speech transcription.Agent response
Agent response
User message (echo/transcription)
User message (echo/transcription)
TextHistoryMessage schema
Additional fields for assistant messages:
Additional fields for user messages:
Recognition types
sdpInvite
sdpInvite
WebRTC SDP offer for voice call setup. Respond with
sdpAnswer.SdpInviteMessage schema
toolCall
toolCall
Notification that the agent is calling a tool/function.
ToolCallHistoryMessage schema
toolCallResult
toolCallResult
Result of a tool execution.
ToolCallResultHistoryMessage schema
websocketToolRequest
websocketToolRequest
Request to execute a tool via WebSocket (for tools configured with WebSocket execution). Respond with
websocketToolResponse.WebsocketToolRequestHistoryMessage schema
conversationResult
conversationResult
Final conversation summary and metadata. Sent after
terminate or when conversation ends.ConversationResultHistoryMessage schema
The
result object structure depends on your agent configuration.
error
error
Error notification from the server.
ErrorHistoryMessage schema
Common error messages
Message flow diagrams
Chat conversation
Chat conversation
Voice call
Voice call
Tool execution via WebSocket
Tool execution via WebSocket
TypeScript types
TypeScript types
Use these types for type-safe message handling:
Next steps
Chat Implementation
Build a complete chat interface with these messages
Tool Execution
Handle tool calls via WebSocket
Error Handling
Handle errors and edge cases
Voice Implementation
WebRTC voice call message flow