> ## Documentation Index
> Fetch the complete documentation index at: https://koreai.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Using Variables

<Badge icon="arrow-left" color="gray">[Back to App Settings](/ai-for-service/app-settings)</Badge>

**Variables** help you capture values that are commonly used by different tasks, nodes, and other AI Agent elements. You can configure a variable as a key-value pair once in the App settings and substitute key with value at runtime during the conversation flow. By capturing frequently used values in a single place, variables provide the advantages of reusability and consistency. For example, let's say you are testing a flight booking app using a staging endpoint. If you configure the endpoint as a variable, it helps you to call the API from several places quickly. When you want to change the staging endpoint to production while publishing the App, it's easy. Similarly, variables can be used to externalize content for messages and prompts from the dialog flow definition. Platform allows App developers to define two types of variables - Environment and Content.

***

## Environment Variables

Environment Variables are global, reusable components which can be used in multiple places to define the App configuration. Every Environment Variable is a key-value pair. The Variable Keys can be used at various places in the App configuration. The platform will resolve/replace the Variable Keys with Variables Values during the conversation. Some of the typical use cases where a developer can use environment variables are:

* To manage the app across environments having different endpoint URLs. The app can be exported and imported based on the environment, and the infrastructure team will need to modify only the variable configuration file.
* To manage **Conditions** in the **Dialog Node** Transitions. Only the left-hand side of the transition condition uses Environment Variables. The right-hand side of the transition conditions doesn't use Environment Variables
* To define and manage the app response that's repeated within the app configuration as variables.
* Authorization Token
* Channel-related tokens and URLs

Post the release of v8.1 of the platform, for on-prem installations, multiple value sets can be stored for these environment variables using Collections, [refer here for more](/ai-for-service/app-settings/variables/collections).

<Note>Ensure that the Environment or Content variable name doesn't contain any hyphen.</Note>

***

### Restricting Sensitive Data

During the AI Agent definition, developers may create **environment variables** for sensitive data like credentials/keys. These variables are useful for connecting to other systems using service nodes or as a part of authorization profiles. However, environment variables are visible to all the developers with shared access to the AI Agent, especially when its definition is exported.

The latest Platform release introduces the **Secure Variable** feature for environment variables, which encrypts the added variable when enabled. This makes only the encrypted variable value visible to others and not the original value.

**Important Considerations**

* The **secure variable** is encrypted in the database and doesn't require any encryption key.
* The original value is used only internally for all service calls, language translation, etc. while executing the AI Agent definition.
* During the export of a secure variable through **App** or **environment variables** import, it has an empty value, so the original value isn't available in plain text.

**Leveraging Encrypted Environment Variable Values for Additional Modules**

You can use the encrypted environment variable values in the following modules in addition to the other supported modules:

* **Channel Configuration**: While configuring channels under **Channels & Flows > Channels**, you can use encrypted/regular environment variable values for all the fields including access token, access key, app ID, URLs, etc.
* **Languages**: Under **App Settings > Language Management > Translation Configurations**, while configuring the translation engine, you can use the regular/encrypted environment variable value (type `{{env.environment variable name}}`) to set up the encrypted variable name as the access key as follows:
  * The **Access Key** field for Google Translator or Microsoft Translator.
    <img src="https://mintcdn.com/koreai/Eq2VeGR7oOfXIGHO/ai-for-service/app-settings/variables/images/env-and-content-variables-img1.png?fit=max&auto=format&n=Eq2VeGR7oOfXIGHO&q=85&s=7b0a68a5b1c219563c59c2c39c961d19" alt="Translation Configurations - Access Key" width="925" height="515" data-path="ai-for-service/app-settings/variables/images/env-and-content-variables-img1.png" />

  * The **Value** field in the **Configure Translation Engine** panel for Custom Translation Engine Configurations.
    <img src="https://mintcdn.com/koreai/Eq2VeGR7oOfXIGHO/ai-for-service/app-settings/variables/images/env-and-content-variables-img2.png?fit=max&auto=format&n=Eq2VeGR7oOfXIGHO&q=85&s=191e9ed7e4cc106e0ca289d4dd071119" alt="Configure Translation Engine - Value" width="730" height="353" data-path="ai-for-service/app-settings/variables/images/env-and-content-variables-img2.png" />

  * **Authorization Profiles** - You can use encrypted/regular environment variables on the following fields while defining a new authorization mechanism for all types of authorizations:

    * **Authorization Check URL**, **Field Key** for form field, and **Field Key** and **Field Value Authorization Fields** for Authorization Type **Basic Auth**. [Learn more](/ai-for-service/app-settings/dev-tools/bot-authorization/setting-up-authorization-using-basic-auth).
    * **Client Id**, **Client Secret Key**, and **Authorization URL** for Authorization Type **Oauth V2**. [Learn more](/ai-for-service/app-settings/dev-tools/bot-authorization/setting-up-authorization-using-oauth-v2).
    * **Client Id**, **Client Secret Key**, **Token Request URL**, **Scope**, and **Refresh Token URL** for Authorization Type **Oauth V2 Client Credentials**.
    * **Consumer Key**, **Consumer Secret**, **Request Token Link**, **Access Token Link**, and **User Authorization Link** for Authorization Type **Oauth V1**. [Learn more](/ai-for-service/app-settings/dev-tools/bot-authorization/setting-up-authorization-using-oauth-v1).
    * **Authorization Check URL** and **Field Key** (for Form Field) for Authorization Type **API Key**. [Learn more](/ai-for-service/app-settings/dev-tools/bot-authorization/setting-up-authorization-using-an-api-key).
    * **Field Key** for Form Field, **Token URL**, **Field Key**, and **Field Value** for Authorization Field, and **Refresh Token URL** for Authorization Type **Oauth V2 Password Grant Type**. [Learn more](/ai-for-service/app-settings/dev-tools/bot-authorization/setting-up-authorization-using-oauth-v2-password-grant).

The availability of the environment variables has been extended to the **Field Key** and **Field Value** parameters.

<img src="https://mintcdn.com/koreai/Eq2VeGR7oOfXIGHO/ai-for-service/app-settings/variables/images/env-and-content-variables-img3.png?fit=max&auto=format&n=Eq2VeGR7oOfXIGHO&q=85&s=3ea43a9d04badd0ec88762549adf5df9" alt="Field Key and Field Value" width="523" height="304" data-path="ai-for-service/app-settings/variables/images/env-and-content-variables-img3.png" />

***

### Create Environment Variables

Enabling the **secure variable** setting after defining an Environment Variable, encrypts and securely stores credentials set as environment variables.

To add a variable, follow the steps:

1. Navigate to **App Settings **>** Variables** > **Environment Variables** and click **Add Variable**.
   <img src="https://mintcdn.com/koreai/GdDNgEUQdpE43twH/ai-for-service/app-settings/variables/images/create-environment-variables.png?fit=max&auto=format&n=GdDNgEUQdpE43twH&q=85&s=df934f36b9cd1b8d501e9d75c59b10bb" alt="Create Environment Variables" width="635" height="681" data-path="ai-for-service/app-settings/variables/images/create-environment-variables.png" />

2. In the **Add Variable** panel, provide the following details:
   * **Variable Name** (required): Enter the variable name. For example, user credentials.
   * **Value** (required): Enter the variable value that’s encrypted.
   * **Notes**: Any tip/note describing the environment variable.
   * **Group**: The name of the group to which the environment variable is mapped.
   * Assign a **Namespace** if enabled ([refer here for more](/ai-for-service/app-settings/managing-namespace)).

3. Enable the **Secure Variable** toggle (**Disabled** by default) to encrypt the original values.

4. Enable the **Propagate value to linked apps** toggle (disabled by default) and select the linked app. This action shares the variable and its value with the selected apps. If the same variable exists in both apps, the current app’s variable value takes precedence.

5. Click **Save**.
   <img src="https://mintcdn.com/koreai/Eq2VeGR7oOfXIGHO/ai-for-service/app-settings/variables/images/env-and-content-variables-img5.png?fit=max&auto=format&n=Eq2VeGR7oOfXIGHO&q=85&s=a93d0f1b6a51271c6a71384c9b4c764b" alt="Save the variable" width="796" height="846" data-path="ai-for-service/app-settings/variables/images/env-and-content-variables-img5.png" />

6. The variable and its encrypted value appear in the list.
   <img src="https://mintcdn.com/koreai/Eq2VeGR7oOfXIGHO/ai-for-service/app-settings/variables/images/env-and-content-variables-img6.png?fit=max&auto=format&n=Eq2VeGR7oOfXIGHO&q=85&s=d44c6040a673d00548cc36847c46d1b7" alt="Environment variable and its encrypted value appear" width="695" height="287" data-path="ai-for-service/app-settings/variables/images/env-and-content-variables-img6.png" />

***

### Using Environment Variables

You can invoke an environment variable in plain text mode (Standard editor) using the following syntax: `{{env.variableName}}`. If you are using it in JavaScript mode, it's `env.variableName`. Here's an example from an app that uses two environment variables called `appType` and `parameters` to determine different app environments such as development, testing, and production. The following script node in one of the app's tasks captures the `base URL` of the app, depending on the current app environment.

<img src="https://mintcdn.com/koreai/Eq2VeGR7oOfXIGHO/ai-for-service/app-settings/variables/images/env-and-content-variables-img8.png?fit=max&auto=format&n=Eq2VeGR7oOfXIGHO&q=85&s=4b1db590621e7db5bf44746b5d209fad" alt="Script to capture Base URL of app" width="536" height="404" data-path="ai-for-service/app-settings/variables/images/env-and-content-variables-img8.png" />

The URL in the following service node changes based on the captured URL:

<img src="https://mintcdn.com/koreai/Eq2VeGR7oOfXIGHO/ai-for-service/app-settings/variables/images/env-and-content-variables-img9.png?fit=max&auto=format&n=Eq2VeGR7oOfXIGHO&q=85&s=058c7e6902d8281c7202abcad8f3295c" alt="URL changes based on the captured URL" width="816" height="281" data-path="ai-for-service/app-settings/variables/images/env-and-content-variables-img9.png" />

***

## Content Variables

App building essentially requires extensive content management efforts. When it comes to multi-language Apps, it also involves tedious coordination efforts between the developers and globally-distributed content authors or copyright team. Content variables enable you to overcome that by abstracting AI Agent flow development efforts from authoring or editing the content. Using Content Variables, programmers can avoid hard-coding the AI Agent content, such as prompts, messages, or any data presented to the user, into AI Agent components, and instead point to specific variables in centrally managed Content Variables files for each app language. You can export the language-specific content variable files to content editors, without exposing any app configurations. The writers can author the content in the exported file, which you can import back into the app.

<Note>Ensure that the Environment or Content variable name doesn't contain any hyphen.</Note>

***

### User Variant-based Content Variables

Content Variables allow user variant-based values, enabling a single content variable to return different values for users within the same language based on region or deployment variant.

Developers can define multiple variant-specific values under a single language, along with a mandatory `Default` fallback value. This approach simplifies multi-region and multi-segment bot deployments by reducing duplicate variables and minimizing conditional flow logic.

At runtime, the platform resolves the appropriate value using the reserved session variable `context.session.BotUserSession.UserVariant,` which developers must set in the Script node.

<img src="https://mintcdn.com/koreai/wIOEXthb4lII2zjd/ai-for-service/app-settings/variables/images/user-variant-variables.png?fit=max&auto=format&n=wIOEXthb4lII2zjd&q=85&s=300687a95f71f3efb0691449c30a72c0" alt="User Variant-based Content Variables" width="1572" height="730" data-path="ai-for-service/app-settings/variables/images/user-variant-variables.png" />

* If the value of `context.session.BotUserSession.UserVariant` matches a configured variant name, the platform returns the corresponding variant-specific value.
* If no match exists, the platform returns the `Default` value for the active language.

<Note>The variant names are case-sensitive.</Note>

For example, the following example shows a `support_number` content variable configured with variant-specific values:

For example, content variable: support\_number

* Default: +1-800-000-xxxx
* US: +1-800-111-xxxx
* UK: +44-800-222-xxxx
* AU: +61-800-333-xxxx

In this example, the platform returns the appropriate support number based on the active value of `context.session.BotUserSession.UserVariant`.

### Entering Language-Specific Values

To add language-specific values for content variables, you first need to switch the app language. You can switch the language by clicking the name of the currently-enabled language from the top-right corner of the app's page and then selecting another language as follows:

<img src="https://mintcdn.com/koreai/Eq2VeGR7oOfXIGHO/ai-for-service/app-settings/variables/images/env-and-content-variables-img7.png?fit=max&auto=format&n=Eq2VeGR7oOfXIGHO&q=85&s=20be08fddc14b6b0843afe94a2846d3a" alt="Select language" width="1919" height="971" data-path="ai-for-service/app-settings/variables/images/env-and-content-variables-img7.png" />

After switching the language, go to **App Settings > Variables > Content Variables** page and click the **edit** icon next to the relevant variable. Replace the text in the **Value** field in the enabled language.

***

### Create Content Variables

To add a variable, follow the steps

1. Navigate to **App Settings **>** Variables** > **Content Variables** tab and click **Add Variable**.
   <img src="https://mintcdn.com/koreai/wIOEXthb4lII2zjd/ai-for-service/app-settings/variables/images/create-content-variables.png?fit=max&auto=format&n=wIOEXthb4lII2zjd&q=85&s=da3777d2e75a1b193e902fcf591fb490" alt="Create Content Variables" width="714" height="848" data-path="ai-for-service/app-settings/variables/images/create-content-variables.png" />
2. In the **Add Variable** panel, select the **Language** from the dropdown list, enter **Variable Name** (required), and **Value Default** (required).
3. Click **Variant-based Value** to add its **Variant** and **Value**. The variant names are case-sensitive.
4. Enter a Notes/description or additional information about the variable.
5. Select the group to which the variable belongs.
6. Enable the **Propagate value to linked apps** toggle (disabled by default) and select the linked app. This action shares the variable and its value with the selected apps. If the same variable exists in both apps, the current app’s variable value takes precedence.
7. Click **Save**.

***

### Using Content Variables

You can invoke a content variable in plain text mode (Standard editor) using the following syntax: `{{content.variableName}}`. If you are using it in JavaScript mode, it's `content.variableName`. Here's an entity node of a multi-language flight booking app that captures the source airport of the users. It uses a content variable instead of a hard-coded user prompt.

<img src="https://mintcdn.com/koreai/Eq2VeGR7oOfXIGHO/ai-for-service/app-settings/variables/images/env-and-content-variables-img13.png?fit=max&auto=format&n=Eq2VeGR7oOfXIGHO&q=85&s=dc1edd5a6f7550d13ef2b35fbf6ec8ba" alt="Entity node containing content variable" width="286" height="130" data-path="ai-for-service/app-settings/variables/images/env-and-content-variables-img13.png" />

When the app reaches this node as a part of the user interaction, the user prompt changes depending on the language of the interaction (provided you entered the respective variable values for all the enabled languages).

***

## Manage Variables

To manage a variable, click the **More** icon next to the variable and select **Edit** or **Delete**. Use the **Edit** option to update the variable configuration or value, and then click **Save** to apply the changes.

For on-premises deployments, you can update encrypted variable values when required.

The new encrypted secure variable value is updated in the list as shown below:

<img src="https://mintcdn.com/koreai/Eq2VeGR7oOfXIGHO/ai-for-service/app-settings/variables/images/env-and-content-variables-img12.png?fit=max&auto=format&n=Eq2VeGR7oOfXIGHO&q=85&s=3e8500d05bdc8e9e28ebeeba56dfbdc1" alt="secure variable value is updated" width="640" height="328" data-path="ai-for-service/app-settings/variables/images/env-and-content-variables-img12.png" />

***

### Importing and Exporting

You can import and export variables between apps.

1. On any of the Variables page accessible from **App Settings > Variables > (Environment/Content) Variables**,

2. Click the **ellipses next to Add Variables**

3. To Import: Select **Import** to import variables from a JSON or CSV file
   1. Since the import will replace the existing variables, you are advised to take a backup of the same.
   2. After taking a Backup, **Proceed** with the Import
   3. Select a JSON or CSV file to import (see below for the file format)

4. To Export: Select either **Export CSV** or **Export JSON** as the preferred format for the export file:
   1. App variables are exported in the form of a JSON or CSV file based upon your selection.
   2. This file includes both environment and content variables.

<img src="https://mintcdn.com/koreai/Eq2VeGR7oOfXIGHO/ai-for-service/app-settings/variables/images/env-and-content-variables-img14.png?fit=max&auto=format&n=Eq2VeGR7oOfXIGHO&q=85&s=f35f117452dbfb443eb909355a1b4eef" alt="Bot variable import/export" width="1883" height="713" data-path="ai-for-service/app-settings/variables/images/env-and-content-variables-img14.png" />

The **App Variable file** contains the following information, the same needs to be present in your Import file. CSV files need a header row. You are advised to refer to the Export (or backup) file and use the same format for the Import file.

* **key** (mandatory) - name of the variable

* **scope** - the scope of the variable corresponds to the Setup Option at the time of variable declaration (if not provided will be set to prePopulated) and can be
  * prePopulated,
  * askOnInstall, or
  * hidden

* **value** - the value of the variables

* **variableType** (if not set will default to env) -
  * env for Environment and
  * locale for Content Variable

* **audioTag** - for the player details in case IVR enabled

* **group** - group name

* **hint** - description of the variable

* **propagateVAlue** - true or false

* **Namespace** - the namespace associated to the variable

* **Language-specific variable**

**Sample CSV file**:

<img src="https://mintcdn.com/koreai/Eq2VeGR7oOfXIGHO/ai-for-service/app-settings/variables/images/env-and-content-variables-img15.png?fit=max&auto=format&n=Eq2VeGR7oOfXIGHO&q=85&s=44627a1f50d82f29e0df91e5101494e0" alt="Sample CSV file" width="1024" height="36" data-path="ai-for-service/app-settings/variables/images/env-and-content-variables-img15.png" />

**Sample JSON file**:

```json theme={null}
[
  {"key":"hosturl",
   "value":"https://platform.kore.ai",
   "hint":"This is the URL of environment which can be used across the endpoints configured in the app",
   "audioTag":"",
   "variableType":"env",
   "scope":"prePopulated",
   "group":"URLS"}
]
```

***
