The core problem solved by the Variable Assignment Node is enabling workflows to 'write back' — persisting the output of a node into a durable variable, including session variables and built-in variables. When used inside a loop, it can also update intermediate loop variables, enabling data transfer across iterations.
Usage Example
The Variable Assignment Node writes the large language model’s output back into session variables, enabling variable propagation.
Adding the Node
Method 1: Add via the + Button
-
Hover your mouse over any node on the canvas (e.g., the Start node); a
+button automatically appears on its right side. -
Click the
+button and select Variable Assignment from the pop-up node list. The node will be automatically added to the canvas and connected to the upstream node.
Method 2: Drag from the Node Library
- In the left-hand node library, locate and select Variable Assignment.
- Drag the node onto the canvas at your desired location, then drag a connection line from the edge of an upstream node to this node.
Core Configuration
Configure Variables
Specify the target variable to assign to and its corresponding new value.
-
Variable: Select a target variable type from the dropdown menu:
- Session variables (configured in the top-right corner of the workflow canvas; persist for the duration of the session).
- Built-in variables (e.g.,
query,historyList, etc.). - Intermediate variables (available only inside loops; must be defined in the loop node configuration).
- Set Value: The new value for the variable. Supports referencing output variables from upstream nodes, or entering a static value directly.
Common Use Cases
| Scenario | Workflow Structure | Role of Variable Assignment |
|---|---|---|
| Saving conversation context | Processing node → Variable Assignment → Subsequent node | Writes extracted information from the current turn into a session variable, making it available in subsequent turns. |
| Context passing within a loop | Loop body: LLM → Variable Assignment → End of iteration | Writes the current iteration’s LLM output into an intermediate variable, accessible in the next iteration. |
| Early loop termination | Loop body: Conditional check → Variable Assignment → End of iteration | Sets a flag variable to true when a condition is met, triggering loop termination. |