Variables enable dynamic computation and data transformation, acting like spreadsheet formulas that calculate values in real-time based on user responses and other data sources. Transform, calculate, and derive new values from existing data without requiring server-side processing. Variables

How Variables Work

Real-time Evaluation

Variables update instantly as users provide responses, enabling dynamic content and calculations throughout your chatflow.

Aliases & Expressions

Create readable names for data sources, then write JavaScript expressions using these aliases to perform calculations.

Chaining Capability

Variables can reference other variables, enabling complex multi-step calculations and data transformations.

Transparent Calculations

All calculations are visible and auditable through JavaScript expressions, ensuring complete transparency.

Common Use Cases

Financial Formulas & Computations
  • Basic arithmetic: income * 12 for annual salary
  • Advanced math: Math.pow(), Math.sqrt(), Math.round()
  • Financial calculations: loan payments, compound interest, ROI
  • Statistical operations: averages, percentages, ratios
// Calculate BMI
weight / (height * height)

// Monthly loan payment calculation  
principal * (rate * Math.pow(1 + rate, months)) / (Math.pow(1 + rate, months) - 1)

Variable Editor

Expression System

Variables use aliases connected to JavaScript expressions:
1

Create Aliases

Define readable names for your data sources:
  • userAge instead of complex resource references
  • monthlyIncome for salary responses
  • creditScore from external API calls
2

Write Expressions

Use JavaScript with your aliases to create calculations:
// Simple calculation
userAge >= 65 ? pensionAmount * 1.2 : pensionAmount

// Complex financial formula
Math.min(monthlyIncome * 0.28, (monthlyIncome * 0.36) - monthlyDebt)
3

Test & Validate

Use the expression tester with mock values to ensure your logic works correctly before deployment.
4

Deploy & Reference

Use your variables throughout the chatflow in messages, conditions, and other variables.

Editor Features

Smart Autocompletion

  • Ctrl+Space triggers intelligent suggestions
  • Auto-detects available response fields
  • Suggests variable names and functions
  • Context-aware completions

Alias Management

  • Visual mapping of aliases to data sources
  • Automatic detection of undefined aliases
  • Smart suggestions for missing connections
  • Resource browser integration

Expression Testing

  • Test expressions with mock values
  • Validate complex calculations
  • Debug multi-step logic
  • Preview results before deployment

Error Handling

  • Built-in null checking capabilities
  • Default value support
  • Type validation assistance
  • Runtime error prevention

Where to Use Variables

Variables integrate seamlessly throughout your chatflow:

Real-World Examples

Financial Services

// Calculate maximum loan amount
Math.min(
  monthlyIncome * 0.28 * 12 * loanTermYears, 
  (monthlyIncome * 0.36 - monthlyDebt) * 12 * loanTermYears
)

Health & Insurance

// Body Mass Index with classification
weight / Math.pow(height / 100, 2)

Best Practices

Descriptive Naming

Use Clear Variable NamesChoose names that explain the variable’s purpose:
  • monthlyMortgagePayment not payment
  • userAgeInYears not age
  • totalAnnualIncome not income

Error Prevention

Handle Edge CasesInclude validation and default values:
// Safe division with fallback
income > 0 ? expenses / income : 0

// Null checking
userName ? userName.trim() : "Guest"

Modular Design

Break Down Complex LogicCreate smaller, reusable variables:
  • grossMonthlyIncomenetMonthlyIncomeloanEligibility
  • Build calculation chains step by step
  • Make debugging easier

Documentation

Document Complex FormulasUse descriptive variable names and comments:
  • Explain business rules and assumptions
  • Document data sources and calculations
  • Include examples of expected inputs/outputs

Performance & Reliability

Real-time CalculationVariables are calculated instantly as users progress through your chatflow:
  • Lightweight Processing - Client-side JavaScript execution
  • No Server Delays - Calculations happen in the user’s browser
  • Dynamic Updates - Values refresh automatically as inputs change
  • Reliable Performance - No external dependencies for basic calculations
Calculation LimitationsVariables support standard JavaScript with some restrictions:
  • Synchronous only - No async operations or API calls
  • No function declarations - Use expressions and built-in functions
  • Client-side only - Complex server-side calculations should use triggers
  • Memory limits - Very large datasets should be processed server-side