Skip to content
Docs
Modules Constructor

Variables

[[name]] variables in the Multogram Modules Constructor: where they come from, value types, object fields and array elements, local and global variables in a multi-threaded module, viewing them in the inspector.

A variable is a named value that one action writes and others read. This is how data passes between actions: Telegram's answer, the account taken, a counter.

Where variables come from

  • An action's result. Many actions have a result variable — the Output Variable on the card. Send Message puts its result into [[sendResult]], Get Resource Value — into [[resourceValue]]. The name can be changed in the action's window.
  • Set Variable — writes the value you give, with the chosen type.
  • Function parameters — inside a called function they are available as variables with the same names.

A variable name starts with a letter or _ and consists of Latin letters, digits and _.

How to use them

In any field of an action, write the name in double square brackets:

Account [[account]].phone sent a message to {{chat}}
NotationWhat you get
[[user]]The whole value
[[user]].profile.idAn object field
[[items]][0]The first element of an array
[[user]].tags[2]An array element inside an object

The path goes outside the brackets

Write [[account]].session_path. The notation [[account.session_path]] won't work: the brackets hold only the variable name.

Value types

TypeExample
string — textHello
number — a number42, 3.14
boolean — yes or notrue, false
object — an object or array (JSON){"name": "John"}, ["a", "b"]

If a field contains only [[name]], the action gets the value with its type: a number, an object, an array. If the variable sits inside text, it turns into text: count=[[n]] → count=5.

Local and global variables

A module runs in several threads at once.

LocalGlobal
Created bySet Variable, an action's resultSet Global Variable
VisibleOnly in its own threadTo all of the module's threads
What forOne account's data: session, answer, targetShared counters and flags

Use local variables by default — threads don't interfere with each other. For shared counters there is Increment Global Variable, and for figures the user sees — the Statistics module.

Variables in the inspector

Inspector → Variables shows all variables with their type and value after a test. A value can be changed right there to check a branch of the scenario with different data.

Referring through another name

Sometimes the name of a variable or resource is stored in another value:

NotationWhat it does
{{(varName)}}The resource whose name is held in the varName variable
[[(resName)]]The variable whose name is held in the resName resource

If there is no name or it is empty, the notation stays as it is.

Updated

CookiesPrivacy Policy

We use essential cookies to run this site. With your consent, we will also use analytics cookies to improve it and marketing cookies to credit whoever referred you. You can change your choice at any time.