How does WebRTC work?
A WebRTC call is a peer connection between two endpoints, such as two browsers, or a browser and a media server. In the browser, getUserMedia() captures the microphone, RTCPeerConnection carries the call and RTCDataChannel sends messages. Setting up a call has three parts:
- Signalling: the two sides swap a description of the session, written in the Session Description Protocol (SDP), as an offer and an answer. WebRTC leaves signalling to the application, which usually sends the offer to its own server.
- Connectivity: Interactive Connectivity Establishment (ICE) finds a network path between them, using STUN servers to discover public addresses and TURN servers to relay traffic when a direct route is blocked.
- Media and data: audio and video travel as media tracks, and other messages over data channels. The IETF’s WebRTC security architecture requires all media to be encrypted with SRTP and all data channels with DTLS.
Why do voice agents use WebRTC?
It was built for live conversation. The two ends agree an audio codec through SDP, and every WebRTC endpoint must support Opus and G.711. The browser captures, encodes and plays the audio, so the application doesn’t have to handle raw audio itself. OpenAI recommends WebRTC rather than WebSockets for connecting a browser to its voice models, for more consistent performance.
It can also keep secrets off the page. In OpenAI’s browser setup, the page sends its offer to the application’s own server, which holds the API key, exchanges the offer with OpenAI and returns the answer.
Example: a voice widget asks for the microphone, creates an offer, sends it to its server, receives the voice service’s answer and starts streaming audio both ways once ICE has found a path.
How does Kawl Now use WebRTC?
Every Kawl Now call runs over WebRTC. When a visitor starts a call, the widget asks for the microphone with echo cancellation and noise suppression requested, creates an SDP offer and sends it to Kawl Now’s server, which exchanges it with OpenAI and returns the answer. The OpenAI API key never reaches the browser.
Audio then travels directly between the visitor’s browser and OpenAI. The call’s data channel is configured to carry no events in either direction, so transcripts and tool calls travel over a separate server-side connection instead.
Calls need HTTPS and a browser with microphone and WebRTC support. Without them, the widget says “Calling needs HTTPS and a browser with microphone support.” Kawl Now saves a text transcript of each call, not the audio.
Common questions
Is WebRTC secure?
WebRTC encrypts media and data by design: the IETF standard requires SRTP for audio and video and DTLS for data channels, and browsers ask permission before a page can use the microphone or camera. The application around it still needs its own controls, such as deciding who may start a call.
Does WebRTC need a server?
Usually. Two browsers can exchange media directly, but they need a signalling server to swap offers and answers, and often STUN or TURN servers to get through firewalls. A voice agent adds a media server or AI service as the other end of the call.