Variables

The Variables block updates workflow variables during execution. Variables must first be initialized in your workflow's Variables modal, then you can use this block to update their values as your workflow runs.

Variables Block

Access variables in supported input fields using <variable.variableName> syntax.

How to Use Variables

1. Initialize in Workflow Variables

First, create your variables in the workflow's Variables modal. Open the panel's More options menu (the ⋯ button at the top of the panel). Choose Variables. Give each variable a name, a type, and an initial value:

customerEmail = ""
retryCount = 0
currentStatus = "pending"

The Variables block only updates variables that already exist. It skips an assignment to a name that has not been created and writes a warning to the logs.

2. Update with Variables Block

Use the Variables block to update these values during execution:

customerEmail = <api.email>
retryCount = <function.result>
currentStatus = "processing"

Each assignment substitutes the references you write, then converts the text to the variable's type. It does not evaluate expressions. A value of <variable.retryCount> + 1 becomes the text 0 + 1, which is not a valid number. The block then fails with Invalid number value for variable "retryCount". To compute a new value, do the math in a Function block and assign its result:

// Function block inside the workflow
return <variable.retryCount> + 1;

// Variables block
retryCount = <function.result>

3. Access Anywhere

Reference variables in any block:

Agent prompt: "Send email to <variable.customerEmail>"
Condition: <variable.retryCount> < 5
API body: {"status": "<variable.currentStatus>"}

For a Judgment or Laya Decision block, put dynamic references in State. Its instructions and criteria must stay literal; reference tags in those fields fail validation.

Example Use Cases

Loop Counter and State - Track progress through iterations

Loop → Agent (Process) → Function (itemsProcessed + 1) → Variables (itemsProcessed = function.result, lastResult)

Retry Logic - Track API retry attempts

API (Try) → Function (retryCount + 1) → Variables (retryCount = function.result) → Condition (retryCount < 3)

Dynamic Configuration - Store user context for workflow

API (Fetch Profile) → Variables (userId, userTier) → Agent (Personalize)

Value Types and Limits

Every variable has a type, chosen when you create it. When a Variables block runs, it converts each assigned value to that type before storing it:

TypeConversionEmpty value becomes
Plain (text)Kept as text""
NumberParsed as a number. Text that is not a number fails the block0
Booleantrue or false (case-insensitive). Anything else fails the blockfalse
ObjectParsed as JSON. Must be a JSON object or array{}
ArrayParsed as JSON. Must be a JSON object or array[]

The block inserts referenced outputs as text first (objects and arrays as JSON) and then converts them. So <function.result> returning 1 is stored as the number 1 in a Number variable. Likewise, {"a":1} is stored as an object in an Object variable.

All variables in a run together may use at most 64 KiB when serialized as JSON. An assignment that would push the total over the limit fails the block with a message such as Workflow variables use 70,000 bytes; maximum is 65,536 bytes. No variable from that block is updated. Values must also be JSON-safe: no cyclic structures and no infinite or NaN numbers.

Outputs

The Variables block is not meant to be wired like other blocks. Variables are accessed globally via <variable.variableName> syntax from any block in the workflow. The block does expose each assignment as an output, <blockname.variableName>, holding the value it just assigned. Still, <variable.variableName> is the reference to use.

Best Practices

  • Initialize in the Variables modal: Always create variables in the workflow Variables modal before using them
  • Update dynamically: Use Variables blocks to update values based on block outputs. Compute derived values in a Function block first
  • Use in loops: Perfect for tracking state across iterations
  • Name descriptively: Use clear names like currentIndex, totalProcessed, or lastError

Common Questions

No. Variables are workflow-scoped and only persist for the duration of a single execution. Each new execution starts with the initial values defined in your workflow's Variables modal.
Yes. All Variables blocks share the same namespace. A later Variables block can overwrite a value set by an earlier one by using the same variable name.
Use the <variable.variableName> syntax in supported input fields. For example, <variable.retryCount> or <variable.customerEmail>. In a Judgment or Laya Decision block, put dynamic references in State; instructions and criteria must be literal.
Each assignment appears as an output of the block (<blockname.variableName>) holding the value just assigned, so the tag dropdown lists them. In practice you reference variables globally via the <variable.variableName> prefix from any block in the workflow. That works whether or not the block is connected.
Use descriptive names in camelCase or snake_case. Variable names are case-sensitive, so 'retryCount' and 'RetryCount' are treated as different variables.
Yes. You can reference any block output when setting a variable value, such as setting customerEmail to <api.email>. To increment a counter or otherwise compute a value, put the expression in a Function block (return <variable.retryCount> + 1) and assign <function.result>. The Variables block itself does not evaluate arithmetic.
The block converts each assignment to the variable's type. A number variable must receive text that parses as a number. A boolean must receive 'true' or 'false'. Object or array variables must receive valid JSON. Check that the referenced output has the shape you expect. Also check that you are not writing an expression such as <variable.count> + 1, which the block cannot evaluate.

On this page