Skip to main content
This guide walks you from zero to a working “Talk to AI” button on your website using Truedy’s WebRTC API and the Ultravox browser SDK. By the end, a visitor clicks the button, the browser requests microphone access, and they are immediately in a live two-way voice conversation with your agent.

Prerequisites

  • A Truedy account with an active agent
  • Your Truedy API key (Settings → API Keys)
  • Node.js 18+ or Python 3.9+ for the server component
  • A modern browser (Chrome, Edge, Firefox, or Safari 15.4+)
Your Truedy API key must never appear in client-side code. All requests to api.truedy.ai must be made from your server. The browser only receives a short-lived joinUrl.

1

Install the Ultravox client SDK

The Ultravox SDK handles WebRTC negotiation and the audio session in the browser.
If you are not using a bundler, you can load it from a CDN:
2

Create a server endpoint that issues a joinUrl

Your server calls the Truedy API to start a WebRTC session and returns the single-use joinUrl to the browser. The browser never sees your API key.
Set the required environment variables before starting your server:
3

Build the browser page

Create a minimal index.html. This is a complete, self-contained example — no build step required.
index.html
4

Test it

  1. Start your server (node index.js or flask run)
  2. Open http://localhost:3000 in your browser
  3. Click Talk to AI
  4. Accept the microphone permission prompt
  5. Speak — your agent will respond in real time
Open your browser’s developer console to see SDK status events and any errors. The status event cycles through connecting → connected → active on a successful call.

Key concepts

The joinUrl is single-use

Every call to POST /webrtc/call produces a unique joinUrl that can only be joined once. Never cache or reuse it. If a user refreshes the page, your frontend must request a new joinUrl from your server.

API key stays on the server

Your Truedy API key authenticates you to api.truedy.ai. It must only ever exist in server-side code or environment variables — never in HTML, JavaScript files served to the browser, or version control.

Microphone permissions

The Ultravox SDK calls getUserMedia internally when joinCall is invoked. The browser will display a native permission prompt the first time. If the user denies microphone access, joinCall throws an error — handle it gracefully in your UI.

Next steps

Custom UI and live captions

Subscribe to transcript events for real-time captions and build a fully branded call UI.

Template variables

Pass dynamic data into your agent’s prompt at call time using template variables.

Widget builder

Use Truedy’s no-code widget builder to embed a pre-built voice button without writing frontend code.

Production security checklist

Review authentication, rate limiting, and webhook signature verification before going live.