hotfudge99
08/13/2025, 2:47 PMAI Evy
08/13/2025, 2:47 PMAI Evy
08/13/2025, 2:47 PMretellWebClient.startCall()
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,
}) ;
## Metadata Best Practices
For deal-specific metadata, use the metadata and retell_llm_dynamic_variables fields when creating the web call [(2) ]() :
- `metadata`: Store arbitrary data like your internal customer ID for later retrieval
- `retell_llm_dynamic_variables`: Inject dynamic variables into your Response Engine prompt and tool descriptions
json
{ "customer_name": "John Doe" }AI Evy
08/13/2025, 2:47 PMagent_id values per client when creating calls . Each agent can have its own configuration, voice settings, and response engine [(3) ]() .
## Error Handling
Implement proper error handling for the web client [(1) ]() :
javascript
retellWebClient.on("error", (error) => {
console.error("An error occurred:", error) ;
// Stop the call
retellWebClient.stopCall() ;
}) ;
## Token Timing Considerations
Based on community discussions, there have been issues with timing between token creation and startCall() [(4) ]() . Ensure minimal delay between receiving the access_token and calling startCall() to avoid connection issues .
For Cloudflare Worker-specific considerations and detailed multi-tenant patterns, I'd recommend checking the [GitHub examples]() or contacting support for implementation guidance specific to your infrastructure.AI Evy
08/13/2025, 2:47 PMAI Evy
08/13/2025, 2:47 PM