Message Reference
This document provides a complete reference for all WebSocket message types used in BlackBox agent communication. All messages are JSON objects sent over the WebSocket connection.Message Structure
All messages follow this base structure:Client → Server Messages
Messages sent from your application to the BlackBox server.Initialize (initialize)
Start a new conversation with an agent.
Message Type: initialize
Schema:
Incoming Chat Message (incomingChatMessage)
Send a text message to the agent.
Message Type: incomingChatMessage
Schema:
SDP Answer (sdpAnswer)
Respond to WebRTC SDP offer for voice calls.
Message Type: sdpAnswer
Schema:
sdpInvite messages during voice call setup.
WebSocket Tool Response (websocketToolResponse)
Return result of tool execution requested via WebSocket.
Message Type: websocketToolResponse
Schema:
websocketToolRequest messages.
Terminate (terminate)
End the conversation and close the connection.
Message Type: terminate
Schema:
Server → Client Messages
Messages received from the BlackBox server.Event (event)
System events indicating connection state and lifecycle.
Message Type: event
Schema:
connection: WebSocket connection established and agent session readyopened: Conversation opened successfullyclosed: Conversation closed normallyfailedOpen: Failed to open conversation
Text (text)
Text messages from agent or user (echo of sent messages).
Message Type: text
Schema:
- Agent responses to user messages
- Echo of user messages you sent (for transcript)
- Streaming/partial messages (with
type: "potential")
SDP Invite (sdpInvite)
WebRTC SDP offer for voice call setup.
Message Type: sdpInvite
Schema:
callType: "webCall"). Respond with sdpAnswer.
Tool Call (toolCall)
Agent is calling a tool/function.
Message Type: toolCall
Schema:
Tool Call Result (toolCallResult)
Result of tool execution.
Message Type: toolCallResult
Schema:
WebSocket Tool Request (websocketToolRequest)
Tool execution request via WebSocket (alternative to webhooks).
Message Type: websocketToolRequest
Schema:
websocketToolResponse.
Conversation Result (conversationResult)
Final conversation summary and metadata.
Message Type: conversationResult
Schema:
terminate or natural completion).
Error (error)
Error message from server.
Message Type: error
Schema:
Message Flow Examples
Chat Conversation Flow
Voice Call Flow
Tool Execution Flow
TypeScript Types
Define types based on the message schemas:Message Validation
All messages should be validated before processing:Next Steps
- Chat Implementation - See messages in action
- Voice Call Implementation - WebRTC message flow
- Tool Execution - Tool message handling
- Error Handling - Error message patterns