# Live chat widget

Add a chat widget to each of your websites and talk to customers in real time. Each widget has its own key, look, topics and team.

The chat widget is a small script you add to your website. Visitors start a conversation, and it arrives in your inbox as a ticket on the `chat` channel. Replies are delivered live, with typing indicators on both sides.

Widgets belong to a [brand](/guides/brands-and-widgets/). Add one widget for each website: each has its own key, look, team and topics, so a chat from your docs site and one from your marketing site can go to different teams.

![The Marketing site widget page: its name and team ringed as 1, the live preview ringed as 2, and the Live pill ringed as 3](https://heykefu.com/guides/brands/widget-overview.webp)

1. **Widget**: its name, usually the website, and the **Team** its new conversations go to.
2. **Preview**: the real widget with your unsaved changes. Switch between the launcher, the home screen and a chat, and try it.
3. **Live**: the widget is on your site and shown, or **Hidden** when **Show the widget** is off. It reads **Not installed** until the first visitor loads it.

## Add the widget to your site

**1. Open the brand's widgets**

Open **Settings**, then **Brands and widgets**, and click the brand. On its **Chat widgets** tab, click the widget, or **Add a widget** for a new website. See [Chat widgets](/guides/brands-and-widgets/#chat-widgets).

![The app with Settings in the sidebar ringed as 1, Brands and widgets in the settings menu ringed as 2, and the Margin brand ringed as 3](https://heykefu.com/guides/chat/open-widget.webp)

**2. Copy the install snippet**

Under **Install**, copy the snippet. It loads the widget script from `https://app.opendesk.sh/widget/v1.js`, or from your own domain when self-hosted, with this widget's **key**.

![The Install section: the script snippet ringed as 1, and the widget key wk_margin_c6ab0ff6 ringed as 2](https://heykefu.com/guides/chat/install.webp)

**3. Paste it on every page**

Paste the snippet before the closing `</body>` tag on every page of the site where the widget should appear.

**4. Limit where it loads**

Under **Behaviour**, list the sites that may load this widget in **Allowed sites**, such as `https://www.example.com`. Left empty, it loads on any site.

![The Behaviour section: Show the widget ringed as 1, Ask for an email first ringed as 2, and Allowed sites with https://margin.app and https://www.margin.app ringed as 3](https://heykefu.com/guides/chat/behaviour.webp)

**Show the widget** turns the launcher off everywhere without removing the script. **Ask for an email first** has visitors leave an address before they chat, so you can follow up by email.

> **Note**
>
> The widget key is public and safe to put in your page: it only says which widget to load. Set **Allowed sites** before going live. The widget's live connection accepts only tokens scoped to one visitor of that widget's brand.

## Send chats to the right team

A new chat goes to the team of the topic the visitor picked, else to the widget's team. [Routing rules](/guides/routing/) can still move it, for example by the page the visitor started on.

Add **Topics** to let visitors say what they need: the widget then asks "What can we help with?" before the first message, and each topic sends the conversation to its team. A widget can have up to 8 topics.

![The Topics section: the topic labels ringed as 1, the team each topic goes to ringed as 2, and Add a topic ringed as 3](https://heykefu.com/guides/brands/widget-topics.webp)

Once a conversation has a team, the widget's header shows the team's name.

To give each new chat to one teammate at once, with a pop-up on their screen, use [Live chats](/guides/triage-and-assignment/#live-chats) on the Assignment page.

## When you're closed

Outside business hours, the widget shows your **Offline message**: by the hours of the team the chat goes to, else the workspace's. Visitors can still write, and your team answers when it is back.

With **Reply by email when they leave**, on by default, a visitor who left an email address and is no longer on your site gets your replies by email, from the brand's address for the team. Their answer by email comes back into the same chat. The email needs a mailbox of the brand that can send: without one, the reply box says so, and each reply that could not be emailed is marked on the ticket's timeline.

![The When you're closed section: the offline message ringed as 1, and the Reply by email when they leave switch ringed as 2](https://heykefu.com/guides/brands/widget-offline.webp)

## Identify signed-in users

If your visitors are signed in to your product, pass their user id, email and name to the widget so conversations attach to the right contact and follow them across devices. To stop anyone posing as another user, sign the user id with this widget's secret. See [Identity verification](/guides/live-chat/identity-verification/).

![The Identify signed-in users section: the identify snippet ringed as 1, and the Widget secret with Rotate secret ringed as 2](https://heykefu.com/guides/chat/identify.webp)

## Verified and unverified visitors

An email address a visitor types in the chat proves nothing on its own: anyone can type anyone's address. So when a visitor leaves their address in the widget's email form, opendesk emails them a link to confirm it, in their language and your brand's email design, and the chat shows them a note that the email went out. They keep chatting meanwhile. Nothing is blocked while they are unverified.

- In the chat, at the top of the conversation (1) and beside the visitor's name (2), your team sees **Unverified** until the visitor opens the link and clicks **Confirm email address**, then **Verified**. It changes live, with no reload. Hover it to see why.
- A visitor signed in through [identity verification](/guides/live-chat/identity-verification/) is **Verified** from the start, and gets no email.
- One link goes out at a time, so sending the form again sends no second email. The visitor can ask for another from the note in the chat after a minute, up to five a day. A link works for 48 hours.
- Opening the link shows a page with the address and a **Confirm email address** button. Only that click verifies, so a mail scanner that opens links verifies no one.
- If the address changes later, the visitor is unverified again until they verify the new one.
- A visitor who types the address of someone you already know gets a contact of their own until they verify, so they never see that person's conversations. Once they verify, their contact merges into the existing one: the chat moves there, your team sees one contact, and replies reach them by email at that address. For safety, the chat in their browser starts over, since whoever typed the address may not be whoever opened the email. A blocked contact, or two contacts with different external ids, stay apart.

![A chat whose visitor has not verified their email: Unverified at the top of the conversation ringed as 1, and beside the visitor's name in the contact card ringed as 2](https://heykefu.com/guides/chat/verification.webp)

## Look and home screen

- **Appearance**: the accent colour (the brand's colour unless you pick one), light, dark or automatic theme, which corner the launcher sits in and how far from the edge, the corners, and the launcher's icon or label.
- **Header**: the title (the brand name when empty), the subtitle, an avatar, and **Show team faces**: up to three teammates of the widget's team, first names only, available people first. A private team's members are never shown.
- **Home screen**: the greeting and up to four suggested questions. A tap starts a conversation with that question. A returning visitor sees their conversations under them: open ones first, then finished ones, each newest first, six at most. A conversation solved or closed more than 30 days ago leaves the home screen; **See older conversations** opens all of them.
- **Intro**: the line under the greeting when a visitor starts a new chat. Empty shows a translated default. Turn off **Welcome text in a new chat** to open new chats empty.
- **Sound for new replies**: a soft chime while the visitor's tab is in the background.

### Change it from your own CSS

The settings above apply to every screen size. To change the position or colour for one of them, set these CSS variables from your site's stylesheet. They win over the widget's settings, and need no `!important`:

| Variable | Sets |
| --- | --- |
| `--opendesk-offset-x` | distance from the side, such as `16px` |
| `--opendesk-offset-y` | distance from the bottom, such as `40px` |
| `--opendesk-z-index` | stacking order |
| `--opendesk-brand` | accent colour of the launcher, buttons and your messages |
| `--opendesk-brand-text` | text and icons on that colour |

```css
:root { --opendesk-offset-y: 20px; }

@media (max-width: 479px) {
  /* Sit above a bottom bar on phones. */
  :root { --opendesk-offset-y: 40px; }
}
```

Set them on `:root`, or on the widget's host element, `[data-opendesk-widget]`.

## How a conversation works

1. When the widget opens, it creates a **visitor session** and receives a visitor token, stored in the browser so returning visitors see their history. A visitor's conversation list holds the chats of that brand only.
2. The visitor's first message creates a ticket and a [contact](/guides/inbox-and-tickets/#contacts-and-companies).
3. Agent replies appear in the widget in real time. Internal notes are never sent to the widget. In an agent's or the AI agent's reply, a web address (`https://`, `http://`, `www.`) or an email written as plain text shows as a link that opens in a new tab, labelled with its site and a short path, like `example.com/help/…`. A link that shows its own address gets the same short label; a link with words of its own keeps them. Only how it shows changes: the message, and its email copy, keep the full address.
4. Agents see when the visitor is typing, and the visitor sees when an agent is typing.
5. Visitors can attach files of up to 25 MB, unless **Let visitors send files** is off for the widget. Any file but programs and scripts is taken, or pick **Only these types**: images, documents, spreadsheets, presentations, audio and video, or ZIP archives. Each file is checked by its contents as well as its name, so a script renamed to `.png` is refused, and programs never get through.
6. With **Let visitors send voice messages** on, a microphone button sits next to the message field. A visitor records up to the **Longest voice message** you pick (5 seconds to 5 minutes), listens back, then sends the recording or deletes it. Recording stops on its own at that length. Voice messages work with files turned off, and agents play them right in the conversation.

While visitors wait with nobody assigned, a red row on top of **Inbox** in the sidebar says how many wait and for how long, and opens the longest wait. Someone who does not take chats can hide it for themselves: open **Customize sidebar**, then **Inbox**, and hide **Waiting chats**.

If the brand's [help center](/guides/knowledge-base/) is published, the widget links to it so visitors can find answers on their own. Deleting a widget ends its visitor sessions; past conversations stay in the inbox.

## Start a chat yourself

You can open a chat with a customer before they write. Click **New ticket**, choose **Start a chat**, pick the contact and write your first message. Without a subject, the chat is named after your message. You can also click **Start chat** on a contact, or search for **Start a chat** in the command menu.

The chat reaches only people whose identity the widget proves: someone signed in through [identity verification](/guides/live-chat/identity-verification/), or a visitor who used the chat from the same browser in the last 90 days and whom you know only from the chat. An email address typed in the widget proves nothing, so once that address emails you, or the contact has any other ticket, only identity verification reaches them. Others show **Not on chat**: email them instead. Identifying signed-in users is the surest way to reach them, on any device.

The next time the visitor loads your site, the launcher shows a count and a preview of your message. Clicking it opens the conversation. While they are away, your message also goes to their email when **Reply by email when they leave** is on for the widget. Under your latest message, **Not seen yet** turns into **Seen** once they read it. Ollie stays out of a chat you start; it is yours.

## Related

- [Brands and widgets](/guides/brands-and-widgets/)
- [Identity verification](/guides/live-chat/identity-verification/)
- [Routing](/guides/routing/)
- [Widget API](/api/resources/widget/)
- [Realtime](/api/realtime/)
