murphsmurf23
11/02/2025, 5:42 PMAI Evy
11/02/2025, 5:42 PMAI Evy
11/02/2025, 5:43 PM<head> section [(1) ]() :
html
<script
id="retell-widget"
src="<https://dashboard.retellai.com/retell-widget.js%22>
type="module"
data-public-key="YOUR_RETELL_PUBLIC_KEY"
data-agent-id="YOUR_RETELL_CHAT_AGENT_ID"
data-agent-version="0"
data-title="YOUR_CUSTOM_TITLE"
></script>
Important note: The chat widget is designed for chat agents, not voice agents [(1) ]() [(2) ]() . If you want to deploy a voice agent as a chat experience, you'll need to convert your voice agent to a chat agent first [(2) ]() .
What you'll need:
- Your Retell Public Key (create one in Dashboard → Keys → Public Keys) [(3) ]() [(4) ]()
- Your Chat Agent ID [(1) ]() [(2) ]()
- Agent version (optional, defaults to latest if not specified) [(1) ]()
You can customize the widget with optional attributes like data-title, data-logo-url, and data-color [(1) ]() [(5) ]() .AI Evy
11/02/2025, 5:43 PMAI Evy
11/02/2025, 5:43 PMmurphsmurf23
11/02/2025, 5:48 PMmurphsmurf23
11/02/2025, 5:49 PMAI Evy
11/02/2025, 5:49 PMAI Evy
11/02/2025, 5:49 PMAI Evy
11/02/2025, 5:49 PMAI Evy
11/02/2025, 5:49 PMmurphsmurf23
11/03/2025, 1:52 AMAI Evy
11/03/2025, 1:52 AMAI Evy
11/03/2025, 1:53 AMAI Evy
11/03/2025, 1:53 AMAI Evy
11/03/2025, 1:53 AMmurphsmurf23
11/03/2025, 1:57 AMAI Evy
11/03/2025, 1:57 AMAI Evy
11/03/2025, 1:58 AMbash
npm install retell-client-js-sdk
Step 2: Set up the SDK class
javascript
import { RetellWebClient } from "retell-client-js-sdk";
const retellWebClient = new RetellWebClient() ;
Step 3: Get an access token from your server
Your client code should call your server endpoint, which internally calls the create web call API to get the access token [(1) ]() [(2) ]() . The endpoint requires your Retell API Key, so this must be done server-side to protect the key [(1) ]() . The access token must be used within 30 seconds or it will be invalidated .
Step 4: Start the call
javascript
await retellWebClient.startCall({
accessToken: createCallResponse.access_token,
}) ;
You can also configure optional settings :
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,
}) ;
Step 5: Stop the call
javascript
retellWebClient.stopCall() ;
Step 6: Listen to events
The SDK emits real-time events for call status, transcripts, and agent speaking state :AI Evy
11/03/2025, 1:58 AMjavascript
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() ;
}) ;
For audio format details, PCM audio is used with Float32Array representation for web environments [(3) ]() .
**AI Evy
11/03/2025, 1:58 AMAI Evy
11/03/2025, 1:58 AMAI Evy
11/05/2025, 2:49 AMmurphsmurf23
11/05/2025, 2:49 AMAI Evy
11/05/2025, 2:49 AMapi.retellai.com reported by other users [(1) ]() .
Correct API Endpoint
The correct base URL for creating web calls is ` (not api.retell.ai as you mentioned) [(2) ]() . The endpoint should be:
POST <https://api.retellai.com/v2/create-web-call>
DNS Issue Context
A community member reported similar DNS resolution problems with api.retellai.com from Turkey, experiencing issues where the domain could not be resolved [(1) ]() . This suggests there may be regional or network-specific DNS propagation issues.
Recommendations
1. **Verify the correct domain**: Ensure you're using api.retellai.com (not api.retell.ai)
2. **Check your API request format**: The create web call endpoint requires proper authentication headers [(2) ]()
3. **Test DNS resolution**: Try resolving api.retellai.com directly from your server environments
For Further Support
Since this appears to be an infrastructure/DNS issue affecting multiple users and networks, I recommend:
- Visit [Contact Sales]()
- Visit [)
The Retell team can confirm the current DNS/hosting status, provide alternative endpoints if available, and advise on any allowlist requirements for Cloudflare Workers.AI Evy
11/05/2025, 2:50 AMAI Evy
11/05/2025, 2:50 AMmurphsmurf23
11/09/2025, 3:19 PMAI Evy
11/09/2025, 3:19 PMAI Evy
11/09/2025, 3:19 PMhtml
<script
id="retell-widget"
src="<https://dashboard.retellai.com/retell-widget.js%22>
data-public-key="YOUR_RETELL_PUBLIC_KEY"
data-agent-id="YOUR_VOICE_AGENT_ID"
data-widget="callback"
data-phone-number="YOUR_RETELL_PHONE_NUMBER"
data-title="Request a Call"
data-countries="US,CA,GB"
data-tc="<https://yoursite.com/terms%22>
data-color="#FFA07A"
data-recaptcha-key="YOUR_GOOGLE_RECAPTCHA_SITE_KEY"
></script>
Required:
- data-public-key (your Retell public key)
- data-agent-id (your voice agent ID)
- data-widget="callback"
- data-phone-number (your Retell phone number)
Optional (but often included) :
- data-title
- data-color
- data-countries
- data-tc
- data-recaptcha-key [(4) ]()
3) For the callback widget, you do not need a separate token server. The standard dashboard embed is sufficient. Just configure the script tag with the correct attributes as above. reCAPTCHA protection is optional but recommended and can be enabled by adding the data-recaptcha-key attribute and the Google reCAPTCHA script .AI Evy
11/09/2025, 3:19 PMAI Evy
11/09/2025, 3:19 PMmurphsmurf23
11/09/2025, 4:47 PMAI Evy
11/09/2025, 4:47 PMAI Evy
11/09/2025, 4:47 PMdata-public-key (your Retell public key)
- data-agent-id (your voice agent ID)
- data-widget="callback"
- data-phone-number (your Retell phone number)
Optional attributes:
- data-title, data-color, data-countries, data-tc, data-recaptcha-key
4. Configure reCAPTCHA (optional but recommended) :
- Add the Google reCAPTCHA v3 script to your <head> and the data-recaptcha-key attribute for bot protection .
5. How it works:
- The widget collects user info and, when submitted, triggers your AI voice agent to call the client’s phone. The agent can then answer questions and schedule appointments as configured in your agent flow [(1) ]() [(2) ]() .
Note: The voice conversation happens over the phone, not directly in the browser. If you require direct web-based voice calls (WebRTC) , you would use the Web SDK instead, which is a different integration path [(3) ]() .
For more details, see:
- [Retell Website Widget]()
- [AI Voice Agent]()
- [Audio Basics]()AI Evy
11/09/2025, 4:47 PM<head> of your website's HTML. Replace the placeholder values with your actual credentials:
html
<script
id="retell-widget"
src="<https://dashboard.retellai.com/retell-widget.js%22>
type="module"
data-public-key="YOUR_RETELL_PUBLIC_KEY"
data-agent-id="YOUR_VOICE_AGENT_ID"
data-widget="callback"
data-phone-number="YOUR_RETELL_PHONE_NUMBER"
data-title="Request a Call"
data-countries="US,CA,GB"
data-tc="<https://yoursite.com/terms%22>
data-color="#FFA07A"
data-recaptcha-key="YOUR_GOOGLE_RECAPTCHA_SITE_KEY"
></script>AI Evy
11/09/2025, 4:48 PMAI Evy
11/09/2025, 4:48 PMmurphsmurf23
11/09/2025, 4:49 PMmurphsmurf23
11/09/2025, 4:49 PMAI Evy
11/09/2025, 4:49 PMAI Evy
11/09/2025, 4:49 PMAI Evy
11/09/2025, 4:49 PMAI Evy
11/09/2025, 4:49 PM