sana_04538
09/16/2025, 11:45 PMAI Evy
09/16/2025, 11:45 PMAI Evy
09/16/2025, 11:45 PMhtml
<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_CHAT_AGENT_ID"
data-agent-version="YOUR_AGENT_VERSION"
data-title="YOUR_CUSTOM_TITLE"
data-logo-url="YOUR_LOGO_URL"
data-color="YOUR_CUSTOM_COLOR"
data-bot-name="YOUR_BOT_NAME"
data-popup-message="YOUR_POPUP_MESSAGE"
data-show-ai-popup="true"
data-show-ai-popup-time="5"
data-auto-open="false"
data-dynamic='{"key": "value"}'
data-recaptcha-key="YOUR_GOOGLE_RECAPTCHA_SITE_KEY"
></script>
Anyone who visits the page where this script is embedded will have access to your agent [(1) ]() [(2) ]() .AI Evy
09/16/2025, 11:45 PMAI Evy
09/16/2025, 11:45 PMsana_04538
09/16/2025, 11:46 PMsana_04538
09/16/2025, 11:47 PMAI Evy
09/16/2025, 11:47 PMAI Evy
09/16/2025, 11:47 PMjavascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const agentResponses = await client.agent.list() ;
console.log(agentResponses) ;
This will return a list of your agents, including their agent IDs. Both the public key and agent ID are required to embed the widget on your site [(1) ]() [(2) ]() .AI Evy
09/16/2025, 11:47 PMAI Evy
09/16/2025, 11:47 PMsana_04538
09/17/2025, 1:40 AMAI Evy
09/17/2025, 1:40 AMAI Evy
09/17/2025, 1:40 AMhtml
<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>
Anyone visiting your site can then request a call, and the agent will handle the phone conversation as a call agent [(1) ]() .AI Evy
09/17/2025, 1:40 AMAI Evy
09/17/2025, 1:40 AMsana_04538
09/17/2025, 1:42 AMAI Evy
09/17/2025, 1:42 AMAI Evy
09/17/2025, 1:43 AMjavascript
await retellWebClient.startCall({
accessToken: createCallResponse.access_token,
sampleRate: 24000, // (Optional) set sample rate of the audio capture and playback
captureDeviceId: "default", // (Optional) device id of the mic
playbackDeviceId: "your_speaker_device_id", // (Optional) device id of the speaker
emitRawAudioSamples: false, // (Optional) emit raw PCM audio
}) ;
You can stop the call with:
javascript
retellWebClient.stopCall() ;
You can also listen to real-time events like call started, call ended, and transcript updates:
javascript
retellWebClient.on("call_started", () => {
console.log("call started") ;
}) ;
retellWebClient.on("call_ended", () => {
console.log("call ended") ;
}) ;
retellWebClient.on("update", (update) => {
// Access real-time transcript via update.transcript
}) ;
Full details and more event handlers are available in the documentation:
[Connect to web call]()
[Create Web Call]()AI Evy
09/17/2025, 1:43 AMAI Evy
09/17/2025, 1:43 AM