WebRTC Channel
Create a WebRTC Channel, request a connection token from your backend, and connect your browser or app to the Assistant with a LiveKit client.
How it works
A WebRTC Channel is the routing configuration that connects browser or app-based clients to your Assistant. The Calls API generates a room-scoped token with Assistant dispatch configuration; LiveKit creates the room when the client connects.
Unlike SIP Channels, WebRTC Channels don't require whitelist configuration since authentication is handled through tokens.
Call flow
For each connection:
- Client requests a connection token from the Calls API, providing the Channel ID
- Calls API validates the WebRTC Channel and its Assistant, then generates a token for a new room
- Client receives the WebSocket URL and access token
- Client connects to LiveKit using the provided credentials
- Assistant receives the connection and begins the conversation
Creating a WebRTC Channel
Required fields
| Field | Required | Description |
|---|---|---|
name | Yes | Display name for the Channel |
type | Yes | Must be WEBRTC for WebRTC Channels |
assistantId | Yes | The Assistant to handle calls on this Channel |
Create request
Use a project-scoped API key, or include projectId in the payload with an organization-scoped key. Data API paths below are relative to the server URL in the API reference, which includes /data_next. The Calls API uses /calls/{channelId} separately.
Code
Response
Code
Connecting with LiveKit client
Request a token from your backend, then pass the returned wsUrl and token to a LiveKit client. Keep the Reecall API key on your backend.
Step 1: obtain connection token
From your backend, request a token for the WebRTC Channel:
Code
Response:
Code
Step 2: connect to LiveKit
The examples below show the connection code for JavaScript, Python, and React. Install the matching LiveKit client SDK and use the wsUrl and token returned in Step 1. These are integration fragments, so supply those values in your application.
For JavaScript, call startCall from a user action, such as clicking a Start call button. If the browser blocks playback, offer an Enable audio button that calls room.startAudio(). For React, provide an audio-unlock control such as LiveKit's StartAudio component.
The JavaScript and React examples capture microphone audio. The Python example creates an audio source only. Feed microphone or other PCM frames into it and consume the incoming audio stream in your application.
Code
Code
Code
Constraints
-
An Assistant can have one WebRTC Channel and one SIP Channel. Creating a second Channel of the same type for that Assistant returns an error.
-
Browser permissions: In a browser environment, users must grant microphone access for audio capture. Make sure to handle permission denials gracefully in your UI.
-
Token expiry: Connection tokens have a one hour lifetime. If a connection fails, request a new token before retrying.