Skip to the content

Embedding the widget

Put your assistant's chat on your website with one script tag. This page covers the snippet, its key, the small JavaScript API, and what to check when the bubble does not show.

Where
Assistant menuDeployChannelsWebsite
Permission
Needs Connect channels
Time
5 min read
Markdown
01 / 03Paste the snippet. Copy it from the website chat's Connection tab and paste it before </body> on every page.
  1. Paste the snippet. Copy it from the website chat's Connection tab and paste it before </body> on every page.
  2. Visitors chat. The bubble appears on any page with the snippet, on a site in your allowed domains.
  3. Open it from your own button. window.HeyServoWidget.open() opens the chat from your own link or button.

What the widget is

The website widget is the chat bubble that sits in the corner of your site. Visitors type or, when calls are on, talk to your assistant. Everything you can choose in the dashboard, such as colours, position, the launcher's label and whether visitors can call, is on Website chat. This page is the developer's side.

The embed snippet

<script src="https://<widget address>/widget.js" data-key="pk_live_…" defer></script>
Copy yours from the website chat's Connection tab: the key is unique to your assistant.

GoalThe chat bubble on your website.

  1. 1

    Turn the widget on

    On DeployChannelsWebsiteSettings, turn on Widget enabled.

  2. 2

    Copy the snippet

    From the Connection tab, or ask your developer to use the MCP tool channels_get_widget_snippet.

  3. 3

    Paste it before </body> on every page

    In a site builder, use its custom code or footer script setting. Only pages with the snippet show the bubble.

  4. 4

    List your site in Allowed domains

    So your key works only on your site.

Attributes3 controls
srcText
The widget's loader, widget.js. Use the address in your snippet.
data-keyText
Required. Your website chat's public key: pk_live_ followed by 20 to 64 letters, digits, _ or -. It is the only attribute the widget reads.
deferShown
Loads the script without holding up your page. Keep it.

What happens on the page

  1. The small loader script checks data-key and draws the launcher: a round bubble, or a chat and a call button when calls are on with separate launchers.
  2. It asks HeyServo for a session with the key. The colour, position, launcher text, logo and call button label come back with it, so design changes reach your site without touching the snippet.
  3. The full chat loads only when a visitor first clicks, and starts warming up when they hover. Your page stays light.
  4. The chat is drawn inside its own isolated element (#heyservo-widget-host), so your site's CSS does not change it, and its CSS does not change your site.
  • One widget per page. A second snippet on the same page is ignored.
  • The visitor's identity is kept in the browser's local storage under heyservo.visitor.{publicKey}, so the same browser is recognised when it comes back.

The JavaScript API

Once the loader runs, window.HeyServoWidget exists on the page.

window.HeyServoWidget3 controls
publicKeyText
The data-key the widget was started with.
open()Button
Opens the chat as if the launcher was clicked. It works once the chat has been loaded, that is after the visitor has opened it once on this page. Before that it does nothing.
destroy()Button
Removes the widget from the page.
<button id="chat-with-us">Chat with us</button>

<script>
  document.getElementById("chat-with-us").addEventListener("click", () => {
    window.HeyServoWidget?.open();
  });
</script>

The widget has no JavaScript events or callbacks. To react to what happens in chats, use webhooks on your server, for example conversation.started or lead.captured.

Allowed domains

List the sites that may show the chat in Allowed domains on the website chat's Settings. A site that is not listed shows nothing. With the list empty, any site that has your snippet can show it. Details are on Website chat.

When the bubble does not show

If the widget cannot start a session, it shows nothing at all, on purpose: a broken bubble is worse than none. Check these in order.

CheckHow
The snippet is on the pageView the page source and look for widget.js.
The key is validOpen the browser console. [heyservo] missing or invalid data-key on the widget <script> tag means data-key is missing or mistyped.
The widget is onWidget enabled on the website chat's Settings.
Your site is allowedThe page's domain is in Allowed domains, including www. if you use it.
The assistant still existsDeleting an assistant deletes its website key. A new assistant has a new snippet.

Limits

Questions people ask

Keep going
Embedding the widget · HeyServo Docs