---
title: "Set variables"
description: "Use the set variables action to create or change context variables in a dialog, to track state and personalize replies."
---

# Set variables

> Use the set variables action to create or change context variables in a dialog, to track state and personalize replies.

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

## Variable types

| Type | Example | Use case |
|------|---------|----------|
| Text | `"premium"` | User preferences, status flags |
| Number | `42` | Counters, quantities, scores |
| Boolean | `true` | Feature 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](https://docs.moveo.ai/docs/ai-agents/context.md#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

- [Context variables](https://docs.moveo.ai/docs/ai-agents/context.md) - Learn about the context system
- [Questions](https://docs.moveo.ai/docs/ai-agents/operations/questions.md) - Collect and store user input
- [Conditions](https://docs.moveo.ai/docs/ai-agents/operations/conditions.md) - Use variables in conditional logic
