# Introduction

SmartQuery (SQ) is a scripting programming language created specifically to extend the capabilities of Smartbot chains.

## Why do you need SmartQuery?  <a href="#zachem-nuzhen-smartquery" id="zachem-nuzhen-smartquery"></a>

* Creating complex conditions in chains (combination of AND and OR)&#x20;
* Working with arrays and dictionaries (promo codes, inventory, word guessing, shopping cart, ...)&#x20;
* Substitution of calculated values ​​in the text of messages (same as regular variables, but you can use arithmetic)&#x20;

## Some examples <a href="#nekotorye-primery" id="nekotorye-primery"></a>

```
# complex conditions
%sex% == 'male' and %ref% == '1' or %sex% == 'female' and %ref% == '2'

# work with arrays
%cart%.push('perfume')
%cart%.push('webinar')

# substitution of expression values ​​in message text
Your balance: {{ %balance% + %premium% }}
```

SmartQuery can be used everywhere where only ordinary variables could be used before: in the text of messages, in mailing lists, conditions and on landing pages.


---

# 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://docs.smartbotpro.io/smartquery/introduction.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.
