# Frontend Javascript API

{% hint style="info" %}
As long as gramchat is initalized, you can access it via the global variable **chat**
{% endhint %}

### Visibility of chat window

#### gram.open()

Open the chat window

#### gram.close()

Close the chat window

#### gram.toggle()

toggle the open/close state of the chat window

#### gram.hide()

Hide the chat window and button

{% hint style="info" %}
You will not see gramchat on the website (with css`display:none`)
{% endhint %}

#### gram.show()

Show the chat window and button

### Messages

#### gram.push("your message to show")

Pushes the message (string) you pass in the function into the chat window **without sending it to the server**


---

# 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://gramchat.gitbook.io/documentation/frontend-javascript-api.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.
