WebRTC
The WebRTC API lets you build your own voice interfaces — custom widgets, embedded chat buttons, mobile apps — using Truedy agents as the AI backend. Your frontend connects directly to the call over WebSocket; there is no phone number or telephony involved.How it works
Start a WebRTC Call
Starts a WebRTC session against one of your agents and returns ajoinUrl. Pass this URL to the Ultravox client SDK to connect audio from the browser or native app.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
agent_id | string (UUID) | Yes | The Truedy agent to connect to. Must belong to your organisation and be active. |
variables | object | No | Key-value pairs for mustache template substitution in the agent’s prompt (e.g. {{first_name}}). |
200 OK
| Field | Type | Description |
|---|---|---|
joinUrl | string | WebSocket URL — pass directly to the Ultravox SDK |
callId | string | Ultravox call identifier (useful for debugging) |
agentName | string | Display name of the agent |
| Status | Meaning |
|---|---|
401 | Missing or invalid API key, or agent belongs to a different organisation |
404 | Agent not found, not active, or not yet synced to Ultravox |
429 | Rate limit exceeded for your API key |
502 | Ultravox communication error (retry is safe) |
Connecting with the Ultravox SDK
Install the SDK:joinUrl is single-use and expires after a short window — connect immediately after receiving it.
Transcript and state events
When connected, the Ultravox SDK emits two real-time data streams you can use to build your UI:| Event | Data | Use case |
|---|---|---|
transcripts | Array of { speaker, text, isFinal } objects | Show live captions |
status | UltravoxSessionStatus enum | Show call state (connecting, idle, listening, thinking, speaking, ended) |
Template variables
Usevariables to personalise the agent’s behaviour per-call without changing the agent’s prompt. Any {{placeholder}} in the agent’s instructions is substituted at call time:
Agent prompt (configured in Truedy dashboard):
{{placeholders}}.
Security note
ThejoinUrl grants direct access to a live AI call. Always create it server-side — never expose your Truedy API key to the browser. Your backend fetches the joinUrl and returns it to your frontend; your frontend only ever sees the wss:// URL.

