---
title: "Context bundles"
description: "Create, import, or merge context bundles in an environment, apply them with a rule, and use their variables in dialogs."
---

# Context bundles

> Create, import, or merge context bundles in an environment, apply them with a rule, and use their variables in dialogs.

Context bundles automatically import [variables](https://docs.moveo.ai/docs/ai-agents/context.md) into the
conversation. To open the context bundles menu, select an environment.

## Uses of context bundles

Context bundles help in many scenarios, such as:

- Different variable values for different languages
- Webhook variables that you can edit at any time without changing code
- Different information within the same AI agent, depending on the environment

## Add a context bundle

1. Open your environment and select the **Context bundles** tab.
2. Select **Add**.
3. Enter a **Name** and, optionally, a **Description**. Then select **Create**.
4. Enter each variable key and its value.
5. Select **Save and close**.

## Upload a context bundle

Upload your context bundle from a JSON file. Two methods are available:

### Import a new bundle

You can import your context bundle the same way that you import an AI agent. Enter a name and a
description, and select your JSON file to import it as a separate bundle.

### Merge bundle

Upload your bundle into an existing one to merge all variables. When a variable conflicts, either
keep the original value or replace it with the uploaded one.

## Use a context bundle

After you create a context bundle, you can use it in your AI agent as context variables. To do
this, first apply the context bundle to the conversation with a rule, and then you can
use the variables in a [dialog](https://docs.moveo.ai/docs/ai-agents/dialogs.md).

### Apply a context bundle

1. Go to **Deploy → Rules**.
2. Select **+ Create**.
3. Select the conditions that apply the context bundle.
4. In **Actions**, select **+**, and then select **Apply bundle**.
5. Choose the context bundle you want to apply.
6. Depending on your conditions, you may want to assign an AI agent too.
7. Activate the rule.
8. Save changes.

### Use the variables

In a dialog, you can use the variables from the context bundle by using the
`{{$global.bundle.variable_name}}` syntax. For example, if you have a variable `name` in your
context bundle, you can use it in a dialog like `{{$global.bundle.name}}`. If you use the variable
before the rule applies the context bundle, it shows as `%UNKNOWN` in the conversation, the same as
any other variable.

Every bundle has a preset property `bundle` with its name, so you can use it in your dialog as
`{{$global.bundle.bundle}}`. This can be useful to differentiate between different bundles in the
same dialog using [conditions](https://docs.moveo.ai/docs/ai-agents/operations/conditions.md).

## Next steps

- [Context and variables](https://docs.moveo.ai/docs/ai-agents/context.md)
- [Rules](https://docs.moveo.ai/docs/environments/environments-rules.md)
- [Environments](https://docs.moveo.ai/docs/environments/environments-overview.md)
