Skip to main content

Web Voice Testing

Test your Vocobase voice agent directly from a web application using real-time WebRTC audio. This guide covers everything you need to connect your frontend to a voice agent — works with any JavaScript framework or vanilla JS.

How it works

Your web app starts a voice session via the Vocobase API, receives WebRTC credentials, and connects using the open-source Pipecat client SDK. Audio flows in real time — your user speaks, the agent responds.

Install dependencies

For React projects, also install:

Start a session

Call the Vocobase API to create a voice session. The response contains WebRTC credentials you’ll use to connect.
Response:
You can also pass variables in the request body to substitute pre-call values into the agent’s prompt and greeting (see Pre-call Variables).

Error responses

Never expose your API key in client-side code. Proxy the session start call through your own backend — your backend adds the API key, gets the credentials, and returns daily_room_url + daily_token to the browser. The WebRTC connection itself requires no API key.

Connect with vanilla JavaScript

This approach works with any framework — plain JS, Vue, Angular, Svelte, or no framework at all.

Basic connection

Listen to events

End the call

Microphone controls

Aggregating bot responses

RTVIEvent.BotTtsText fires once per TTS chunk, not once per complete response. To build full agent messages, aggregate chunks until the next user turn:

Complete HTML example

A self-contained page you can use to test your integration:

Connect with React

The @pipecat-ai/client-react package provides PipecatClientProvider and PipecatClientAudio — a provider for context and a component that automatically handles bot audio playback (replacing the manual onTrackStarted approach).
PipecatClientAudio renders a hidden <audio> element that plays the agent’s voice. Mount it when connected — it replaces the manual onTrackStarted callback used in the vanilla JS approach.

Events reference


Backend proxy example

Your backend should proxy the session start call to keep the API key server-side.

Receiving the transcript and recording

After the session ends, the platform fires a session.completed webhook to each enabled webhook endpoint containing the transcript, recording URL, credit usage, pre-call variables, and any post-call extraction. The call block is omitted for browser WebRTC sessions because there’s no associated phone call. Configure webhook endpoints with POST /api/v2/config/webhooks; enabled endpoints receive events for both telephony and WebRTC sessions. See Webhook Setup for setup and Webhook Payloads for the full schema. If your stack can’t accept inbound webhooks, poll GET /api/v2/sessions/{session_id} instead — it returns the same fields with a freshly-minted recording URL on each call:

Billing

Voice sessions are billed at 1 credit per 60 seconds, pro-rata by the second. Credits are deducted after the session ends. See Credits & Billing for full details.

Rate limits

Rate limit headers are included on all responses: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, and Retry-After (on 429). See Authentication for full rate limit details.

Troubleshooting

HTTPS is required for microphone access in all browsers except localhost. Your production deployment must use HTTPS.

Next steps

Credits & Billing

Understand how voice sessions consume credits.

Authentication

API key format, rate limits, and error codes.

Webhook Payloads

Receive session.completed events with transcripts and duration.

Quick Start

Create an agent and make your first call.