header
login

Variables (add_var)

The add_var function creates or modifies variables in the current workflow. Variables are used to store data between workflow steps.

Setting a Variable

In the function parameters, specify name-value pairs:

{
  "username": "{=tgData.from.first_name=}",
  "counter": "0",
  "greeting": "Hello, {=tgData.from.first_name=}!"
}

Each key becomes the variable name, the value becomes its content.

Value Types

  • Text: "Hello"
  • Number: "5", "3.14"
  • Variable: "{=message=}"
  • Template: "User {=username=} wrote: {=message=}"

Using in Subsequent Functions

Once created, the variable is available in all subsequent functions via {=name=} syntax:

Hello, {=username=}! Your counter: {=counter=}

Examples

Saving User Data

{
  "user_id": "{=tgData.from.id=}",
  "user_name": "{=tgData.from.first_name=}"
}

Counter

{
  "counter": "1"
}

Saving User Choice

{
  "user_choice": "{=message=}"
}

Display in Editor

On the canvas, the block shows the first variable name for quick identification.