Skip to content
OneSay Developers

Guides

Voice widget: put your AI Agent on your own website

Not open yet. The voice widget does not work end to end yet: the page side that visitors load (the loader and the widget) is not served in any environment.

Not open yet. The voice widget does not work end to end yet: the page side that visitors load (the loader and the widget) is not served in any environment. You can already create and publish a widget in OneSay Cloud and copy its snippet; it starts working on your site when the widget opens. This page shows how it will work.

The voice widget puts your AI Agent on your website with one line of code. A visitor clicks the launcher, allows the microphone and talks to your Agent. You decide which sites it may run on and how much it may spend per day; calls are billed to your Organization as AI Agent calls.

This guide uses the pre-production environment (Staging); Production and more regional nodes will follow, each with its own addresses.

1. Create and publish a widget

  1. In OneSay Cloud, open Voice widgets and choose New voice widget.

  2. Choose its language, theme and position.

  3. Publish it. Publishing asks for:

    • the Agent profile that answers your visitors;
    • the allowed sites, one per line: https://www.example.com, every subdomain as https://*.example.com, or http://localhost for local testing in a Test Environment;
    • the daily spend cap, the most the widget may spend in one UTC day.

    You confirm the publish in OneSay Cloud. After it, the widget page shows the widget ID and its snippet.

The widget ID is public. It only works on the allowed sites: a page anywhere else gets no settings and no call.

2. Add the snippet to your page

Paste the snippet from the widget page into your page's HTML, before </body>:

html
<script async src="https://cloud.staging.onesay.com/_widget/v1/loader.js" data-onesay-widget="vwgt_01JD0000000000000000000000"></script>

Copy the snippet from OneSay Cloud rather than from this page: its address is your environment's, and its widget ID is yours.

The loader is small and loads the widget only after your page has loaded. The widget runs inside its own shadow root, so your page's styles do not change it and its styles do not change your page.

3. Allow it in your site's security headers

If your site sends a Content Security Policy, allow the widget's addresses. On Staging they are:

DirectiveAdd
script-srchttps://cloud.staging.onesay.com (the loader and the widget)
connect-srchttps://api.staging.onesay.com (the widget's settings and its call), the LiveKit server of your environment, in its https:// and wss:// form (the realtime call; the widget's settings name it as server_url)

Production and more regional nodes have their own addresses; take them from the snippet and your environment, not from this page.

The microphone belongs to your page's own origin, so the browser asks the visitor once, as for any page. If your site sends a Permissions-Policy header, it must allow microphone for your own origin (microphone=(self)); microphone=() turns the widget's microphone off.

4. What a visitor's call costs and how it is limited

  • A widget call is an AI Agent call of the widget's Environment. It is billed with the same price lines (realtime session, input and output) and settles against your Organization's balance and allowance, like any other call. The trial allowance covers widget calls.
  • Each call must fit within the widget's daily spend cap and your Organization's balance. When either runs out, new calls are refused; a call in progress ends only when the money runs out or someone hangs up.
  • Requests are rate-limited per widget and visitor address, to protect the service.

5. Turn a widget off or revoke it

  • Turn off refuses new calls at once; calls in progress continue.
  • Revoke ends the widget for good: new calls are refused and calls in progress end.

Next steps