# Triggers

## Installation

Simply include the trigger script after the end of your body

```markup
<script src="https://static.gramchat.me/triggers.gram.js"></script>
```

{% hint style="info" %}
Please keep in mind, that you need an already setup gramchat for this trigger functions to work
{% endhint %}

## MessageOnScrollPercent(percent, message)

Automatically open gramchat and prompt the user with a message if he/she scrolled down on your page for a certain percentage

```markup
<script>
MessageOnScrollPercent(80, "This message will pushed to gramchat 
if the user scrolled down 80% of the page");
</script>
```

## MessageOnMouseLeave(message)

Automatically open gramchat and prompt the user with a message the moment the mouse fades out of the window.

```markup
<script>
MessageOnMouseLeave("Thanks for visiting our page! Bye");
</script>
```

## MessageOnHover(htmlID, message)

Automatically open gramchat and prompt the user with a message if he/she hovers over the given element

```markup
<div id="messageOnHoverDIV">Hover here</div>
<script>
MessageOnHover("messageOnHoverDIV", "You hovered over the div");
</script>
```

## MessageOnClick(htmlID, message)

Automatically open gramchat and prompt the user with a message if he/she clicks the given element

```markup
<div id="messageOnClickDIV">Click here</div>
<script>
MessageOnClick("messageOnClickDIV", "You clicked on the div");
</script>
```


---

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