Set Variable Node
The Set Variable Node defines or updates a workflow variable for use later in your flow.
Store static or dynamic values to be accessed by other nodes downstream.
Purpose
- Storing Intermediate Results: Save output for later use.
- Parameter Configuration: Set dynamic parameters for other nodes.
- State Management: Maintain a counter, flag, or status.
- Data Extraction: Pull a specific value from complex input data for reuse.
Configuration
Configurable properties:
Property | Type | Description | Default |
---|---|---|---|
label | string (optional) | Descriptive name for the node instance. | 'Set Variable' |
variableName | string (optional) | Name of the variable to create or update. | 'myVar' |
variableValue | any (optional) | The value to set for the variable (static or dynamic, e.g., from input data). | '' |
Variable Value Syntax & Evaluation
Value types: variableValue
can be string, number, boolean, object, or array.
Static: Directly sets value (e.g., Hello World
).
Dynamic: Reference data from input using templating (e.g., {{input.user.id}}
).
Empty: If left blank, check if the variable becomes null
, undefined
, or triggers an error.
Refer to backend docs for syntax and resolution details.
Variable Scope & Access
Scope: Where is the variable accessible? (Global to the workflow? Local to a branch?)
Access in other nodes: How to reference? (e.g., {vars.myVar}
, flow.variables.myVar
)
Check backend/workflow documentation for exact usage.
Inputs and Outputs
Input (Left Handle):
Receives data from upstream, which can be referenced in variableValue
if dynamic.
Output (Right Handle, id: "output"
):
Emits the exact same data it received; the node's purpose is to set a variable as a side effect.
Logic of Execution
- Receives input data.
- Evaluates
variableValue
(static or from input). - Sets or updates
variableName
to that value, according to scope rules. - Emits the original input data unchanged.
Example: Storing a User ID from API Response
Input Data Example:
{
"userProfile": {
"id": "user-789_abc",
"name": "Jane Doe",
"email": "jane.doe@example.com"
},
"status": "success"
}
Node Configuration:
- label: Store User ID
- variableName: activeUserID
- variableValue:
{{input.userProfile.id}}
Execution:
- Receives the input data above.
- Extracts
input.userProfile.id
("user-789_abc"
). - Sets workflow variable
activeUserID
to that value. - Passes original input to output.
- Downstream nodes can access
activeUserID
(e.g.,https://api.example.com/orders?userId={{vars.activeUserID}}
).
Notes and Considerations
- Variable Naming: Use clear names, follow a naming convention.
- Overwriting: Last set wins (within scope).
- Data Types: Ensure downstream compatibility.
- Debugging: Inspect variable values at various stages if the platform supports it.
The Set Variable Node enables state, parameterization, and dynamic logic for any workflow.