Skip to main content

Set variables

The Set variables action creates or modifies variables during a conversation. Use variables to store information, track state, and personalize responses.

How to set a variable​

  1. Open your dialog in the editor
  2. Add a Set variables action to your flow
  3. Enter the variable name (key)
  4. Set the value (text, number, or reference to another variable)
  5. Save your changes
The Set variables action that sets $preferred_language to Spanish.The Set variables action that sets $preferred_language to Spanish.

Variable types​

TypeExampleUse case
Text"premium"User preferences, status flags
Number42Counters, quantities, scores
BooleantrueFeature flags, confirmation states
Reference{{$user.email}}Copy value from another variable

Common use cases​

Track conversation state​

variable: $step_completed
value: "payment"

Store user preferences​

variable: $preferred_language
value: "Spanish"

Copy from user context​

variable: $customer_email
value: {{$user.email}}

Add Cc recipients to email replies​

On an email conversation, $email_cc adds Cc recipients to the AI agent's replies. Enter bare addresses or variable references, separated by commas, up to 10 entries:

variable: $email_cc
value: billing@example.com, {{$account_manager_email}}

For the full rules, see Cc recipients for email.

Best practices​

  • Use descriptive names - Choose clear names like order_total instead of val1
  • Keep scope in mind - Variables persist for the entire conversation
  • Initialize values - Set default values to avoid undefined references
  • Document your variables - Maintain a list of variables used in your dialogs

Accessing variables​

After setting a variable, access it in:

  • Text responses: Hello, {{$customer_name}}!
  • Conditions: Check if $customer_tier equals "premium"
  • Webhooks: Include variables in request payloads
  • URL responses: https://example.com?user={{$user.user_id}}

Next steps​