luca_00250
08/10/2025, 4:20 AMAI Evy
08/10/2025, 4:20 AMAI Evy
08/10/2025, 4:20 AMAI Evy
08/10/2025, 4:20 AMAI Evy
08/10/2025, 4:20 AMluca_00250
08/19/2025, 10:21 PMluca_00250
08/19/2025, 10:21 PMAI Evy
08/19/2025, 10:21 PMAI Evy
08/19/2025, 10:22 PMnpm install retell-client-js-sdk
Then set up the SDK class :
javascript
import { RetellWebClient } from "retell-client-js-sdk";
const retellWebClient = new RetellWebClient() ;
## Creating and Starting a Call
Your frontend should call your backend endpoint (which you mentioned is working) to get the access token . Then start the call :
javascript
await retellWebClient.startCall({
accessToken: createCallResponse.access_token,
}) ;
You can also configure additional options :
javascript
await retellWebClient.startCall({
accessToken: createCallResponse.access_token,
sampleRate: 24000, // (Optional) set sample rate of the audio capture and playback
// (Optional) device id of the mic.
captureDeviceId: "default",
// (Optional) device id of the speaker
playbackDeviceId: "0ec1807fd0fe6e51b990660ec4e2ebb78sdfcba51e279815d00c423ce03407ff",
// (Optional) Whether to emit "audio" events that contain raw pcm audio bytes represented by Float32Array
emitRawAudioSamples: false,
}) ;
## Essential Event Listeners
Add these event listeners for proper call handling :AI Evy
08/19/2025, 10:22 PMjavascript
retellWebClient.on("call_started", () => {
console.log("call started") ;
}) ;
retellWebClient.on("call_ended", () => {
console.log("call ended") ;
setIsCallActive(false) ;
}) ;
// When agent starts talking for the utterance
// useful for animation
retellWebClient.on("agent_start_talking", () => {
console.log("agent_start_talking") ;
}) ;
// When agent is done talking for the utterance
// useful for animation
retellWebClient.on("agent_stop_talking", () => {
console.log("agent_stop_talking") ;
}) ;
// Real time pcm audio bytes being played back, in format of Float32Array
// only available when emitRawAudioSamples is true
retellWebClient.on("audio", (audio) => {
// console.log(audio) ;
}) ;
// Update message such as transcript
// You can get transcrit with update.transcript
// Please note that transcript only contains last 5 sentences to avoid the payload being too large
retellWebClient.on("update", (update) => {
// console.log(update) ;
}) ;
retellWebClient.on("metadata", (metadata) => {
// console.log(metadata) ;
}) ;
retellWebClient.on("error", (error) => {
console.error("An error occurred:", error) ;
// Stop the call
retellWebClient.stopCall() ;
}) ;
## Stopping the Call
To end the call :
javascript
retellWebClient.stopCall() ;
## Key Implementation Notes
From community discussions, you need the JavaScript SDK for your frontend and ensure your backend can request a call so it can send the call information to the frontend, which then starts the websocket connection with Retell without needing an API key [(2) ]() .
Since your Google Cloud backend is working fine, the issue is likely in the frontend JavaScript implementation or the connection between your frontend call to the backend and the subsequent use of the access token.AI Evy
08/19/2025, 10:22 PMAI Evy
08/19/2025, 10:22 PMAI Evy
08/19/2025, 10:25 PMAI Evy
08/19/2025, 10:25 PMjavascript
// Initialize the client
const retellWebClient = new window.RetellWebClient() ;
// Function to start a call (call this when your button is clicked)
async function startCall() {
// First, call your Google Cloud backend to get the access token
const response = await fetch('YOUR_BACKEND_ENDPOINT') ;
const createCallResponse = await response.json() ;
// Start the call with the access token
await retellWebClient.startCall({
accessToken: createCallResponse.access_token,
sampleRate: 24000, // (Optional) set sample rate of the audio capture and playback
// (Optional) device id of the mic.
captureDeviceId: "default",
// (Optional) device id of the speaker
playbackDeviceId: "0ec1807fd0fe6e51b990660ec4e2ebb78sdfcba51e279815d00c423ce03407ff",
// (Optional) Whether to emit "audio" events that contain raw pcm audio bytes represented by Float32Array
emitRawAudioSamples: false,
}) ;
}
You'll also need to set up the essential event listeners:AI Evy
08/19/2025, 10:25 PMAI Evy
08/19/2025, 10:25 PMjavascript
retellWebClient.on("call_started", () => {
console.log("call started") ;
}) ;
retellWebClient.on("call_ended", () => {
console.log("call ended") ;
setIsCallActive(false) ;
}) ;
// When agent starts talking for the utterance
// useful for animation
retellWebClient.on("agent_start_talking", () => {
console.log("agent_start_talking") ;
}) ;
// When agent is done talking for the utterance
// useful for animation
retellWebClient.on("agent_stop_talking", () => {
console.log("agent_stop_talking") ;
}) ;
// Real time pcm audio bytes being played back, in format of Float32Array
// only available when emitRawAudioSamples is true
retellWebClient.on("audio", (audio) => {
// console.log(audio) ;
}) ;
// Update message such as transcript
// You can get transcrit with update.transcript
// Please note that transcript only contains last 5 sentences to avoid the payload being too large
retellWebClient.on("update", (update) => {
// console.log(update) ;
}) ;
retellWebClient.on("metadata", (metadata) => {
// console.log(metadata) ;
}) ;
retellWebClient.on("error", (error) => {
console.error("An error occurred:", error) ;
// Stop the call
retellWebClient.stopCall() ;
}) ;
To stop the call, use:
javascript
retellWebClient.stopCall() ;
Make sure your website is served over HTTPS, as web calls won't work over HTTP [(2) ]() . Also check your browser console for any permission errors or WebRTC failures .AI Evy
08/19/2025, 10:25 PMluca_00250
08/19/2025, 10:28 PMAI Evy
08/19/2025, 10:28 PMAI Evy
08/19/2025, 10:28 PMjavascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const webCallResponse = await client.call.createWebCall({ agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD' }) ;
console.log(webCallResponse.agent_id) ;
2. Frontend implementation - Your website should then use the access token from the response to start the call.
The response from creating a web call includes the access_token that you'll need for your frontend .
Could you paste your complete current script so I can review it against the official implementation patterns?AI Evy
08/19/2025, 10:28 PMAI Evy
08/19/2025, 10:29 PMluca_00250
08/19/2025, 10:31 PMAI Evy
08/19/2025, 10:31 PMAI Evy
08/19/2025, 10:32 PMjavascript
import { RetellWebClient } from "retell-client-js-sdk";
const retellWebClient = new RetellWebClient() ;
Step 2: Call your backend to create web call and get access token
Your backend should call the create web call API [(2) ]() :
javascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const webCallResponse = await client.call.createWebCall({ agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD' }) ;
console.log(webCallResponse.agent_id) ;
Step 3: Start the call on frontend [(1) ]()
javascript
await retellWebClient.startCall({
accessToken: createCallResponse.access_token,
}) ;
Step 4: Set up event listeners
javascript
retellWebClient.on("call_started", () => {
console.log("call started") ;
}) ;
retellWebClient.on("call_ended", () => {
console.log("call ended") ;
setIsCallActive(false) ;
}) ;
retellWebClient.on("agent_start_talking", () => {
console.log("agent_start_talking") ;
}) ;
retellWebClient.on("agent_stop_talking", () => {
console.log("agent_stop_talking") ;
}) ;
retellWebClient.on("update", (update) => {
// console.log(update) ;
}) ;
retellWebClient.on("error", (error) => {
console.error("An error occurred:", error) ;
retellWebClient.stopCall() ;
}) ;
Step 5: Stop the call
javascript
retellWebClient.stopCall() ;
Please share your current script so I can identify any issues with your implementation.AI Evy
08/19/2025, 10:32 PMAI Evy
08/19/2025, 10:32 PMluca_00250
08/19/2025, 10:40 PMluca_00250
08/19/2025, 10:40 PMAI Evy
08/19/2025, 10:40 PMAI Evy
08/19/2025, 10:41 PMjavascript
import { RetellWebClient } from "retell-client-js-sdk";
const retellWebClient = new RetellWebClient() ;
Backend Call Creation:
javascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const webCallResponse = await client.call.createWebCall({ agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD' }) ;
console.log(webCallResponse.agent_id) ;
[(2) ]()
Start the Call:
javascript
await retellWebClient.startCall({
accessToken: createCallResponse.access_token,
}) ;
[(1) ]()
Event Listeners:
javascript
retellWebClient.on("call_started", () => {
console.log("call started") ;
}) ;
retellWebClient.on("call_ended", () => {
console.log("call ended") ;
setIsCallActive(false) ;
}) ;
retellWebClient.on("agent_start_talking", () => {
console.log("agent_start_talking") ;
}) ;
retellWebClient.on("agent_stop_talking", () => {
console.log("agent_stop_talking") ;
}) ;
retellWebClient.on("update", (update) => {
// console.log(update) ;
}) ;
retellWebClient.on("metadata", (metadata) => {
// console.log(metadata) ;
}) ;
retellWebClient.on("error", (error) => {
console.error("An error occurred:", error) ;
// Stop the call
retellWebClient.stopCall() ;
}) ;
Please share your script so I can identify any specific issues with your implementation.AI Evy
08/19/2025, 10:41 PMAI Evy
08/19/2025, 10:41 PMluca_00250
08/19/2025, 11:01 PMAI Evy
08/19/2025, 11:01 PMAI Evy
08/19/2025, 11:01 PMjavascript
import { RetellWebClient } from "retell-client-js-sdk";
const retellWebClient = new RetellWebClient() ;
Backend Call Creation:
javascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const webCallResponse = await client.call.createWebCall({ agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD' }) ;
console.log(webCallResponse.agent_id) ;
[(2) ]()
Start the Call:
javascript
await retellWebClient.startCall({
accessToken: createCallResponse.access_token,
}) ;
[(1) ]()
Essential Event Listeners:
javascript
retellWebClient.on("call_started", () => {
console.log("call started") ;
}) ;
retellWebClient.on("call_ended", () => {
console.log("call ended") ;
setIsCallActive(false) ;
}) ;
retellWebClient.on("agent_start_talking", () => {
console.log("agent_start_talking") ;
}) ;
retellWebClient.on("agent_stop_talking", () => {
console.log("agent_stop_talking") ;
}) ;
retellWebClient.on("update", (update) => {
// console.log(update) ;
}) ;
retellWebClient.on("metadata", (metadata) => {
// console.log(metadata) ;
}) ;
retellWebClient.on("error", (error) => {
console.error("An error occurred:", error) ;
// Stop the call
retellWebClient.stopCall() ;
}) ;
Please paste your current script so I can identify any specific issues with your implementation.AI Evy
08/19/2025, 11:01 PMAI Evy
08/19/2025, 11:01 PM