Web calls
Run your agent in a browser — voice over WebRTC, or text chat — with the same prompt, tools, and guardrails.
A web call runs your agent in a browser instead of on a phone line. Same agent, same tools, same guardrails. To hear one now, follow the web quickstart; this page explains how it fits together.
Beta — text chat is enabled per workspace. Ask us to turn it on for yours.
How a call starts
Your backend asks us for a token. The browser uses the token to connect directly to us. Your backend creates the call, then stays out of the ongoing audio path.
your backend --(API key)-------> POST /web-calls
<--(token, ws_url)--
your browser --(token)---------> the returned ws_urlYour API key must never reach the browser. Mint the token server-side and send the browser only the token — it authorizes exactly one conversation and nothing else.
Ask for a token, naming the agent and anything the prompt needs:
{
"agent_id": "AGENT_ID",
"variables": {
"user_name": "Ada",
"plan": "premium"
},
"metadata": {
"your_user_id": "u_123"
},
"modality": "audio"
}Over the API: POST /v1/web-calls.
| Field | What it does |
|---|---|
agent_id | Runs the deployed version, unless you pin one with version_id |
variables | Values for the agent's prompt. Up to 50 |
metadata | Values to store on the call record, without adding them to the agent’s prompt. Do not put secrets here |
modality | audio (default) or text |
Authenticate your user and validate context on your backend before minting the token. Variables give the agent context; they do not authorize actions. Enforce access checks in the APIs that perform those actions.
The response gives you a call_id (which works against
GET /calls/{id} right away), a token, and a
ws_url. The token is good for about two minutes to join — it doesn't limit
how long the call runs.
Mint it when the user clicks, not in advance. An unused pending call can hold a concurrency slot until it is cleaned up.
Voice or text
Text chat removes the audio and nothing else:
| Voice | Text | |
|---|---|---|
| Agent, prompt, variables, guardrails | same | same |
| Tools and MCP servers | same | same |
| Transcript, webhooks, extractions | same | same |
| Billing and concurrency | by the minute | the same |
| Who decides a turn ended | speech endpointing | the person pressing Enter |
| Microphone and recording | yes | nothing to record |
A few call actions have no meaning in a chat window — transferring a phone call, keypad input — so they're not offered to the agent at all, rather than left to fail and apologize. Handing off to another agent, ending the conversation, and booking a callback all still work; a callback is often the right escalation when a transfer isn't available.
The agent knows it's writing rather than speaking, so it may use light formatting. Your greeting arrives as the first message.
Guardrails apply to text replies as well as speech. A reply may arrive whole after it has been checked, rather than token by token. Render the final transcript as the source of truth, so the UI works with both streamed and checked replies. See chat events.
Afterwards
A web call is an ordinary call record. The transcript, recording, summary,
extractions, and webhooks all behave as they do for phone calls, and your
metadata comes back on the record so you can join it to your own systems.
The record is marked as a web call, so browser traffic is never counted as phone calls in your analytics.
Using the SDK
@kejue/voice-web handles the connection, agent state, transcript
assembly, and audio routing:
- Voice calls with the SDK — a full voice UI.
- Text chat with the SDK — a chat UI.
- SDK reference — every option, event, and type.
Connecting without the SDK
The SDK is convenience, not a requirement — the contract is the token plus
livekit-client.
import { Room, RoomEvent } from 'livekit-client';
const { token, ws_url } = await fetch('/api/start-call', { method: 'POST' })
.then((r) => r.json());
const room = new Room();
// WebRTC subscribes to the track but never routes it to a speaker —
// attach it, or the call "works" and the user hears silence.
room.on(RoomEvent.TrackSubscribed, (track) => {
if (track.kind === 'audio') document.body.appendChild(track.attach());
});
await room.connect(ws_url, token);
await room.localParticipant.setMicrophoneEnabled(true, undefined, {
preConnectBuffer: true,
});What you take on yourself: reading agent state from the participant attributes (including for an agent that was already in the room before you joined), assembling the transcript from the published snapshots rather than appending them, keeping tool arguments and outputs out of the browser, and all the audio element handling — attaching, autoplay, teardown.