---
schema_version: "1"
id: 7656099c04a536a5edf4e4ce7dd95ff959673f33b47b7c91a79cd616395d330f
title: Create a Custom Variable for Your Agent 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_create.md
canonical_url: https://help.salesforce.com/s/articleView?id=ai.agent_variables_create.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 2ca57cec6eb00aa5ba7b2c893336d42f3692276b1e28f4ea5d7913b1091017ff
description: 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.
products:
  - Agentforce
  - Cross Cloud
release: "264"
---
# 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.

### 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>

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col>
          <col>
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d27846e78">User Permissions Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d27846e78 ">To create a custom variable:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d27846e78 ">Manage AI Agents AND <a href="https://help.salesforce.com/s/articleView?id=ai.agent_setup_explore_types.htm&amp;type=5&amp;language=en_US" target="_blank">the required permissions for your agent
                type</a></td>

          </tr>
        </tbody>
      </table>

1. From the Agentforce Agents Setup page, open your agent in the legacy builder. If your agent is active, [deactivate it](https://help.salesforce.com/s/articleView?id=ai.copilot_setup_activate_deactivate.htm&language=en_US&type=5).
2. From the left sidebar, select **Context**.
3. Click **New Variable**. Then, enter the variable's details and review the settings.
    
    The variable’s data type is based on the action output’s data type.
    
    |  |  |
    | --- | --- |
    | Allow value to be set by API | Change the value of this variable with an API. If you’re using this variable for verification or other security functions, consider keeping it hidden from APIs and don’t select this option. |
    | Allow LLM to use value | The agent can use the value of this variable to make decisions and generate conversational responses. If you’re using this variable for verification or other security functions, consider keeping it hidden from the LLM and don’t select this option. |
    | Assign or Map This Variable | When you assign a context or custom conversation variable to an action input, your agent can only use the assigned variable to fill the value of the input. When you map an action output to a variable, you can use the output value in filters and instructions. |
4. Save your changes.

To see details about the variable and where it's used, click its name on the Context panel in the legacy builder.

To assign the variable to an action input after creating it, go to an action input in the legacy builder. Then, from the Assign a Variable dropdown, select the variable.

To map an action output to the variable after creating it, go to the action output in the legacy builder. Then, from the Map to Variable dropdown, select this variable.

To remove a value from the variable, map an action output with an empty value to it.

- **[Example: Improve Your Agent's Memory with Filters and Variables](https://help.salesforce.com/s/articleView?id=ai.agent_custom_variables_filters_example.htm&release=264.0.0&type=5)**  
    Help your agent resolve common troubleshooting inquiries effectively with variables and filters. In this example, you create a variable that stores troubleshooting steps related to login issues and filters that control which actions the agent can use. The agent stores all of the troubleshooting steps in the variable. Then, it guides the customer through the troubleshooting process by delivering the most relevant step based on the conversation context.