Set Variable Node
Overview
The Set Variable Node lets builders create or update variables directly within a flow. It is designed for mid-flow calculations, data transformation, and state management without relying on an API response or Agent slot filling.
Builders can use it to perform tasks such as:
combining first and last names
calculating tax or totals
formatting API values for display
setting flags for downstream logic
preparing values for Branch Nodes or other nodes
Problem it solves
Supports mid-flow data updates
Before this feature, variables were only updated when:
an API returned data, or
an Agent filled a slot
There was no dedicated way to manipulate values during the flow itself.
Removes simple logic from Agents
Instead of asking an Agent to calculate, format, or derive values, the flow can now handle those tasks directly.
This improves reliability and reduces unnecessary LLM usage.
Makes flow logic more visible
Variable transformations are shown explicitly on the canvas.
This is easier to maintain than hiding logic inside prompts or backend services.
Why use the Set Variable Node
The Set Variable node helps you create, update, and transform data during a flow without relying on an LLM for simple tasks.
1. Data Flexibility
Convert raw data into more useful formats.
Combine, format, or calculate values as needed.
Examples:
Combine
firstNameandlastNameintofullName.Calculate
taxAmountfrom asubtotal.
2. Faster and More Cost-Effective
Performs simple calculations and formatting instantly.
Reduces unnecessary LLM calls, improving performance and lowering costs.
3. Clear Flow Logic
Makes data changes visible directly in the flow.
Helps builders easily understand where variables are created or updated.
4. Better Developer Experience
Provides a structured way to manage flow data and session state.
Makes it easier to build and maintain complex workflows.
5. Improved Reliability
Handles straightforward transformations without LLM interpretation.
Reduces the risk of incorrect outputs for simple operations.
How the Set Variable Node Works
1. Create or Update Variables
Create new variables or update existing ones.
New values can replace previous values when needed.
2. Multiple Assignments in One Node
A single node can contain multiple variable assignments.
Assignments are displayed as a list in the node configuration.
3. Sequential Execution
Assignments run from top to bottom.
Variables updated in one row can be used by the next row immediately.
4. Expression Support
The node supports expressions for:
Mathematical calculations
String formatting
Boolean logic
JSON processing
Array operations
Other supported data transformations
User workflow
1. Add the node to the flow
In the Flow Editor, drag a Set Variable Node onto the canvas.
Place it where you need to create or transform data before the next step.
2. Add assignment rows
In the node sidebar or drawer, add one or more assignment rows.
Each row represents one variable assignment.
3. Configure each assignment
For each row, define:
Variable Name
Value
Type
4. Arrange assignments in order
Add more rows as needed.
The assignments are processed in the order shown.
Order matters when one row references a value created in a previous row.
5. Review the node summary
On the canvas, the node body displays the total number of assignments.
6. Connect the node
Wire the node’s single output handle to the next step in the flow.
7. Runtime execution
At runtime, the engine executes the assignments top-to-bottom.
After each row runs, the flat session context is updated immediately.
This allows the next row to reference values created earlier in the same node.
Example use cases
Refer to this tutorial demonstrates how to build, validate and test a customer v2 flow using the Flow editor - Build Flow
Use Case: Loyalty points calculation
This is a customer rewards tier calculation workflow that determines a member's loyalty tier based on their points and displays the appropriate message.
Step 1: Start
The flow begins when the workflow is triggered.
Node:
start
Step 2: Say Node - Display Welcome Message
A greeting message is shown to the user.
Node Name
Greetings
Message
Welcome to Demo Rewards! Let's spin up a sample member and check their tier.
Purpose
Introduces the rewards program.
Informs the user that the system will check a sample member's rewards status.

Step 3: Initialize Member Points - Set Node 1
The flow sets an initial points value for the member.
Name
seed_points
Variable to Set
Creates or assigns a value to the
pointsvariable.This acts as sample member reward points.
Variable: Points
Set to: Math.floor(Math.random() * 3000)
Type: Number
Purpose
Provides input data for tier calculation.

Step 4: Calculate Tier Information - Set Node 2
The system computes the member's tier and any bonus points.
Name
compute_tier
Variable to Set 1
Variable: bonus_points
Set to: Math.round(points * 0.15)
Type: Number
Variable to Set 1
Variable: total_points
Set to: points + bonus_points
Type: Number

Step 5: Error Handling (if calculation fails)
If there is an issue during the tier calculation, the flow follows the Error path.
Node: calc_error
Message: "Sorry, something went wrong computing the tier."
End.
Step 6: Route User to Appropriate Tier
If calculation succeeds, the flow proceeds to a branching decision.
Name
route_tier
Branching Rule 1
Expression: total_points >= 2000
Branch Name: platinum
Branching Rule 2
Expression: total_points >= 1000
Branch Name: gold
Branching Rule 3
Expression: total_points >= 500
Branch Name: silver
Branching Rule 4
Expression: total_points > 0
Branch Name: bronze

Step 7: Say Node
Node Name
platinum_message
gold_message
silver_message
bronze_message
no_points_message
Message
This member has {{points}} points, plus a 15% bonus of {{bonus_points}}, for {{total_points}} total — that's PLATINUM tier! Concierge service and every perk unlocked.
This member has {{points}} points, plus a 15% bonus of {{bonus_points}}, for {{total_points}} total — that's GOLD tier! Keep earning to reach Platinum at 2000.
This member has {{points}} points, plus a 15% bonus of {{bonus_points}}, for {{total_points}} total — that's SILVER tier! Free shipping unlocked.
This member has {{points}} points, plus a 15% bonus of {{bonus_points}}, for {{total_points}} total — that's BRONZE tier. Keep earning to reach Silver at 500!
This member has no points yet. Make a purchase to start earning!
Allow barge-in
Yes
Yes
Yes
Yes
Yes
Step 8: End
All message nodes converge into the same endpoint.
Node: end
Purpose: Terminates the workflow after displaying the appropriate tier message.
Complete Flow:

Last updated
Was this helpful?