> ## 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.

# Methods

> What DeskHoot can do

Every method is on `window.DeskHoot` once the script has loaded. To call one earlier, [queue it](https://docs.deskhoot.com/sdk/install.md#call-deskhoot-before-it-loads).

## Loading

**ready()** `Promise\<void\>`

Loads the chat now, without opening it. Resolves when the chat is ready and rejects if it cannot load. Without this call, the chat loads the first time it opens.

**destroy()** `void`

Removes the chat from the page and stops every listener.

## Showing and hiding

**open()** `void`

Opens the chat and moves focus into it.

**close()** `void`

Closes the chat and returns focus to where it was.

**hide()** `void`

Hides the chat button, and closes the chat if it is open.

**show()** `void`

Shows the chat button again.

See [Open and close](https://docs.deskhoot.com/sdk/control.md).

## Theme

**setTheme(theme)** `Promise\<\{ theme \}\>`

Sets the chat to `"light"`, `"dark"` or `"system"`.

**parameters**

**theme** `"light" | "dark" | "system"` *required*

The theme to use. `"system"` follows the visitor's device.

See [Light or dark](https://docs.deskhoot.com/sdk/theme.md).

## Customers

**setUser(identity)** `Promise\<\{ identified, ignored? \}\>`

Signs in a customer your server has signed.

**parameters**

**identity.user** `string` *required*

The description of the customer that your server signed.

**identity.hash** `string` *required*

The signature of `user`: HMAC-SHA256 with your signing key.

**reset()** `Promise\<\{ reset: true \}\>`

Signs the customer out and starts a fresh guest. Call it when the customer signs out of your product.

**getContext()** `Promise\<object\>`

Returns the IDs of the current customer and conversation session. It holds no messages.

**what you get back**

**customer\_id** `string`

DeskHoot's ID for the current customer.

**session\_id** `string | null`

The current conversation session, or `null` when there is none yet.

**context\_id** `string`

Identifies this customer and session together. Pass it back to `setMetadata()` to make sure you write to the same one.

**customer\_version** `number`

Goes up each time the customer's reported details change.

**session\_version** `number`

Goes up each time the session's reported details change.

**setMetadata(metadata)** `Promise\<object\>`

Saves details the browser reports about the customer or the current session. Your team does not see these, because a visitor can change anything their browser sends. For details your team should see, use [Verify users](https://docs.deskhoot.com/sdk/identify.md).

**parameters**

**metadata.customer** `object`

Changes to the customer's details: `set` is an object of fields to save, `remove` is a list of field names to delete.

**metadata.session** `object`

The same, for the current session only.

See [Verify users](https://docs.deskhoot.com/sdk/identify.md).

## Events

**on(event, handler)** `() =\> void`

Calls `handler` each time `event` happens. Returns a function that stops listening.

**parameters**

**event** `string` *required*

An [event name](https://docs.deskhoot.com/sdk/events.md#events).

**handler** `function` *required*

Called with the event's details.

**off(event, handler)** `void`

Removes a handler added with `on()`. Pass the same function.

See [Events](https://docs.deskhoot.com/sdk/events.md).

## More than one chat

**DeskHootClients.get(name)** `DeskHoot | undefined`

Returns the chat loaded with `data-client="name"`. Each one has all the methods above.

## Related

> [card] [Open and close](https://docs.deskhoot.com/sdk/control.md)
>
> Control the chat from your own code.

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

> [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.


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