All nodes/Data/Values & State
Variable
Declares a variable with a name, type, and initial value. The variable can be session-scoped (lives within an execution) or thread-scoped (persisted in the DB between messages). Connects to VarSet for writing.
Type in the graph: var
Stateful
Try it
Reading a variable in a template
The variable's value reaches the template through its "Var" port.
- Execute + Data
- Data
Runs as pasted
When to use it
A variable is what you need when a value has to outlive a step: a request counter, the chosen language, a list built up along the way, a “we already said hello” flag. This node declares a variable — name, type and default — and reads it. Writing is done by its neighbour Set variable; declared variables are also visible to, and writable from, the JavaScript node.
If the value never changes, you do not need a variable — use a Const.
Three scopes
- Session — lives for one run. The value is shared by every branch of that run, including nested sub-workflows.
- Thread — persisted, and survives across the messages of one conversation: the next turn in the same chat, or in the same Telegram topic, reads what was written.
- Call — not stored at all: every read returns the default and every write is ignored. Handy for switching persistence off temporarily without taking the graph apart.
How it works
The node has no execution ports — it is a source of a value. Unlike a constant, a variable is re-read on every access, so a node placed after “Set variable” sees the new value.
There are three ways to read it: an edge from its output into the consumer’s port; the “Var” port
of a template (where the value is available as {{ var }}); and {{ variables.<name> }} — which
works for the Session scope only.
Common mistakes
- Two declarations of one name is a validation error. A graph with two Var nodes sharing a name will not deploy: one name, one node — read it from as many places as you like.
- A variable triggers nothing. An edge from it does not activate the consumer; a step with no other incoming trigger simply will not run.
- Thread scope without a conversation is one run. The value is tied to a conversation; in a one-off run (a manual test, a webhook with no session) there is nothing to carry it between runs, and the variable lives exactly as long as the run.
{{ variables.<name> }}is empty before the first read. The default lands in the variable when the Var node is first read. A template that reaches for it earlier renders nothing — reading through the port is the reliable way.
Inputs
—
Outputs
| Port | Wire | Payload | Notes |
|---|---|---|---|
Valueoutput | Datadata | object |
Configuration
| Field | Type | Default | Description |
|---|---|---|---|
Default Valuedefault_value | string | "" | Default value for variable |
Scopescope | string | session | Variable scope: session — lives for one execution; thread — persisted in the database between messages; call — never stored, every read returns the default Options: |
Variable Namevar_name | string | my_var | Variable name |
Typevar_type | string | string | Variable type Options: |