> 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/actions/set-variable.md).

# Set variable

{% hint style="info" %}
This action allows you to set and change the value of variables for the user at the right place in the script.&#x20;

Thus, you can accrue bonus points, save information from the user, set statuses and much more.
{% endhint %}

To set a variable, we add this action to the screen of our script by right-clicking in an empty space, or by selecting the desired action from the additional menu.

![](/files/o2PTvvLFz8AZESX5pHFa) ![](/files/jyfruCxQkg4VAH1pQghV)

In the block menu, we can give the action a name, choose which variable to change, or create a new variable.

![](/files/iRoUsYiPmjSecfX9YAwM)

For example, let's create a new variable for accrual and calculation of user's bonus points and call it "Points"

![](/files/7ZqshhjMG6J3rG8Kvo55)

A window for creating a variable will appear. Let's choose the variable type - number, so that it can be increased and decreased as needed.&#x20;

The access level is local, that is, its value will be different for each user.&#x20;

When everything is ready, click "Create":

![](/files/MFtfYfpJobTB7ooPt1kC)

Now in the block menu, increase its value by +1.&#x20;

Let's write a simple arithmetic operation in the right field:&#x20;

{{%Points%=%Points%+1}}

![](/files/rDcVIsXmcQIAS91F9OCA)

{% hint style="info" %}
Please note: for operations with variables, all expressions must be framed with double curly braces {{ }}&#x20;
{% endhint %}

By the way, you can write more complex mathematical calculations in the right field, as well as use the SmartQuery syntax. Excellent! We just have to link this block with the key user action, for which he will receive a bonus. Let's say we'll award points for the first post in a group.

![](/files/wDmyrlrH1UTtXTyqu9BQ)

You can also set several variables at once in one block by clicking the "Set one more variable" button

![](/files/mPeAiPiVS6SOsHKLFGxx)

Now you know how to work with the "Set Variable" action


---

# 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/actions/set-variable.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.
