# Install the widget

Add a site, copy the install code, and paste it into your website. It works on any site that lets you add code.

## Let your coding AI do it

You can ask a coding AI such as Cursor, Claude Code, or Lovable to read `quiry.me/docs` and add the widget. The raw text of this page is at `quiry.me/docs/install.md`, and the full list is at [quiry.me/llms.txt](/llms.txt).

1. Put the install code in the one place that every page shares. In Next.js, that is before `</body>` in `app/layout.tsx`. The code contains the **workspace** and **key** chosen in Settings > Widgets.
2. `data-workspace` and `data-widget` are required. Optional attributes are `data-launcher="false"` (hide the launcher and open only with `Quiry.open()`), `data-position` (`left` or `right`), and `data-color` (launcher color).
3. You can call `Quiry.open()`, `Quiry.close()`, and `Quiry.identify()` before the script has loaded. Put the first line below ahead of the install code and the calls are queued and run after loading.

```
<script>window.Quiry=window.Quiry||{q:[]};["open","close","identify","onReady","onError","onUnread"].forEach(function(m){Quiry[m]=Quiry[m]||function(){Quiry.q.push([m,arguments])}});</script>
<script src="https://quiry.me/w.js" data-workspace="my-team" data-widget="my-site" async></script>
```

> The widget does not appear if your site address is missing from the allowed domains. Check this first when you add a new site.

## Add a site

1. Open **Settings** and select **Add site** under **Sites** on the left.
2. Enter a **Name**. It appears in the widget and in notification emails.
3. Enter a **Key**. Use lowercase letters, numbers, and hyphens, 2 to 40 characters. It goes into the install code and console URLs.
4. In **Allowed domains**, enter the address of the site that will carry the widget.

If you do not see Add site, you do not have permission to manage sites. Ask an admin for a permission group.

## Paste the install code

1. Select the site you added and open the **Install** tab.
2. Under **Install code**, select **Copy code**.
3. Paste it where it will load on every page of your website, just before `</body>`.

Reload your site and the contact button (the launcher) appears at the bottom right. Send a test message and check that it arrives in the console **Inbox**.

## Allowed domains

The widget only loads on addresses listed under **Allowed domains**. Enter one per line, starting with `https://`.

```
https://example.com
https://*.example.com
```

A `*` allows every subdomain at once. Add new addresses here when your site moves or grows.

## Contact page

To take conversations where a widget cannot go (messengers, business cards, print), turn on the **Contact page**.

1. Under **Contact page** in the **Install** tab, choose an **Address**. Use lowercase letters, numbers, and hyphens, 3 to 40 characters.
2. After you save, the contact screen opens at `quiry.me/c/address`. Save the **QR code** to put it on printed material.
3. With **Show in the quiry app inbox** on, customers can find your service in the quiry app and contact you from there.

## Connect logged-in users

If your site has accounts, you can link a logged-in user to their quiry customer record. Customers do not have to type their email again, and they show as **Registered user** in the customer detail. A developer needs to set this up once.

1. Under **Connect logged-in users** in the **Install** tab, copy the **Signing secret** into an environment variable on your site's server.
2. On the server, sign the user id.
3. In the browser, call `Quiry.identify` with that signature.

```
import { createHmac } from "node:crypto";
const hash = createHmac("sha256", process.env.QUIRY_IDENTITY_SECRET).update(String(user.id)).digest("hex");
// Browser: Quiry.identify({ id: user.id, email: user.email, name: user.name, hash })
```

> Never put the signing secret in browser code. If it leaks, select **Regenerate secret** and update the value on your server. Regenerating makes existing signatures invalid immediately.

What a coding AI should know about connecting users:

- `hash` is required. If it is missing or wrong, the link is ignored and the visitor stays anonymous. The signature covers the user id only, so name and email are not protected by it.
- Create the signature on the server only. Keep the signing secret in a server environment variable (any name works, such as `QUIRY_IDENTITY_SECRET`), never in browser code, the repository, or a client bundle.
- Call `Quiry.identify` after sign-in finishes, passing the `hash` the server returned as is.
- There is no call to announce a sign-out. On sign-out, reload the page so the widget restarts without user details.
- In an SPA that swaps pages (Next.js, React Router, and so on), put the install code in the layout once. Do not add it again on every route change. Call `Quiry.identify` again only when the user's details change.

Next: [Move from Channel Talk](/docs/from-channeltalk).
