> For the complete documentation index, see [llms.txt](https://docs.chatlayer.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chatlayer.ai/~/changes/zWOY8fNiBBrqneKkuGvA/bot-answers/events.md).

# Events

Events are used to trigger a flow based on an event that happens in a certain conversation. Multiple types of events allow for widely varying use cases.

To add an event, go to the 'Events' module under Bot dialogs

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FRCXoIAe9WD66O9crnc1q%2Fimage.png?alt=media&amp;token=9eac8bbf-f9a7-4c42-9132-fd94efcbf2dd" alt=""><figcaption></figcaption></figure>

Create a new event and give it a name. In the dropdown menu, select what type of event you want to create.

## Variables changed event

This event allows you to guide the user towards a specific flow whenever a variable is changed. While creating a new “variables changed” event, you can select:

* Which variable do you want to watch
* Which bot dialog should be triggered whenever this variable changes

Whenever the variable is changed, for example in a go-to, when a button is clicked, or when an entity is detected, this event will be triggered. If the bot dialog triggered by the event has multiple messages, or connects to other bot dialogs, a go-to will show all of these.

If the bot dialog from where the variable was changed connects to other bot dialogs, these will be shown after the bot dialog of the event.

![](https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LLTwFwbOqJj4dDhg8Ju%2F-M0bNdk-aEhqurz6mg5T%2F-M0bPKUR72YKVfH-sehw%2Fimage.png?alt=media\&token=a672ea50-3994-4c05-8dc3-0a7628c3f4c1)

In this flow, for example, a variable is changed in a quick reply in the 'Change variable' bot dialog that triggers an event. This event triggers the 'Event triggered' bot dialog, which has a 'Go to' that points to 'Event triggered step 2'. After these messages, the flow is redirected to the 'Send back after event' action, where the following configuration is placed.

![](https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LLTwFwbOqJj4dDhg8Ju%2F-M0bNdk-aEhqurz6mg5T%2F-M0bQLJCtNGA7ZI9uNzU%2Fimage.png?alt=media\&token=e1ef5b36-9eca-4de6-bc51-eac4631706ab)

This results in the following flow:

![](https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fchatlayer-documentation%2F-LzHi-KRNJFx2l-oR3XJ%2F-LzHko00h37usGpJPyHf%2F2.png?generation=1579789009495447\&alt=media)

The changed variables are also stored in the user session, where you can access them in the `events.variablesChanged` array.

![](https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LLTwFwbOqJj4dDhg8Ju%2F-M0bNdk-aEhqurz6mg5T%2F-M0bQiQqeNniGa3Sgll7%2Fimage.png?alt=media\&token=2cf5a36e-0f5b-4101-9cc9-475fa294365a)

Our customers often use the 'variables changed event' to perform an API request through an [API action](/~/changes/zWOY8fNiBBrqneKkuGvA/integrations/custom-back-end-integrations.md) whenever a specific variable changes.

## Silence detected event

With this event you can steer the conversation in a new direction when the user stops responding.\
\
It allows you to configure which bot dialog is triggered if the bot detects a silence, or in other words: when the user does not respond for a certain period of time. You can set the amount of time after which the new dialog will be triggered in the duration field (in minutes).

Essentially, this event starts a timer after the bot's last message; if the user hasn't responded yet when the timer runs out, the bot will prompt the user with a new message of your choosing.

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FyYEQU6Q24qDhQ37yXVW1%2Fimage.png?alt=media&amp;token=cb847f51-57a3-4f4e-b98c-000af285ddf1" alt=""><figcaption></figcaption></figure>

The duration of silence can range from 1 minute to a maximum of 1440 minutes (24 hours).

It is possible to create multiple "Silence Detected" events for one bot. All "Silence Detected" events will start counting down at the same time. This means you can prompt the user at different intervals by setting up "Silence Detected" events with different durations. For example, using one event with a duration of 3 minutes and another of 30 minutes you can first ask the user if they want to continue the conversation after a few minutes silence and then reset the conversation after half an hour of inactivity.\
\
It's best not to create multiple events with the same duration. Otherwise the user will be spammed with multiple dialogs at once.&#x20;


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.chatlayer.ai/~/changes/zWOY8fNiBBrqneKkuGvA/bot-answers/events.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
