How it works
The SDK is served as JavaScript at/public/listen-sdk. When you call AnyReach.listen(...), it injects a hidden iframe into your page and brokers all audio and transcript traffic through it over postMessage. You never handle the LiveKit connection directly.
Load the script
Add the script tag to your page. Point it at your Anyreach host.AnyReach.listen on window.
Get a token
AnyReach.listen requires a url and token, which you mint from the API.
conversations:read_sensitive or conversations:manage scope. Authenticate with Authorization: Bearer <token>; user PATs (pat_) also need X-Anyreach-Org: <organization_id>.
The conversation must be in progress. If it is not active, the endpoint returns 409. If the conversation has no associated LiveKit room, it returns 404.
Start a session
Wire your event handlers first, then callconnect().
1
Create the session
Pass the
url and token from the listener-token response.2
Attach handlers
Register handlers before connecting so you do not miss early events.
3
Connect
connect() returns a promise that resolves once the listener is subscribed. It rejects on error or after a 15-second timeout.4
Enable audio
Browser autoplay policy may suspend audio until a user gesture. Call
startAudio() from a click handler.Session API
AnyReach.listen({ url, token }) returns a session object with these methods.
mute() and unmute() control your local audio output only. They do not affect what the agent or caller hear.Events
Subscribe withsession.on(event, handler).
getState() and the stateChange event report idle, connecting, connected, or disconnected.Full example
Next steps
Live monitoring
Listen to in-progress conversations from the Anyreach dashboard.
Agent Assist overview
See the full set of real-time assist capabilities.

