# Chat

## Trigger Chat Programmatically&#x20;

By default, chat is only opened when a visitor clicks on the chat launcher displayed on your site. If you would like a button or another element on your site to control the chat state, you can take advantage of the messenger API.&#x20;

Utilizing the `LO.messenger` API, you can control the state by calling `open()` or `close()` .

```javascript
function openChat () {
    LO.messenger.open()
}

function closeChat () {
    LO.messenger.close()
}
```

{% hint style="warning" %}
The `LO.messenger` API is only available once chat has been set up for your site.
{% endhint %}

The chat launcher can also be completely hidden, should you desire to control the chat state exclusively through an element on your site. You can find this and other chat launcher settings in the Lucky Orange app under the **Chat Settings** tab, located within your site's **Settings** section.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.luckyorange.com/libraries/browser/chat.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
