Skip to main content

Variable

Uncontrolled node

Overview

The Variable node retrieves values from the workflow's variable store. Variables allow you to persist data across different nodes and workflow executions. This node looks up variables by name and outputs their current value, checking the local scope first (current workflow/parent) and falling back to the global scope (root workflow) if not found.

You can use dot notation (e.g., user.profile.name) to access nested properties within objects, and Handlebars syntax (e.g., {{prefix}}_{{id}}) to dynamically construct variable names based on other inputs.

Inputs

InputTypeDescriptionDefault
NameTextThe name of the variable to retrieve. Supports dot notation for nested objects (e.g., data.user.name) and Handlebars templating for dynamic names.-

Outputs

OutputTypeDescription
ValueDataThe value stored in the specified variable. Returns the string 'undefined' if the variable does not exist in either local or global scope.

Runtime Behavior

When the Variable node executes, it performs the following steps:

  1. Template Processing: If the name input contains Handlebars syntax (e.g., {{variableName}}), it processes these templates using available data from parent variables and inputs.
  2. Scope Resolution: It first attempts to resolve the variable path in the local scope (parent workflow variables). If not found, it checks the global scope (root workflow variables).
  3. Path Traversal: Supports advanced dereferencing using dot notation (e.g., user.address.city) to access nested object properties.
  4. Output: Outputs the resolved value, or the string 'undefined' if the path cannot be resolved.
Variable Scope

Variables set using the Set Variable node in the same workflow (local scope) take precedence over variables set at the root workflow level (global scope). Use the isGlobal property on Set Variable to explicitly control where variables are stored.

Example

Scenario: Retrieve a user's score that was previously stored in a variable.

  1. Connect a Text node containing "userScore" to the Name input of the Variable node.
  2. The Value output will contain the data previously stored in the userScore variable (e.g., 100 or {points: 100, level: 5}).
  3. If you stored a nested object and want to access a specific property, set the Name input to "userScore.points" to retrieve just the points value.

Dynamic Variable Names: If you have variables named item_1, item_2, etc., you can use Handlebars syntax in the Name input: item_{{index}}, where index is an input from another node containing the number 1, 2, etc.