Before you start
- A voice Pearl that is active. The call runs its published version.
- Its Pearl ID: on your Pearl’s overview page, in the Settings popover.
- An API key, or an OAuth app with the
pearls:websocketscope (Make Realtime API calls in the platform). See API Authorization. - One of the two audio formats, the same in both directions:
Connect
1
Create the call
From your backend, call Create Call. It returns the
url to open and a ticket valid for 60 seconds.endUserId is your own id for the person on the call, such as a customer id: send the same value for the same person every time.2
Open the WebSocket
Open the
url with the ticket, within 60 seconds. Pearl sends ready, then you stream.Stream audio
- Audio is binary, in both directions: raw bytes in the call’s format, with no base64 and no JSON.
- Send one 20 ms frame every 20 ms, in real time, for the whole call. When the end user is quiet or muted, send silence, not nothing.
- Pearl sends one 20 ms frame every 20 ms too, with silence while it listens. Play the frames through a small jitter buffer of 60 to 100 ms.
- Interruptions need no code. When the end user talks over Pearl, it stops speaking and the next frames are already silence: there is nothing to clear on your side.
Events
Text messages are JSON events. Pearl sends three:
To hang up, send
{"type":"hangup"}. After the call, the call history and the webhooks show it with channel: "websocket".
Errors and limits
A message is at most 16 KB. Stream Call has every message, end reason and limit.
Examples
Quickstart
Talk to your Pearl from your terminal, with your microphone.
Browser App
A web page with the microphone and Pearl’s voice.

