---
title: "Context and variables"
description: "Learn the types of context variables, such as dialog, user, system, and bundle variables, tags, live instructions, and email Cc."
---

# Context and variables

> Learn the types of context variables, such as dialog, user, system, and bundle variables, tags, live instructions, and email Cc.

## Overview

In Moveo, store temporary information during a conversation using **context variables**.
These variables apply only to a specific conversation and are automatically deleted once the
conversation ends. Context is a collection of key-value pairs that help AI agents make decisions,
store state, and enhance dialog interactions.

Context variables can be set at different levels:

- **Environment level** (see [Context Bundles](https://docs.moveo.ai/docs/environments/context-bundles.md))
- **Agent level** (within AI agents and dialogs)

Additionally, context can store user-related information, such as their name, email, or other
relevant data.

## Types of context variables

### Dialog variables

Create and store variables within a dialog using [questions](https://docs.moveo.ai/docs/ai-agents/operations/questions.md).
These variables are flexible and can be named as needed.

### User variables

User-related information is stored in specific system-defined variables, including:

- **`$user.display_name`**: User's name
- **`$user.email`**: User's email address
- **`$user.user_id`** or **`$user.external_id`**: Unique user ID (depends on the communication
  channel)

Some user variables, such as user IDs, are automatically assigned by the system, while others
require manual input via **questions** or **forms** at the start of a conversation.

:::warning
User variables **cannot be set directly**. To assign a value using a
[**Set Variable** action](https://docs.moveo.ai/docs/ai-agents/operations/set-variables.md), select the appropriate key (for example,
`$user.display_name`).

For webhook responses, refer to the [Webhook reference](https://docs.moveo.ai/docs/ai-agents/dialog-webhooks.md#what-gets-sent-and-received).
:::

### System variables

Moveo provides system-generated variables that contain essential metadata about the conversation:

| Variable                    | Description                                                       |
| --------------------------- | ----------------------------------------------------------------- |
| `$sys-channel`              | Communication channel of the conversation                         |
| `$sys-unknown_counter`      | Number of times a [fallback](https://docs.moveo.ai/docs/ai-agents/triggers/unknown.md) was triggered |
| `$sys-business`             | Indicates if the conversation occurs within business hours        |
| `$sys-desk`                 | Identifies the conversation environment                           |
| `$sys-session`              | Unique conversation ID                                            |
| `$sys-user_message_counter` | Number of messages sent by the user                               |

:::note
The **`$sys-unknown_counter`** variable is **zero-indexed**, meaning the first unknown
response occurrence is stored as `0`.
:::

### Bundle variables

Import variables from **[Context Bundles](https://docs.moveo.ai/docs/environments/context-bundles.md)** associated with different
environments. These variables follow the format: `{{$global.bundle.variable}}`.

### Tags

[Tags](https://docs.moveo.ai/docs/ai-agents/operations/tag.md) assigned by the AI agent during a conversation are stored in
**`$tags`** as a list. For example, if the assistant assigns `location` and `hours` tags, `$tags`
contains `['location', 'hours']`.

This variable is useful for:

- Filtering conversations in **[Analytics](https://docs.moveo.ai/docs/analytics/analytics-overview.md)**
- Triggering specific actions using **[Rules](https://docs.moveo.ai/docs/environments/environments-rules.md)**
- Enhancing human-agent interactions (agents can manually assign tags)

To add a new tag, use the **`Add Tag`** dialog action.

### Live instructions

The `live_instructions` variable allows real-time updates to the AI agent, guiding its behavior
dynamically based on external input.

### Cc recipients for email

On an [email](https://docs.moveo.ai/docs/integrations/email.md) conversation, two context variables set the Cc
recipients of the AI agent's replies:

| Variable             | Who sets it                                       | What it holds                                            |
| -------------------- | ------------------------------------------------- | -------------------------------------------------------- |
| `$channels.email.cc` | Moveo, on each inbound email                      | The Cc and other To recipients of the last inbound email |
| `$email_cc`          | You, with a **Set variables** action or a webhook | Extra Cc recipients for the AI agent's replies           |

Both variables hold one comma-separated string, like the **Cc** field of an inbox:
`ana@example.com, billing@example.com`.

Each AI agent reply copies the addresses in `$channels.email.cc` first, then the addresses in
`$email_cc`. Moveo removes repeated addresses and the address that the reply goes to.

Moveo replaces `$channels.email.cc` on each inbound email. The value lists the Cc recipients and
any To recipients other than your AI agent's address. Moveo keeps the first 10 addresses, in
lowercase, without display names. An inbound email with no Cc and no other To recipient sets the
value to an empty string. A webhook or a **Set variables** action cannot change this variable.

`$email_cc` follows these rules:

- It holds at most 10 addresses and 1,024 characters. Moveo ignores empty entries.
- Each entry is one bare address, such as `ana@example.com`. A display name, such as
  `"Ana Lopez" <ana@example.com>`, is not valid.
- When one entry is not valid, Moveo rejects the whole value and keeps the previous one.
- An empty string removes all the addresses.
- The value stays when a new inbound email arrives, even an email without Cc.

:::note
Human agent replies copy only the addresses in `$channels.email.cc`. The `$email_cc` addresses go
on AI agent replies only.
:::

## Using context in dialogs

Context variables enable various dialog functionalities, such as:

- **Setting new variables**
- **Updating existing ones**
- **Deleting variables**
- **Making decisions using conditions** ([Learn more](https://docs.moveo.ai/docs/ai-agents/operations/conditions.md))

For example, you can check whether a user has provided their email and prompt them accordingly if
it's missing.

### Ways to set context variables

- **[Questions](https://docs.moveo.ai/docs/ai-agents/operations/questions.md)**: Collect information during a dialog.
- **[Webhooks](https://docs.moveo.ai/docs/ai-agents/ai-agents-webhooks.md)**: Update variables in real time based on external data.
- **[Set Variable action](https://docs.moveo.ai/docs/ai-agents/operations/set-variables.md)**: Directly assign values in dialogs.

## Using context variables

Reference variables in the dialog by using `{{$variable}}`.

For example:

```plaintext
Hello {{$user.display_name}}, how can I assist you today?
```

Refer to the documentation for more guides on handling context variables effectively.
