https://retellai.com/?utm_source=discord&utm_medium=seo logo
The widget cannot initialize due to a persistent U...
# ❓・ai-evy-support
r
@AI Evy The widget cannot initialize due to a persistent Uncaught SyntaxError: Unexpected token '<' when adding the embed code to the footer of an Astra-based WordPress site. Do you have a recommended method or a dedicated WordPress plugin for embedding the Webcall widget that is known to work reliably with the Astra theme?
a
Thanks for tagging me @robotshelper_99260_17584. I'll look through relevant sources and get back to you shortly.
### Answer The
Uncaught SyntaxError: Unexpected token '<'
error typically occurs when the script tag is not being interpreted correctly by WordPress, often due to how the theme or page builder processes HTML. Based on the available sources, the Retell chat widget should be embedded by adding the script tag within the
<head>
tag of your HTML [(1) ]() . The correct embed code format is:
Copy code
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"
></script>
For WordPress implementations, particularly with themes like Astra, here are key troubleshooting steps: Ensure proper domain whitelisting: Your domain must be added to the allowed domains list for your public key [(2) ]() . If using a subdomain or specific path, whitelist the exact domain where the widget is embedded [(3) ]() . Avoid placing in footer if possible: The documentation specifies the script should go in the
<head>
tag [(1) ]() . If your theme forces footer placement, the script may load after other JavaScript executes, causing initialization issues. Check for WordPress HTML sanitization: WordPress often strips or modifies script tags when added through certain theme customizers or page builders [(4) ]() . Consider adding the script through: - Theme's
functions.php
using
wp_head
action hook - A dedicated header/footer plugin - Direct theme file editing (header.php) Verify API key security: Ensure your API key is properly protected and not exposed in client-side code . Public keys are safe for frontend use [(2) ]() , but API keys should never be in client-side code. The available sources don't mention a dedicated WordPress plugin for Retell widget embedding. The standard approach is using the embed script tag in the site's
<head>
section [(1) ]() .
​ To learn more, see the sources I considered: [[1] Retell Website Widget](https://docs.retellai.com/deploy/chat-widget) [[2] Public Keys](https://docs.retellai.com/accounts/public-keys) [[3] Chat bot not responding](https://discord.com/channels/1186424376300679209/1384593638499160124) [[4] Adding agent to website](https://discord.com/channels/1186424376300679209/1311977657889587291) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.