---
schema_version: "1"
id: 92885f5c1df586f9332ad54fb3d3354e6f622072f4648b3a70e66ce525995a75
title: Variables in the Legacy Builder
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ai/264-0-0/agent_variables.md
canonical_url: https://help.salesforce.com/s/articleView?id=ai.agent_variables.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 713f28ea8c42202635e5c4297dbac15970e73cad25b95c27f878a61cd0234bed
description: To improve security and ensure consistent agent behavior, use variables in filters, instructions, and as input for actions. You can use variables to control how your agent uses subagents and actions and to provide more information about a conversation.
products:
  - Agentforce
  - Cross Cloud
release: "264"
---
# Variables in the Legacy Builder

To improve security and ensure consistent agent behavior, use variables in filters, instructions, and as input for actions. You can use variables to control how your agent uses subagents and actions and to provide more information about a conversation.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Enterprise</strong>, <strong>Performance</strong>, <strong>Unlimited</strong>, and <strong>Developer</strong> Editions. <a href="https://help.salesforce.com/s/articleView?id=ai.agent_setup_explore_types.htm&amp;release=264.0.0&amp;type=5" title="Learn about agent types and default templates for specific clouds and common use cases.">Required add-on licenses vary by agent type.</a></td></tr></tbody></table>

A context variable is mapped to an object field. If your agent can connect to customer channels, it includes context variables that are mapped from Messaging Session object fields, including custom fields. Context variables are prefixed with `$Context` and are typically read-only. The End User Language context variable is editable.

A conversation variable is unique to the agent it's in, and it holds a value only during the conversation session.

A custom conversation variable stores an action’s output value. You can use a custom conversation variable in a filter or as input for an action. The variable can be a Boolean, Number, or Text data type.

Here are some ways you can use variables.

- Assign a context or custom conversation variable to an action input. When you assign a variable to an action input, your agent can only use the assigned variable to fill the value of the input. Action inputs must be one of these data types: Boolean, Number, Text.
- Map an action output to a variable. You can use the output value in filters and instructions. Action outputs must be one of these data types: Boolean, Number, Text.
- Use a variable in a filter. Filters ensure that your agent can use a subagent or action only when a variable meets the filter conditions.
- Specify variable values with the Agent API and mention a variable in subagent instructions.

For a context variable, use this format: `{!$Context.VariableAPIName}`. And for a conversation variable, use this format: `{!VariableAPIName}`.

- **[Create a Custom Variable for Your Agent in the Legacy Builder](https://help.salesforce.com/s/articleView?id=ai.agent_variables_create.htm&release=264.0.0&type=5)**  
    Control how an agent uses subagents and actions by mapping an action output to a custom variable. For example, when you assign a variable to an action input, your agent can use only the assigned variable to fill the value of the input.
- **[Standard Variable Reference for the Legacy Builder](https://help.salesforce.com/s/articleView?id=ai.agent_variables_ref.htm&release=264.0.0&type=5)**  
    Some agents include pre-built variables, called standard variables. Explore your agent's standard variables on the Context tab in the legacy Agentforce Builder.

#### See Also

- [_Video_: Control Agentforce Decision-Making with Variables and Filters](https://youtu.be/sOnECEt7iWs)
- [_Agentforce Developer Guide_: Get Started with the Agent API](https://developer.salesforce.com/docs/ai/agentforce/guide/agent-api-get-started.html)
- [_Agentforce Developer Guide_: Send Agent Variables with the Agent API](https://developer.salesforce.com/docs/ai/agentforce/guide/agent-api-variables.html)