# Working with variables

## How to get client variable values

get\_client\_var() | get\_client\_vars()

<details>

<summary>Description</summary>

<mark style="background-color:blue;">**To get the value of a single variable**</mark>

**get\_client\_var(client\_id, variable)**

Parameters:\ <mark style="color:red;">**!**</mark>**&#x20;client\_id -** client ID\ <mark style="color:red;">**!**</mark>**&#x20;variable -** variable name

<mark style="background-color:blue;">**To get the values of multiple variables**</mark>

**get\_client\_vars(client\_id, names)**

Parameters:\ <mark style="color:red;">**!**</mark>**&#x20;client\_id -** client ID\ <mark style="color:red;">**!**</mark>**&#x20;names-** array of variables

</details>

<details>

<summary>Example</summary>

Let's send the manager a message with the lesson number that one of the participants in our project is taking:

<div data-with-frame="true"><figure><img src="/files/eiVkeIiu26R2QmZQt1lc" alt="" width="563"><figcaption><p>Example of using the function to get a variable’s value</p></figcaption></figure></div>

<div data-with-frame="true"><figure><img src="/files/EABOr9Bu6KqtcHdGb2R3" alt="" width="375"><figcaption><p>Function result</p></figcaption></figure></div>

The same option, but with output, for example, of the level and the lesson within it:

<div data-with-frame="true"><figure><img src="/files/i7C0Pe1JBMaq1tIMQuYu" alt=""><figcaption><p>Example of using the function to get multiple values</p></figcaption></figure></div>

<div data-with-frame="true"><figure><img src="/files/xUxWyqL8ODm8cM8A73vq" alt="" width="350"><figcaption><p>Function result</p></figcaption></figure></div>

</details>

<details>

<summary>Code example for copying</summary>

```
/*Getting a single variable*/
trial=get_client_var(64732310, 'lesson')

/*Getting multiple variables*/
names=["level","lesson"]
trial=get_client_vars(64732310, names)
```

</details>

## How to assign a client variable

set\_client\_var() | set\_client\_vars()

<details>

<summary>Description</summary>

<mark style="background-color:blue;">**To assign a single variable value**</mark>

**set\_client\_var(client\_id, variable, value)**

Parameters:

**client\_id** — MaviBot client ID\
**variable** — a name of the variable to be assigned\
**value** — the variable value

<mark style="background-color:blue;">**To assign multiple variables**</mark>

**set\_client\_vars(client\_id, variables\_dict)**

Parameters:

**client\_id** — MaviBot client ID\
**variables\_dict** — dictionary; contains all variable names and their values to be added. \
Format:\
'{"var\_name1": "var\_value1", "var\_name2": "var\_value2", "var\_name3": "var\_value3"}'

</details>

<details>

<summary>Example</summary>

Example 1:

set\_client\_var(client\_id, "new", "yes")

<div data-with-frame="true"><figure><img src="/files/fDwStmPglckcRAufL2o6" alt="" width="563"><figcaption></figcaption></figure></div>

<div data-with-frame="true"><figure><img src="/files/a84sCRlYZIHnUcfuZhfc" alt=""><figcaption></figcaption></figure></div>

Example 2:

set\_client\_vars(1136, '{"var\_name1": "var\_value1", "var\_name2": "var\_value2", "var\_name3": "var\_value3"}')

<div data-with-frame="true"><figure><img src="/files/5WbATS5XUZzA0ddF8MQ4" alt=""><figcaption></figcaption></figure></div>

Variables section in the client card

<div data-with-frame="true"><figure><img src="/files/7OGpWGqjMJmqXPGqyk3S" alt=""><figcaption></figcaption></figure></div>

&#x20;

</details>


---

# 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.mavibot.ai/chatbot/functions/calculator/variables.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.
