https://retellai.com/?utm_source=discord&utm_medium=seo logo
<@1145576664366055464> Hi! We’re building a brows...
# ❓・ai-evy-support
h
@AI Evy Hi! We’re building a browser-based async voice interview experience using the Retell Web SDK. Once a user lands on our page (served via Cloudflare Pages), we extract an ntid param from the URL, look up metadata via a Make.com webhook (deal name, contact info, etc), and then want to create a web-call using your create-web-call endpoint and immediately connect the user using the browser SDK. What are the best practices for initializing and joining a create-web-call session via the Web SDK after the metadata is returned from the webhook? Specifically: Should we create the call on page load or only after a user clicks? How do we safely pass metadata into the create-web-call and use it to pre-fill the SDK experience? What’s the ideal sequencing between the create-web-call POST and RetellWebSDK.start()? We’re not using phone calls — this is entirely browser-based. Thanks!
a
Thanks for tagging me @hotfudge99. I'll look through relevant sources and get back to you shortly.
### Answer For your browser-based voice interview experience, here's the recommended approach based on the documentation: ## Call Creation Timing Create the call after user interaction rather than on page load [(1) ]() . The access token obtained from create-web-call has a 30-second timeout - if you don't start the call within 30 seconds, it will be invalidated and marked with error . ## Passing Metadata Safely You can safely pass metadata through the
metadata
field and dynamic variables through
retell_llm_dynamic_variables
in the create-web-call request [(2) ]() :
Copy code
javascript
const webCallResponse = await client.call.createWebCall({ 
  agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
  metadata: {
    // Your interview metadata here
    deal_name: "Interview Session",
    contact_info: "user@example.com"
  },
  retell_llm_dynamic_variables: {
    customer_name: "John Doe"
  }
}) ;
## Ideal Sequencing 1. **Server-side**: Call your backend endpoint which internally calls create-web-call to get the access token [(1) ]() 2. **Client-side**: Initialize the RetellWebClient :
Copy code
javascript
import { RetellWebClient } from "retell-client-js-sdk";
const retellWebClient = new RetellWebClient() ;
3. Start the call immediately after receiving the access token :
Copy code
javascript
await retellWebClient.startCall({
  accessToken: createCallResponse.access_token,
}) ;
## Additional Configuration Options You can configure sample rate, audio devices, and other options when starting the call :
Copy code
javascript
await retellWebClient.startCall({
  accessToken: createCallResponse.access_token,
  sampleRate: 24000,
  captureDeviceId: "default",
  playbackDeviceId: "default",
  emitRawAudioSamples: false,
}) ;
The key is keeping the time between create-web-call and startCall() as short as possible due to the 30-second token expiration .
​ To learn more, see the sources I considered: [[1] Connect to web call](https://docs.retellai.com/deploy/web-call) [[2] Create Web Call](https://docs.retellai.com/api-references/create-web-call) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.