Skip to main content
Build browser-based voice calls with WebRTC. Handle WebSocket signaling, SDP exchange, and audio streams — with complete code for the full call lifecycle. What you’ll learn: WebRTC setup, SDP offer/answer exchange, audio handling, and call termination.
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 voice enabled
  • A web integration token (from Dashboard → Agent → Web Integrations)
  • The AllowWebCall feature enabled on your web integration
  • HTTPS environment (WebRTC requires secure context)
  • User permission for microphone access
Voice calls use WebRTC for real-time audio and WebSocket for signaling:

Step 1: Establish WebSocket connection

Connect and initialize with callType: "webCall":

Step 2: Handle SDP offer

After initialization, the server sends an sdpInvite message with the WebRTC offer:

SdpInviteMessage schema


Step 3: Create peer connection and send answer

Create an RTCPeerConnection, set the remote offer, get microphone access, and send the answer:

SdpAnswerMessage schema


Step 4: Handle connection state changes

Monitor WebRTC connection state and handle audio:

Step 5: End the call

Clean up resources when ending the call:

Next steps

Message Reference

Complete schema documentation for all WebSocket messages

Error Handling

Handle connection errors and edge cases

Chat Implementation

Build text chat interfaces

Tool Execution

Handle agent tool calls via WebSocket