> For the complete documentation index, see [llms.txt](https://docs.helvia.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.helvia.ai/deploy/webchat.md).

# Webchat

Webchat is the fastest way to put your agent in front of users. Embed a JavaScript snippet on your site and visitors get an interactive chat widget with no backend work required. Despite the simplicity of deployment, Webchat offers the deepest customization of any channel: colors, avatars, bubble behavior, notifications, and more.

<div data-with-frame="true"><figure><img src="/files/7lB8LPueDPNKKndakgxF" alt="" width="359"><figcaption></figcaption></figure></div>

### How Webchat Works

A Webchat deployment generates a JavaScript snippet. Paste it into your website's HTML and the widget loads automatically. Every visitor gets their own conversation session, and the agent responds using the workflow you assign to the deployment.

You can run multiple Webchat deployments for the same agent. Give each its own settings, workflow, or branding to serve different pages or audiences.

<table data-card-size="large" data-column-title-hidden data-view="cards"><thead><tr><th>Feature</th><th>Description</th></tr></thead><tbody><tr><td><h4><i class="fa-palette">:palette:</i></h4><h4>On-Brand Design</h4></td><td>Match colors, fonts, and avatars so the widget feels part of your site</td></tr><tr><td><h4><i class="fa-code">:code:</i></h4><h4>Easy Deployment</h4></td><td>Drop one JavaScript snippet on any site and the widget loads itself, no backend required</td></tr><tr><td><h4><i class="fa-microphone">:microphone:</i></h4><h4>Voice Conversations</h4></td><td>Let visitors speak and hear replies with speech-to-text and text-to-speech</td></tr><tr><td><h4><i class="fa-sliders">:sliders:</i></h4><h4>Deeply Customizable</h4></td><td>Fine-tune layout, behavior, and advanced options through visual settings and custom JSON</td></tr></tbody></table>

### Creating a Webchat Deployment

{% stepper %}
{% step %}

#### Select the Webchat Channel

Go to **Designer > Deployments** and click the **Webchat** icon <i class="fa-globe">:globe:</i> in the channel toolbar.
{% endstep %}

{% step %}

#### Configure General Settings

Give your deployment a **Name** and optional **Description** so your team can identify it later. See [#general-settings](#general-settings "mention") for the full breakdown of each field.
{% endstep %}

{% step %}

#### Customize Layout Settings

Configure the widget's appearance and behavior across different sub-tabs. Each is covered in [Layout Settings](/deploy/webchat/layout-settings.md).
{% endstep %}

{% step %}

#### Save and Preview

Click **Save Changes**. Next, preview the deployment or inspect the JavaScript snippet.
{% endstep %}
{% endstepper %}

### Embed and Preview

Each Webchat deployment has two options for interacting with the widget:

<table data-card-size="large" data-column-title-hidden data-view="cards"><thead><tr><th>Method</th><th>Description</th></tr></thead><tbody><tr><td><h4><i class="fa-code">:code:</i></h4><h4>JavaScript Snippet</h4></td><td><p>Reveals the JavaScript snippet for this deployment. Copy and paste it into your website's HTML to embed the widget. </p><p>Use this when you're ready to go live or want to test the widget in a staging environment alongside your actual site content.</p></td></tr><tr><td><h4><i class="fa-eye">:eye:</i></h4><h4>Preview</h4></td><td><p>Opens a live preview in a new browser tab. The widget renders on a blank page exactly as visitors will see it. </p><p>Use it to quickly verify colors, avatars, notifications, and conversation flow without touching your site.</p></td></tr></tbody></table>

You can access both the JavaScript Snippet and the Preview from two places: the action icons in the Deployments list, or the buttons inside the deployment's edit dialog.

The JavaScript Snippet consists of two parts, both required for a correct deployment:

* The Webchat library script in the page `<head>`&#x20;

```javascript
<script
    src="https://cdn.helvia.io/hbf-webchat/lib/latest-stable/webchat.min.js">
</script> 
```

* An initialization script in the page `<body>`

```html
<div id="botDiv"></div>
  <script> 
    window.HBFWebchat.init( 
      {
        "deploymentId":"<deploymentIdentifier>",
        "apiUrl":"https://core-v5.helvia.io/",
        "entryPoint" : "<flow_start_node_id>" // optional
      }
    );
  </script>
```

{% hint style="info" %}
The JavaScript snippet already includes your `<deploymentIdentifier>`.
{% endhint %}

### Bubble and Embedded

Webchat appears on your site in one of two styles. Choose the one that matches how prominent you want the chat to be, then set it with the **General > Mode** option in [Layout Settings](/deploy/webchat/layout-settings.md).

<table data-card-size="large" data-column-title-hidden data-view="cards"><thead><tr><th>Style</th><th>Description</th></tr></thead><tbody><tr><td><h4><i class="fa-comment-dots">:comment-dots:</i></h4><h4>Bubble</h4></td><td>A floating launcher button that expands into a chat window, best for general sites and landing pages</td></tr><tr><td><h4><i class="fa-table-layout">:table-layout:</i></h4><h4>Embedded</h4></td><td>The chat rendered inline on the page with no launcher button, best for dedicated support and help pages</td></tr></tbody></table>

### Settings

A Webchat deployment is configured through its settings tabs, each covering a different layer of the widget.

#### General Settings

The General Settings tab controls deployment-level behavior that applies before the conversation begins:

| Field               | Description                                                                                                                                                                     |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Language**        | The default language the agent uses in conversations.                                                                                                                           |
| **Flow**            | The Start workflow the agent runs when a conversation begins.                                                                                                                   |
| **Allowed Origins** | Restricts which domains can embed and load the widget. Add the URL of every site that should host this deployment or use wildcards (e.g., `*.example.com`) to cover subdomains. |

{% hint style="info" %}
Leave **Allowed Origins** empty during testing to allow all origins. Always set it before going to production so the widget cannot be loaded from sites you do not control.
{% endhint %}

To remove a deployment, click **Delete Deployment** and confirm by typing "DELETE" in the dialog that appears.

{% hint style="danger" %}
**Permanent Action** Deleting a deployment is permanent. Clone the deployment first if you want to preserve its configuration.
{% endhint %}

#### Layout Settings

Layout Settings is where you customize how the widget looks and behaves: colors, avatars, notifications, actions, and voice, across a set of visual tabs. See the [Layout Settings](/deploy/webchat/layout-settings.md) page for the full breakdown.

#### Custom Settings

For configuration beyond the visual tabs, enable Custom Settings inside Layout Settings and pass a JSON object. See the [Custom Settings](/deploy/webchat/custom-settings.md) page for every available key.

### Developer Hooks

The Webchat widget exposes JavaScript hooks and HTML attributes that let developers customize user tracking, trigger workflows from page elements, and control widget behavior beyond the visual settings. These features require basic knowledge of HTML and JavaScript.

<details>

<summary><i class="fa-user-question">:user-question:</i>  <strong>User identification</strong></summary>

Webchat stores a user ID in the browser's `localStorage` to recognize returning visitors on the same browser and device.

By default, Webchat generates a random user ID. To use your own identifier, for example, to link conversations to authenticated users, implement `window.HBF_retrieveUserId()` in your site's JavaScript. Webchat calls this function on load and uses the returned value instead.

To pass additional user metadata (name, email, or custom attributes), implement `window.HBF_retrieveUserInfo()`. Webchat calls this function alongside `HBF_retrieveUserId()` and attaches the returned data to the contact record.

<table><thead><tr><th width="266">Hook</th><th width="132.5">Return Type</th><th>Purpose</th></tr></thead><tbody><tr><td><code>window.HBF_retrieveUserId()</code></td><td><code>string</code></td><td>A stable, unique identifier for the current user</td></tr><tr><td><code>window.HBF_retrieveUserInfo()</code></td><td><code>object</code></td><td>A key-value map of additional user information (commonly under <code>customData</code>)</td></tr></tbody></table>

{% hint style="info" %}
Both hooks are optional. If neither is implemented, Webchat falls back to a randomly generated ID with no additional metadata.
{% endhint %}

Example: Provide a known user ID and custom data.

```html
<script>
    window.HBF_retrieveUserId = function() {
        return "user@example.com" // replace with actual user's unique identifier
    }
</script>

<script>
    window.HBF_retrieveUserInfo = function() {
        return {
            name: "John Doe",
            email: "user@example.com",
            customData: {
                "<variableName1>": "<variableValue>",
                "<anotherVariable>": "<anotherValue>"
            }
        }
    }
</script>
```

</details>

<details>

<summary><i class="fa-lock">:lock:</i>  <strong>User Pre-Authentication</strong></summary>

When [end user authentication](/security/end-user-authentication.md) is enabled on an agent, the embedding site can pass a pre-authenticated token so the user enters the conversation already signed in. Use `window.HBFWebchat.setAuthToken(divId, token, refreshToken?)` to set or update the token at runtime. The `divId` is the deployment ID you passed to `HBFWebchat.init()`; it targets the right widget when your page has more than one. The `token` is the pre-authenticated value the platform validates against the providers configured on the agent. The optional `refreshToken` lets the platform refresh expired tokens during the session without prompting the user.\
\
The token can also be supplied at init through `customData.authToken` (and `customData.authRefreshToken` if a refresh is needed). Use this when the user is already authenticated by the time the widget loads.

```javascript
<script> 
    window.HBFWebchat.setAuthToken('<botDiv>', '<token>', '<refresh-token>');
</script>
```

</details>

<details>

<summary><i class="fa-rotate-right">:rotate-right:</i>  <strong>Reload widget</strong></summary>

In order to reload the Webchat widget, without reloading the hosting page, you must first remove the `HBFWebchat` instance and then initialize it again.

```html
<script>
 window.HBFWebchat.remove();
 window.HBFWebchat.init( 
   {
      "deploymentId":"<deploymentIdentifier>",
      "apiUrl":"https://core-v5.helvia.io/"
   }
 );
</script>
```

</details>

<details>

<summary><i class="fa-messages">:messages:</i>  <strong>Conversation transcript</strong></summary>

You can fetch the whole conversation transcript using the function `window.HBFWebchat.getTranscript()`

The returning value will be an array of objects with the following interface:

```javascript
[
  {
   text: string;
   from: { email?: string; name?: string; role: "bot" | "user" };
   timestamp: Date;
  }
]
```

</details>

<details>

<summary><i class="fa-bolt">:bolt:</i>  <strong>Trigger workflow via HTML element</strong></summary>

Add the attributes `class="btn-hcn"`, `data-hcn`, and `data-target-div` to any HTML element to trigger a workflow on click. Set `data-hcn` to the ID of the start node for the workflow you want to run.

```html
<button type="button" class="btn-hcn" data-lang="el" data-hcn="flowID" data-target-div="botDiv">Start Chat</button>
```

</details>

<details>

<summary><i class="fa-bolt">:bolt:</i>  <strong>Trigger workflow with parameters</strong></summary>

Use `window.HBFWebchat.redirectChatTo()` to redirect the widget to a specific node while passing optional variables. These variables are accessible through the `parameters` object in the platform. If the bubble widget is not open yet, this function opens it automatically and overrides any other configuration.

```html
<button onclick="window.HBFWebchat.redirectChatTo('botDiv', { nodeId:'node-id', variables: { key: 'value' } })">Button label</button>
```

</details>

<details>

<summary><i class="fa-bolt">:bolt:</i>  <strong>Trigger workflow via URL query parameters</strong></summary>

If your page already has the Webchat widget installed, you can construct links that open the widget and trigger a specific workflow using query parameters.

| Parameter       | Effect                                                    |
| --------------- | --------------------------------------------------------- |
| `?hws=on`       | Opens the widget on page load                             |
| `?hws=alwayson` | Opens the widget and hides the close button               |
| `?hcn=<nodeId>` | Triggers the workflow starting from the specified node ID |

Combine parameters as needed. For example, if `https://helvia.ai` includes a Webchat widget , the link `https://helvia.ai?hws=on&hcn=start` opens the widget and starts the workflow with node ID `start`.

</details>

### Best Practices

* **Match your brand:** Use your brand colors, fonts, and a recognizable avatar so the widget feels native to your site, not bolted on
* **Start with Bubble mode:** Most websites benefit from a non-intrusive floating widget. Reserve Embedded mode for dedicated support or help pages
* **Set Allowed Origins before production:** Restrict which domains can load the widget so it cannot be embedded on sites you do not control
* **Preview before deploying:** Always use the eye icon to test changes before updating the snippet on your live site

{% hint style="success" %}
You now know how to create, customize, and embed a Webchat deployment on your website.
{% endhint %}
