> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usefrictionless.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Control the chat

> Open it from your own button, show unread counts, and handle sign-in and sign-out.

## Your own button

```js theme={null}
Frictionless.init({ company_id: "YOUR_WORKSPACE_ID", launcher: false });
myButton.onclick = () => Frictionless.toggle();
Frictionless.on("unread", (count) => { myBadge.textContent = count || ""; });
```

| Method | What it does |
| - | - |
| `open()` | Opens the chat |
| `open("help")` | Opens on the help tab |
| `open("book")` | Opens on the Book tab (see [Bookings](#bookings)) |
| `close()` | Closes it |
| `toggle()` | Opens or closes it |
| `showLauncher()`, `hideLauncher()` | Shows or hides the chat button |
| `on("unread", fn)` | Calls `fn` with the number of unread replies |

Unless you pass `autoOpen`, the chat starts closed, as a button, until a visitor opens it.

## Signed-in users

To show agents who a visitor is, call `identify()` with a `userHash` computed on your server. [Identify signed-in users](/context-api/website) shows how.

## Signing out

When a user signs out, call `Frictionless.reset()`. It forgets the visitor on that browser, so the next person to use it starts a new chat and can't see the last one.

```js theme={null}
async function signOut() {
  await yourSignOut();
  window.Frictionless?.reset();
}
```

## Bookings

With **Book tab in the website chat** switched on in **Integrations → Calendar**, `open("book")` opens it, and `on("booking", fn)` tells you when someone books. While the Book tab is off, `open("book")` opens the home screen instead.

```js theme={null}
bookButton.onclick = () => Frictionless.open("book");

Frictionless.on("booking", (b) => {
  // b: { title, start, day, time }
});
```

To take bookings without the chat, see [Take bookings on your website](/bookings/overview).


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