# Variables: Store and Reuse Values in Robylon

Store values in variables, including the ones connected integrations create, and use them in AI agents, workflows, canned responses and macros.

> Source: https://www.robylon.ai/docs/data-and-integrations/variables-intents-entities
> Section: Data and tools

Variables hold values during a conversation, for example a customer's email. AI agents, workflows, canned responses and macros can all read them.

Open them from [**Settings → Data & Developer → Variables**](https://app.robylon.ai/settings/global-variables).

## What a variable is

A variable is a named value that agents, workflows and tools can read and change during a conversation. Each variable has a display name, for example "Order ID", and a system name in curly braces, for example `{order_id}`.

Variables come from several places:

| Source | Examples |
| --- | --- |
| Built in | `{chat_history}`, `{last_user_message}`, `{user_email}`, `{user_phone_number}`, `{chat_id}`, `{user_language}`, and ticket fields for each helpdesk |
| Created by you | Global variables you add on the Variables page |
| [Entities](https://www.robylon.ai/docs/data-and-integrations/entities) | Each entity creates a variable that holds the extracted value |
| [Credentials](https://www.robylon.ai/docs/data-and-integrations/secrets-keys) | Each credential creates a variable that inserts the secret |
| [Properties](https://www.robylon.ai/docs/inbox/properties) | Ticket and conversation properties |
| Connected integrations | Global variables Robylon creates when you connect Shopify, Shiprocket, ClickPost, GoKwik or Return Prime, named with the app's prefix. See [Shipping, checkout and returns](https://www.robylon.ai/docs/integrations/shipping-returns-checkout#what-connecting-creates). |

A variable's value lasts for one workflow run or conversation. To keep details about a customer between conversations, use [user attributes](https://www.robylon.ai/docs/contacts/user-attributes).

## Use a variable

Type `{` in any field that accepts variables, for example an API URL, and pick the variable from the list. When the step runs, Robylon replaces it with the current value.

To use one field from an API response, save it to its own variable with **Capture Response** on the API or tool: enter a **Path**, for example `response.orders[0].status`, and pick the variable under **Save to Variable**. Paths use Jinja syntax and can also read `status_code`.

When a path does not match the response, for example `response.orders[0].status` on a response with no orders, the variable is saved empty and the workflow step or tool call continues instead of failing. Check for an empty value before you rely on it.

## Create a global variable

<Steps>
  <Step title="Open Variables">
    Go to [**Settings → Data & Developer → Variables**](https://app.robylon.ai/settings/global-variables) and click **Add Variable**.
  </Step>
  <Step title="Name and describe it">
    Enter a **Display Name** and a **Description**. Robylon creates the system name from the display name, in lower case with underscores, so "Order ID" becomes `{order_id}`. Names must be unique.
  </Step>
  <Step title="Choose the input type">
    Under **Agent Input Type**, choose **Free Text** or **Choice (dropdown)**. An agent is prompted to enter this value when it uses the variable, and with a dropdown it picks from your options.
  </Step>
  <Step title="Set a default value">
    Under **Set to**, choose **Value** for a fixed default or **Expression** for a calculated one. For a JSON object, start and end the value with curly braces. For a list of strings, put each string in double quotes.
  </Step>
  <Step title="Save">
    Click **Save**. The variable is now available in all workflows and automations.
  </Step>
</Steps>

**Agent Input Type** decides how a teammate fills in the variable. When a teammate uses a canned response or macro that contains it, they are asked for the value before sending: **Free Text** lets them type any value, and **Choice** shows a dropdown of the options you set.
