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
| Available in: Lightning Experience |
| Available in: Enterprise, Performance, Unlimited, and Developer Editions. Required add-on licenses vary by agent type. |
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
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
Some agents include pre-built variables, called standard variables. Explore your agent's standard variables on the Context tab in the legacy Agentforce Builder.

