dzei2234
10/02/2025, 7:28 PMAI Evy
10/02/2025, 7:28 PMAI Evy
10/02/2025, 7:29 PM<script> tag .
To set up the chat widget, you need :
- A chat agent created using the Create Chat Agent guide
- Your Retell Public Key
- Your Retell agent ID (chat agent)
Add this script tag to your HTML within the <head> tag :
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_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>
The widget uses the Retell public key system, allowing direct API calls from the frontend with no backend proxy required [(1) ]() [(2) ]() .AI Evy
10/02/2025, 7:29 PMAI Evy
10/02/2025, 7:29 PMdzei2234
10/02/2025, 7:36 PMAI Evy
10/02/2025, 7:36 PMAI Evy
10/02/2025, 7:36 PMjavascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const chatResponse = await client.chat.createSMSChat({
from_number: '+12137771234',
to_number: '+14155551234',
}) ;
console.log(chatResponse.agent_id) ;
The API requires these key parameters :
- `from_number`: The phone number to send SMS from in E.164 format (must be a Retell number with SMS capability)
- `to_number`: The phone number to send SMS to in E.164 format
You can also include optional parameters like :
- `override_agent_id`: Override the agent used for this particular chat
- `metadata`: Store arbitrary data associated with the chat
- `retell_llm_dynamic_variables`: Add dynamic variables for personalization
The SMS functionality works with phone numbers that have SMS enabled, and currently only Retell Twilio numbers can enable SMS [(2) ]() . You'll need to enable SMS capability for your phone number first by following the [Enable SMS guide](/deploy/enable-sms) [(3) ]() .AI Evy
10/02/2025, 7:36 PMAI Evy
10/02/2025, 7:36 PMdzei2234
10/02/2025, 7:48 PMAI Evy
10/02/2025, 7:48 PMAI Evy
10/02/2025, 7:49 PMAI Evy
10/02/2025, 7:49 PMjavascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const chatResponse = await client.chat.createSMSChat({
from_number: '+12137771234',
to_number: '+14155551234',
}) ;
console.log(chatResponse.agent_id) ;
The API endpoint is POST /create-sms-chat . The required parameters are:
- `from_number`: The phone number to send SMS from in E.164 format (must be a number purchased from Retell or imported to Retell with SMS capability)
- `to_number`: The phone number to send SMS to in E.164 format
Optional parameters include:
- `override_agent_id`: Override the agent used for this particular chat
- `override_agent_version`: Override the agent version used
- `metadata`: An arbitrary object for storage purposes
- `retell_llm_dynamic_variables`: Add optional dynamic variables in key value pairs
The API will return a response containing the chat_id, agent_id, chat_status, and other details about the SMS chat session .AI Evy
10/02/2025, 7:49 PMdzei2234
10/02/2025, 8:03 PMAI Evy
10/02/2025, 8:03 PMAI Evy
10/02/2025, 8:03 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"
></script>
3. Verify Agent Type
Chat agents are different from voice agents [(2) ]() . If you converted a voice agent to a chat agent, note that voice-specific functions like call transfers and DTMF are automatically removed during conversion .
4. Test Chat Widget
The documentation mentions testing functionality, though specific testing steps aren't detailed in the available sources [(1) ]() .
5. Check reCAPTCHA Configuration
If you're using reCAPTCHA protection, ensure you've included the Google reCAPTCHA v3 script and enabled reCAPTCHA protection for your public key .
One Discord user mentioned having similar issues with the chat widget not working [(3) ]() , suggesting this is a known issue that others have experienced.
If these steps don't resolve the issue, I'd recommend checking the browser console for any JavaScript errors or visiting [Contact Sales]() for additional support.AI Evy
10/02/2025, 8:04 PMAI Evy
10/02/2025, 8:04 PM