https://retellai.com/?utm_source=discord&utm_medium=seo logo
can I implement a voice agent as a chat widget whe...
# ❓・ai-evy-support
d
@AI Evy can I implement a voice agent as a chat widget where the user clicks on the chat widget in an website and speask with the voice agent natively in the browser?
a
Thanks for tagging me @dzei. I'll look through relevant sources and get back to you shortly.
### Answer Yes, you can implement both voice and chat capabilities in a single widget on your website. [(1) ]() When you provide both
data-agent-id
(for chat) and
data-voice-agent-id
(for voice) in the Retell widget script, it enters hybrid mode. In this mode, users see a chooser screen with "Voice Assistant" and "Chat Assistant" options, and a tab bar at the bottom allows switching between voice and chat at any time. Voice calls use WebRTC for real-time audio with a built-in audio visualizer, enabling native browser-based voice conversations. Here's how to set it up:
Copy code
html
<script
  id="retell-widget"
  src="<https://dashboard.retellai.com/retell-widget-v2.js%22>
  type="module"
  data-public-key="YOUR_RETELL_PUBLIC_KEY"
  data-voice-public-key="YOUR_VOICE_PUBLIC_KEY"
  data-agent-id="YOUR_CHAT_AGENT_ID"
  data-voice-agent-id="YOUR_VOICE_AGENT_ID"
  data-title="How can we help?"
  data-color="#FFA07A"
></script>
At least one of
data-public-key
or
data-voice-public-key
is required. If only
data-voice-agent-id
is set, the widget goes directly to the voice call interface.
​ To learn more, see the sources I considered: [[1] Retell Website Widget](https://docs.retellai.com/deploy/chat-widget) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
d
@AI Evy where can I find the data-voice-public-key="YOUR_VOICE_PUBLIC_KEY" data-voice-agent-id="YOUR_VOICE_AGENT_ID"
a
Thanks for the follow-up, @dzei. I'll get back to you soon.
### Answer \ You can find these values in your Retell AI dashboard: [(1) ]() **data-voice-public-key**: This is your Retell Public Key, which you can find in the [Retell Public Keys settings]() . **data-voice-agent-id**: This is your voice agent ID. You need to create a voice agent first to get this ID. The documentation states you should "Create a voice agent to handle phone conversations" and then use that agent's ID. Before embedding the widget, the prerequisites are: 1. Create a voice agent (this gives you the agent ID) 2. Get your Retell Public Key from your account settings The
data-voice-public-key
is a separate public key specifically for voice/web call API, while
data-public-key
is used for the chat API. At least one of these public keys is required.
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] Retell Website Widget](https://docs.retellai.com/deploy/chat-widget) ​
d
@AI Evy but in this case where can I get the data-agent-id="YOUR_CHAT_AGENT_ID" because i have set it up as voice agent
a
Thanks for the follow-up, @dzei. I'll get back to you soon.
### Answer If you only want voice functionality, you don't need
data-agent-id
at all. [(1) ]() The
data-agent-id
is specifically for text chat functionality and requires a chat agent. If you only have a voice agent set up, you can use just the voice-related attributes. For voice-only mode, your widget script would look like this:
Copy code
html
<script
  id="retell-widget"
  src="<https://dashboard.retellai.com/retell-widget-v2.js%22>
  type="module"
  data-voice-public-key="YOUR_VOICE_PUBLIC_KEY"
  data-voice-agent-id="YOUR_VOICE_AGENT_ID"
></script>
When only
data-voice-agent-id
is set, the widget goes directly to the voice call interface. However, if you want to add chat functionality later, you would need to create a chat agent. [(2) ]() To create a chat agent, navigate to the Agents section in your Retell dashboard, click "Create New Agent", and select "Chat Agent" as the agent type. Alternatively, you can convert your existing voice agent to a chat agent by opening it and clicking "Convert to Chat Agent".
​ To learn more, see the sources I considered: [[1] Retell Website Widget](https://docs.retellai.com/deploy/chat-widget) [[2] Create chat agent](https://docs.retellai.com/build/create-chat-agent) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
d
@AI Evy okay the correct code is <script id="retell-widget" src="https://dashboard.retellai.com/retell-widget-v2.js" type="module" data-voice-public-key="key_364067889b24c30686fedbc121b9" data-voice-agent-id="agent_voice_dc43804a4ebc6562a39c9a40cf" > but when i click start the call it is not starting the call
a
Thanks for the follow-up, @dzei. I'll get back to you soon.
### Answer Here are some troubleshooting steps to help resolve the issue with your voice widget not starting calls: 1. Check Browser Console for Errors Open your browser's developer console (F12) and look for any JavaScript errors when you click "Start Call". This will show if there are permission issues, network errors, or configuration problems [(1) ]() . 2. Verify Public Key Permissions Ensure your public key has the correct permissions enabled for web calls. Go to your Retell Public Keys settings and confirm that web call functionality is enabled for the key you're using . *3. Enable reCAPTCHA (Optional but Recommended) * If you have reCAPTCHA protection enabled for your public key, you need to include the reCAPTCHA script and add the site key to your widget. Add this to your
<head>
tag :
Copy code
html
<script src="<https://www.google.com/recaptcha/api.js?render=YOUR_GOOGLE_RECAPTCHA_SITE_KEY>"></script>
Then add the attribute to your widget script:
Copy code
html
<script
  id="retell-widget"
  src="<https://dashboard.retellai.com/retell-widget-v2.js%22>
  type="module"
  data-voice-public-key="key_364067889b24c30686fedbc121b9"
  data-voice-agent-id="agent_voice_dc43804a4ebc6562a39c9a40cf"
  data-recaptcha-key="YOUR_GOOGLE_RECAPTCHA_SITE_KEY"
></script>
4. Check Browser Microphone Permissions The widget requires microphone access for voice calls. Make sure your browser has permission to access the microphone and that you're serving the page over HTTPS (required for WebRTC) . 5. Verify Agent Configuration Confirm that your voice agent (
agent_voice_dc43804a4ebc6562a39c9a40cf
) is properly configured and active in your Retell dashboard . If the issue persists after these checks, please share any error messages from the browser console for more specific troubleshooting.
​ To learn more, see the sources I considered: [[1] Retell Website Widget](https://docs.retellai.com/deploy/chat-widget) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.