> For the complete documentation index, see [llms.txt](https://docs.smartbotpro.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.smartbotpro.io/scripts/basics/how-the-script-is-chosen.md).

# How the script is chosen

Before reading, we recommend that you read the [article about scripts. ](https://app.gitbook.com/o/-M0DMiuC0q5onO-ID_le/s/uRfd5lEYYH6D50QjzeAX/~/changes/996w3IhouLXkvHdJdNpB/beginning-of-work/more-about-scripts)

When an event occurs, to which you set a reaction in one of the scenarios, the bot starts checking the scenarios to find the best one.&#x20;

For example, you have created several scripts and in each of them you have set a "user input" event with the expectation of a particular message.&#x20;

When the subscriber writes one of these messages to the bot, or another script trigger condition is triggered, the bot will start executing the corresponding chain.&#x20;

Note that within a script, you can specify multiple chains at once. To do this, it is enough to create several start events inside the script:

![](/files/qiJy9c3Lx5TWkmtBgEJp)

The screenshot shows 3 events, from which there are different chains. But all these events are combined into one scenario. In fact, a script is a set of events and bot logic united by one subject area. For example, you can make a "delivery questions" script and add several chains there that will answer the questions "what cities do you deliver to", "how long does it take for delivery", "how much does delivery cost", and so on.


---

# 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.smartbotpro.io/scripts/basics/how-the-script-is-chosen.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.
