> ## Documentation Index
> Fetch the complete documentation index at: https://help.desk.min-ai.ar/llms.txt
> Use this file to discover all available pages before exploring further.

# Add the web chat

> A chat on your website: paste one line of code and your visitors write to you.

The chat shows as a bubble in a corner of your site. What your visitors write reaches the **Inbox** like any other conversation, answered by the channel's agent or your team. There's no account to connect.

**1. Add the channel**

In **Channels**, tap **Add channel** and pick **Web chat**. Fill in the **Channel name**, the **Answering agent** and the **Receiving team**, and tap **Continue**. The channel is on.

**2. Paste the code on your site**

On the channel's page, copy the **Code for your site** and paste it before `</body>` on the pages where you want the chat (or in the shared template, to have it on all of them):

```html theme={null}
<script async src="https://chat.desk.min-ai.ar/widget.js" data-channel="wc_…"></script>
```

**3. Say which sites may show it**

In **Sites**, add your site's address (`yourshop.com`, or `*.yourshop.com` for all its subdomains) and tap **Save**. Browsers block the chat on any other site. With no site listed, it shows on any site that pastes the code.

## Where to paste the code

* **Your own HTML**: before `</body>`, on each page or in the template they share.
* **WordPress**: with a code plugin in the footer (for example *WPCode*: **Code Snippets → Header & Footer → Footer**), or in the theme's `footer.php`.
* **Tiendanube**: in **Settings → External codes**.
* **Shopify**: **Online Store → Themes → Edit code**, in `theme.liquid`, before `</body>`.
* **Google Tag Manager**: a **Custom HTML** tag with the code, triggered on **All Pages**.

If your site has a content security policy (CSP), add `https://chat.desk.min-ai.ar` to `script-src` and `frame-src`.

## How it looks

In **Look** you pick the **Color**, the **Title** (empty: the channel's name), the **Greeting** visitors read before writing, the **Position** (bottom right or left) and the **Chat language** (the visitor's browser's, or a fixed one). The preview shows how it looks.

On a phone, the open chat takes the whole screen. If a reply arrives while the chat is closed, the bubble shows how many new messages there are.

## Before the chat

In **Before the chat** you pick what the chat asks visitors before their first message: **Name**, **Email** and **Phone**, each **No**, **Optional** or **Required**. The agent reads them in the contact and calls the visitor by their name. Visitors your site identified (see [Who the visitor is](#who-the-visitor-is)) aren't asked.

What visitors type there isn't verified: the name and email go in the contact, and the phone as a separate detail (`webchat_phone`), so nobody can pass for a WhatsApp customer by typing their number. Asking for many required details makes some visitors not write: the usual is to ask for the name, and the email or phone as optional.

## The chat as a page

**The chat as a page of its own** is a link (`https://chat.desk.min-ai.ar/chat/wc_…`) that opens the chat alone, without your site: share it by email, on social media or in a QR code.

## What the agent sees

The agent knows which page of your site the visitor was on when they wrote, and that they may close it at any moment: if it needs to follow up later, it asks for an email or a phone. Visitors get the reply while the page is open, and find it when they come back on the same browser.

## Who the visitor is

If your site has users, it can tell minai desk who each one is. Their conversation then follows them to any browser, and the agent knows their name and email. In **Who the visitor is** you pick:

* **No**: everyone writes as an anonymous visitor.
* **If signed in**: those signed in on your site arrive with their name; the rest, anonymous.
* **Users only**: only those signed in can write.

To use it, tap **Make a secret** and keep it on your server (it's shown once; if you lose it, make another and the old one stops working). When the user has signed in, your server signs a JWT with that secret and your page hands it to the chat:

```js theme={null}
// On your server (Node, with the jsonwebtoken package):
const token = jwt.sign(
  { sub: user.id, name: user.name, email: user.email },
  process.env.DESK_WEBCHAT_SECRET,
  { algorithm: "HS256", expiresIn: "1h" },
);
```

```html theme={null}
<!-- On the page, with the token your server made: -->
<script>
  window.minaiDesk = window.minaiDesk || function () { (minaiDesk.q = minaiDesk.q || []).push(arguments) };
  minaiDesk("identify", "TOKEN");
</script>
```

`sub` (the user's id on your site) and the expiry are required; `name` and `email`, optional. What the visitor wrote before signing in moves to their conversation. Never put the secret in the page's code.

Other commands your page can give the chat: `minaiDesk("open")`, `minaiDesk("close")`, `minaiDesk("toggle")` and `minaiDesk("logout")` (when the user signs out: the browser becomes a new visitor).

## The limit

**New conversations a day** keeps your model spending safe if someone abuses the chat (500 unless you change it). Past the limit, new visitors can't write until the next day; conversations already started go on. A visitor also can't send more than 20 messages a minute.

## Turning it off or removing it

* **Turn off**: the chat stops showing on your site, even with the code still pasted. The channel and its conversations stay: to come back, tap **Turn on**.
* **Remove**: the channel and its conversations are deleted (contacts and cases stay), and the pasted code shows nothing.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.