Loading
Upcoming Mandatory Changes to Public Key Infrastructure (PKI)Read More
Salesforce Enforces New Security Requirements in Summer 2026Read More
Agentforce and Einstein Generative AI
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Create a Custom Variable for Your Agent in the Legacy Builder

          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

          Available in: Lightning Experience
          Available in: Enterprise, Performance, Unlimited, and Developer Editions. Required add-on licenses vary by agent type.
          User Permissions Needed
          To create a custom variable: Manage AI Agents AND the required permissions for your agent type
          1. From the Agentforce Agents Setup page, open your agent in the legacy builder. If your agent is active, deactivate it.
          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
            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.
           
          Loading
          Salesforce Help | Article