# Installation

> Embed the chat widget on your site and wait for it to be ready.

The widget renders a single floating button on your page that opens a chat panel. The script loads asynchronously, so use the readiness hooks below instead of polling for `window.GetResolved`.

## Add the script

Drop the snippet into your site, ideally before the closing `</body>`. Replace `YOUR_CHAT_KEY` with the chat key from your workspace settings.

### Anonymous users

Use this form on public pages — landing pages, marketing sites, or anywhere visitors aren't signed in. Each conversation is keyed to the browser session.

```html
<script>
  window.GetResolvedConfig = {
    chatKey: "YOUR_CHAT_KEY"
  };
</script>
<script src="https://app.getresolved.ai/chat/init.js" async></script>
```

### Identified users

Once a user is signed in, pass their identity in `user` so conversations stick to that account across sessions and devices — and so messages back from your team are delivered to the right inbox.

```html
<script>
  window.GetResolvedConfig = {
    chatKey: "YOUR_CHAT_KEY",
    user: {
      id: "USER_ID",
      email: "user@example.com",
      name: "User Name"
    }
  };
</script>
<script src="https://app.getresolved.ai/chat/init.js" async></script>
```

`id` is your application's stable identifier for the user; `email` and `name` are optional but improve the agent's view in the GetResolved dashboard. Render this snippet server-side (or inject the values from your app shell) so the user data is always in sync with your auth state.

## Waiting for the widget to load

The init script loads asynchronously, so `window.GetResolved` may not exist the moment your page code runs. Use one of the hooks below instead of polling.

### Promise

Once `window.GetResolved` is defined, its `.ready` promise resolves with the API. Safe to call any number of times.

```js
window.GetResolved.ready.then((GR) => {
  GR.hide();
});
```

### Event

For code that runs **before** the script loads — the widget fires this event once it's ready.

```js
document.addEventListener("getresolved:ready", (event) => {
  event.detail.hide(); // same object as window.GetResolved
}, { once: true });
```

### Callback

`GetResolved.onReady(cb)` is a callback shorthand for the promise form.

```js
window.GetResolved.onReady((GR) => {
  GR.hide();
});
```

## Install-time configuration

Anything you set on `window.GetResolvedConfig` before the script loads is applied during initialization. See the [Commands](/docs/widget/commands) page for the full list of options.

```js
window.GetResolvedConfig = {
  chatKey: "YOUR_CHAT_KEY",
  hideOnOutsideClick: true,
  hideOnPanelClose: true,
};
```

