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

# Open and close

> Control the chat from your own code

Open the chat from your own button, close it, or hide the chat button on pages where it gets in the way.

```html theme={null}
<button onclick="DeskHoot.open()">Chat with us</button>
```

## Methods

**DeskHoot.open()** `void`

Opens the chat and moves focus into it. If the chat button was hidden, closing the chat brings the button back.

**DeskHoot.close()** `void`

Closes the chat and returns focus to where it was before.

**DeskHoot.hide()** `void`

Hides the chat button, and closes the chat if it is open. The chat stays loaded, so events keep arriving.

**DeskHoot.show()** `void`

Shows the chat button again after `hide()`.

## Open it when the page loads

Queue the call, so it runs as soon as the chat has loaded.

```html theme={null}
<script>
  window.DeskHoot = window.DeskHoot || [];
  DeskHoot.push(["open"]);
</script>
```

## Show unread messages on your own button

The `unread` event gives the number of messages the customer has not read yet.

```js theme={null}
DeskHoot.on("unread", ({ count }) => {
  document.querySelector("#chat-count").textContent = count || "";
});
```

## Related

> [card] [Events](https://docs.deskhoot.com/sdk/events.md)
>
> Run your code when something happens.

> [card] [Light or dark](https://docs.deskhoot.com/sdk/theme.md)
>
> Match your website's theme.

> [card] [Verify users](https://docs.deskhoot.com/sdk/identify.md)
>
> Show signed-in customers to your team.

> [card] [Methods](https://docs.deskhoot.com/sdk/methods.md)
>
> What `DeskHoot` can do.


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