# Commands

> Methods on window.GetResolved for opening, hiding, and configuring the chat panel.

Once the widget is installed, the methods below are available on `window.GetResolved`. All methods are safe to call after the widget has loaded — see [Installation](/docs/widget/installation) for readiness hooks.

## Open the chat

Opens the chat panel. No-op if already open.

```js
GetResolved.open();
```

## Close the chat

Closes the chat panel. No-op if already closed.

```js
GetResolved.close();
```

## Toggle the chat

Toggles the chat panel between open and closed.

```js
GetResolved.toggle();
```

## Hide the widget

Hides the floating button and panel entirely. Chat state is preserved.

```js
GetResolved.hide();
```

## Show the widget

Brings the widget back after `hide()`.

```js
GetResolved.show();
```

## Example: custom "Chat with us" button

Wire any element on your page to open the chat.

```html
<button onclick="GetResolved.open()">Chat with us</button>
```

## Auto-hide behaviors

Make the floating button and panel disappear entirely when the user clicks outside the widget or closes the panel. After the widget hides, call `GetResolved.show()` or `GetResolved.open()` from your own trigger to bring it back.

**Runtime** — call any time after the widget loads:

```js
GetResolved.configure({
  hideOnOutsideClick: true,
  hideOnPanelClose: true,
});
```

**Install-time** — set on `window.GetResolvedConfig` before loading the script:

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

## Detecting clicks outside the widget

The widget renders a single root container on `document.body` with a stable id and data attribute. Use one of the hooks below instead of matching internal class names, which may change between releases.

- `window.GetResolved.contains(el)` — returns `true` if `el` is inside the widget.
- `window.GetResolved.root` — the container element.
- `#getresolved-widget-container` and `[data-getresolved-root]` — stable DOM selectors for the same element.

```js
document.addEventListener("click", (event) => {
  if (!window.GetResolved?.contains(event.target)) {
    window.GetResolved?.hide();
  }
});
```

