Web Call
A step by step guide to create a web call with agent using frontend Web SDK
Set up the SDK
Step 1: Install the Retell Web SDK
npm install retell-client-js-sdk
Step 2: Set up the SDK class
Call create-web-call
to get call id
Your client code should call your server endpoint which internally calls create web call to get the access token for the call. The endpoint requires using your Retell API Key, which is the reason why you need to call the endpoint from the server instead of client to protect the key from exposing.
The access token obtained will be used in your frontend client code to start the call.
Start the Call
Once call starts, you can listen to a couple events that’s emitted for real time updates about the call.
There are other optional options that allow you to set the sample rate of call, audio capture and playback device, whether to receive raw audio bytes from the client.
Stop the Call
You can close a web call with the agent by using
Listen to events
You can listen to events emitted by the SDK to get real time updates about the call, including who is speaking, the real time transcript, start and end of the call.
Audio Basics
If you have not worked with audio bytes before, we stronly suggest you to check out audio basics, which can help with choosing the best configuration here.
PCM audio format conversion functions convertUnsigned8ToFloat32
and
convertFloat32ToUnsigned8
can be found in
audio basics.
Was this page helpful?