The Phonely Web SDK lets you add browser-based voice calls to your app without exposing your Phonely API key to the browser.
Your server creates a short-lived web call session with Phonely, then your browser passes that session bundle to the SDK.
Install
Use @phonely-ai/web v0.0.8 or newer.
How It Works
- Your browser asks your backend to start a web call for an agent.
- Your backend calls Phonely with your API key.
- Phonely returns a short-lived session bundle.
- Your backend returns that bundle to your browser.
- The Web SDK uses the bundle to join the call and read the live transcript.
Never send your Phonely API key to the browser. Keep it in your backend only.
Create A Web Call Session
Call this endpoint from your backend.
Request Body
The body is optional. Send {} if you do not need metadata.
Response
Return this object from your backend to your browser.
Backend Example
Browser Example
Live Transcript
When transcript.autoStart is enabled, the SDK reads the transcript using the transcriptUrl and phonelyToken from the session response. Return the session response from your backend unchanged so the SDK can use those fields.
Listen for transcript updates:
Token Expiration
Session tokens are short lived. If a token expires, start a new web call session from your backend.