Set Variable Block
What it does: Create or update variables within your workflow to store and reuse values throughout the process.
In simple terms: Variables are like labeled containers that hold information. Use Set Variable to store a piece of data - like a customer's name or a calculation result - so you can use it later in other parts of your workflow.
When to Use This
Use Set Variable when you need:
- ✅ Store values for later use
- ✅ Combine multiple pieces of information
- ✅ Transform data between steps
- ✅ Set default values
- ✅ Create calculated fields
Example: Store a customer's order total in a variable, then use it later to calculate tax and display the final amount.
Key Features
- Flexible Values: Store text, numbers, dates, or complex data
- Dynamic Assignment: Use values from other blocks
- Overwrite or Create: Update existing variables or make new ones
- Scope Control: Variables available throughout workflow
How Variables Work
- Name your variable: Choose a clear, descriptive name
- Set the value: What data to store
- Use later: Reference the variable in subsequent blocks
Setup Guide
Step 1: Add a Set Variable Block
Drag a Set Variable block into your workflow where you need to store data.
Step 2: Name Your Variable
Choose a name that describes what the variable holds:
| Good Names | Avoid |
|---|---|
| customerEmail | x |
| orderTotal | temp |
| discountAmount | var1 |
| shippingAddress | data |
Step 3: Set the Value
Define what value to store:
- Static value: A fixed value you type in
- Dynamic value: Reference from another block or variable
- Combined value: Mix text with variable references
Step 4: Use Your Variable
Reference your variable in later blocks using the variable picker or by typing the variable name.
Common Use Cases
Store User Inputs
Save customer responses from chat for use in later parts of the workflow.
Calculation Results
Store the result of a calculation or script output for use elsewhere.
Default Values
Set initial values that may be updated as the workflow progresses.
Formatted Data
Create a nicely formatted string combining multiple data pieces.
Flags and State
Mark whether certain conditions have been met (true/false values).
Counters
Keep track of iterations in loops or counts of items processed.
Value Types You Can Store
| Type | Example | Use Case |
|---|---|---|
| Text | "Hello World" | Messages, names, descriptions |
| Number | 42.5 | Calculations, counts, prices |
| Boolean | true/false | Flags, conditions, toggles |
| Date | 2024-01-15 | Scheduling, timestamps |
| List | [item1, item2] | Collections of items |
| Object | {name: "John"} | Structured data |
Combining Values
You can combine static text with dynamic values:
Template: "Hello, {{customerName}}! Your order total is ${{orderTotal}}"
Result: "Hello, John! Your order total is $125.00"
What You Get Back
After setting a variable:
- Variable stored: The value is saved for later use
- Confirmation: Success status of the operation
- Available throughout: Variable accessible in subsequent blocks
Tips for Success
- Use descriptive names - Future you will thank present you
- Set early, use often - Define variables before you need them
- Keep organized - Group related variables with similar naming
- Check for empty - Handle cases where data might be missing
- Update when needed - Variables can be changed throughout the workflow
Troubleshooting
| Problem | Likely Cause | Solution |
|---|---|---|
| Variable is empty | Never set or cleared | Verify Set Variable runs before use |
| Wrong value | Overwritten later | Check if variable is set multiple times |
| Not found | Typo in name | Verify spelling matches exactly |
| Type mismatch | Number stored as text | Check how value is being set |
Best Practices
- Name consistently - Use camelCase or snake_case throughout
- Document purpose - Add notes about what each variable stores
- Avoid overwriting accidentally - Be careful when reusing variable names
- Initialize early - Set default values at workflow start
- Clean up when done - Clear sensitive data when no longer needed