https://retellai.com/?utm_source=discord&utm_medium=seo logo
How do I fix this issue: I need on my website a bu...
# ❓・ai-evy-support
l
@AI Evy How do I fix this issue: I need on my website a button that demos a live webcall to a Retell agent, so have set up the agent, purchased a Twilio number, created a Google Cloud server, but am stuck...
a
Thanks for tagging me @luca_00250. I'll look through relevant sources and get back to you shortly.
### Answer Based on the available sources, I don't have specific documentation about setting up web call demos on websites or integrating with Google Cloud servers for this purpose. However, I can see that Retell AI supports web calls and has a Web-SDK mentioned in the knowledge base. The sources reference a Frontend SDK with events that are helpful for web call implementations [(1) ]() . For your specific setup with a Twilio number and Google Cloud server integration, you'll need more detailed implementation guidance than what's available in these sources. I'd recommend checking out these potentially helpful resources: - [Custom Telephony Overview]() for telephony integration details [(2) ]() - [Building AI Agents: The Ultimate Guide for Non-Programmers]() for general setup guidance [(3) ]() For specific web call implementation and Google Cloud server integration, you may want to: - Visit [Contact Sales]() - Visit [) Would you like me to provide a general answer about web call implementations based on my knowledge instead?
​ To learn more, see the sources I considered: [[1] Platform Changelogs | Retell AI](https://www.retellai.com/changelog) [[2] Custom Telephony Overview](https://docs.retellai.com/deploy/custom-telephony) [[3] Building AI Agents: The Ultimate Guide for Non-Programmers | Retell AI](https://www.retellai.com/blog/how-to-build-ai-agents-for-beginners) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
l
I cannnot get a Web Call (NOT web chat..!) working on the homepage of my website... and have gone round and round in circles together with Claude, ChatGPT 5, and Gemini, as well as Retell AI documentation... Who can help me with this: the back-end servicer (Google Cloud) works fine, it's the front-end on the website that's giving me a headache...
@AI Evy I cannnot get a Web Call (NOT web chat..!) working on the homepage of my website... and have gone round and round in circles together with Claude, ChatGPT 5, and Gemini, as well as Retell AI documentation... Who can help me with this: the back-end servicer (Google Cloud) works fine, it's the front-end on the website that's giving me a headache...
a
Thanks for the follow-up, @luca_00250. I'll get back to you soon.
### Answer Based on the documentation, here's the complete frontend implementation for web calls on your website: ## Frontend Setup First, install the Retell Web SDK [(1) ]() :
Copy code
npm install retell-client-js-sdk
Then set up the SDK class :
Copy code
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 :
Copy code
javascript
await retellWebClient.startCall({
 accessToken: createCallResponse.access_token,
}) ;
You can also configure additional options :
Copy code
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 :
Copy code
javascript
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 :
Copy code
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.
​ To learn more, see the sources I considered: [[1] Connect to web call](https://docs.retellai.com/deploy/web-call) [[2] Discord message from @azuremis on 2024-10-14](https://discord.com/channels/1186424376300679209/1186462578310910112/1295323075679617095) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
l
@AI Evy I have this in the HTML script of the webpage: import { RetellWebClient } from "https://esm.sh/retell-client-js-sdk@2.0.7?bundle"; window.RetellWebClient = RetellWebClient;
a
Thanks for the follow-up, @luca_00250. I'll get back to you soon.
### Answer Your HTML import looks correct for using the Retell Web Client with a CDN approach [(1) ]() . Now you need to initialize the client and set up the call functionality. After your import script, you'll need to add the implementation:
Copy code
javascript
// 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:
​ To learn more, see the sources I considered: [[1] Connect to web call](https://docs.retellai.com/deploy/web-call) [[2] Web Widget Troubles](https://discord.com/channels/1186424376300679209/1401960246859010088) ​
Copy code
javascript
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:
Copy code
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 .
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
l
a
Thanks for the follow-up, @luca_00250. I'll get back to you soon.
### Answer I'd be happy to review your script, but I don't see the complete script in your message. Could you share the full JavaScript code you're currently using? Based on the Retell AI documentation, for web calls you'll need to create a web call first using the API to get an access token [(1) ]() . The process involves: 1. Backend call to create web call - Your Google Cloud server should call:
Copy code
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. 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?
​ To learn more, see the sources I considered: [[1] 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.
a
Thanks for the follow-up, @luca_00250. I'll get back to you soon.
### Answer I don't see the script in your message. Could you paste your complete current JavaScript code so I can review it? In the meantime, here's what your complete web call implementation should look like based on the official documentation [(1) ]() : Step 1: Install and set up the SDK
Copy code
javascript
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) ]() :
Copy code
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) ]()
Copy code
javascript
await retellWebClient.startCall({
 accessToken: createCallResponse.access_token,
}) ;
Step 4: Set up event listeners
Copy code
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
Copy code
javascript
retellWebClient.stopCall() ;
Please share your current script so I can identify any issues with your implementation.
​ 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.
a
Thanks for the follow-up, @luca_00250. I'll get back to you soon.
### Answer I don't see the script in your message. Could you paste your complete JavaScript code? Once you share it, I can review it against the official Retell AI web call implementation. Based on the documentation, here's the correct structure you should have [(1) ]() : Frontend Setup:
Copy code
javascript
import { RetellWebClient } from "retell-client-js-sdk";
const retellWebClient = new RetellWebClient() ;
Backend Call Creation:
Copy code
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:
Copy code
javascript
await retellWebClient.startCall({
 accessToken: createCallResponse.access_token,
}) ;
[(1) ]() Event Listeners:
Copy code
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.
​ 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.
a
Thanks for the follow-up, @luca_00250. I'll get back to you soon.
### Answer I don't see the script code in your message. Could you paste the complete JavaScript code you're working with? Once you share it, I can review it against the official Retell AI implementation. Here's what your complete web call setup should include based on the documentation [(1) ]() : SDK Setup:
Copy code
javascript
import { RetellWebClient } from "retell-client-js-sdk";
const retellWebClient = new RetellWebClient() ;
Backend Call Creation:
Copy code
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:
Copy code
javascript
await retellWebClient.startCall({
 accessToken: createCallResponse.access_token,
}) ;
[(1) ]() Essential Event Listeners:
Copy code
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.
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
​ 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) ​