Add a Voice Agent Widget to Your Website
Add your Spokiva voice agent to any website with a single script tag. Visitors click a button and talk to your AI agent right in the page — no phone number, no telephony setup required.
How it works
- The widget is a small JavaScript file loaded from our servers that renders a button (or inline panel) on your page.
- When a visitor clicks the button, the widget connects to the voice agent and streams audio directly in the browser using WebRTC.
- No phone number is needed — everything happens inside the visitor's browser.
- All configuration is stored on our side. Changes in the Spokiva admin panel apply automatically without re-embedding.
Where to find your embed code
- Log in to the Spokiva admin panel .
- Open your workflow (the voice agent you built).
- Open Settings → Configure Widget.
- Turn on Enable Embedding.
- Optionally enter the Allowed Domains where the widget may run (leave empty to allow any website).
- Click Save Configurations.
- Copy the Embed Code shown below the button.
The embed script
Copy the whole block and paste it just before the closing </body>tag of your website's HTML.
<!-- Spokiva Widget -->
<script>
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = 'https://call.neptuneinfotech.com/embed/spokiva-widget.js?token=emb_YOUR_TOKEN&environment=production&apiEndpoint=https://call.neptuneinfotech.com';
js.setAttribute('data-spokiva-context', JSON.stringify({
page_url: window.location.href,
today: new Date().toISOString().slice(0, 10)
}));
js.async = true;
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'spokiva-widget'));
</script>Widget types
Voice Agent
Visitors click a button and talk to your agent by voice.
Chat Agent
Visitors type messages to your agent.
Embed modes
Floating Widget
A button floats in a corner of the page. The most common option.
- Position: bottom-right / bottom-left / top-right / top-left
- Button text and color are configurable
Inline Component
The widget renders inside a container you place in your page content.
- Add <div id="spokiva-inline-container"> where you want it
- Drive a voice agent with window.SpokivaWidget.start() / .end()
Headless (Bring Your Own UI)
No built-in UI — drive the agent from your own buttons via the JavaScript API.
- window.SpokivaWidget.start() / .end()
- onStatusChange / onCallStart / onCallEnd / onError callbacks
- Chat: startChat(), sendMessage(), getMessages()
Passing visitor details to the agent
Pass information about the current visitor to the agent. It becomes available inside your prompts as {{initial_context.<name>}}.
js.setAttribute('data-spokiva-context', JSON.stringify({
page_url: window.location.href,
today: new Date().toISOString().slice(0, 10),
user_email: '[email protected]', // your own fields
plan: 'premium'
}));For details your page learns after load, call window.SpokivaWidget.setContext({ ... }) before starting the conversation.
Allowed domains & security
The Allowed Domains list controls which websites may load the widget. Leave it empty to allow any website, or add domains one at a time (e.g. example.com or *.example.com). This is a security control: anyone with your token can use it only on domains you allow.
Browser and mic permission
- The site must be served over HTTPS for microphone access to work in modern browsers.
- The call starts on a user click because browsers only grant mic access after a user action.
- Desktop and mobile browsers are supported.
Changing configuration after embedding
You do not need to re-embed the script to change button text, color, position, widget type, or embed mode. Save the new configuration in the admin panel and it applies automatically — the widget fetches its configuration at load time.
Troubleshooting
| Problem | What to check |
|---|---|
| Widget does not appear | Confirm Enable Embedding is on. Check the console for a network error loading the widget script. Confirm the site is HTTPS. |
| “Failed to fetch config” in the console | Your token may be inactive, expired, or the domain is not in the Allowed Domains list. Re-save the configuration in the admin panel. |
| Microphone prompt does not appear | The call must start from a user click. Make sure start() is inside a click handler and the page is HTTPS. |
| Audio is not heard | Confirm the visitor's browser allows the microphone. Test in a private/incognito window. |
Support
For help, contact your Spokiva representative or reach out through the Neptune Infotech team. Include the workflow name and a description of the issue.
