Loading
Upcoming Mandatory Changes to Public Key Infrastructure (PKI)Read 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
          Set Up a Custom Agent Invocable Action in Flow Builder

          Set Up a Custom Agent Invocable Action in Flow Builder

          Add a custom agent invocable action to a new or existing flow to complete a task automatically with your Agentforce Service agent or default Agentforce agent.

          Required Editions

          Available in: Lightning Experience
          Available in: Enterprise, Performance, Unlimited, and Developer Editions. Required add-on licenses vary by agent type.
          Important
          Important Starting June 17, 2025, Agentforce (Default) will not include new features or improvements and isn’t available in new Salesforce environments. We recommend migrating to Agentforce Employee agent for continued enhancements and support. If you plan to transition to Agentforce Employee agent or make related license changes, complete the migration of your existing Agentforce (Default) agents in advance to avoid potential disruption in agent availability. If you can't complete the migration in advance, you can create new agents after the transition, which can involve some downtime. See Migrate from Agentforce (Default) to Agentforce Employee Agent.
          User Permissions Needed
             
          To create an agent invocable action associated with an Agentforce Service agent:

          Manage Agentforce Service Agents AND Manage AI Agents

          OR

          Customize Application

          To create an agent invocable action associated with an Agentforce Employee agent:

          Manage AI Agents

          OR

          Customize Application

          To create an agent invocable action associated with Agentforce (Default):

          Manage AI Agents AND the required permissions for your agent type

          OR

          Customize Application

          To open, edit, or create a flow in Flow Builder: Manage Flow

          If you haven't already, prepare to call an agent from an Apex class or flow.

          1. In Flow Builder, select Action. Then, from the AI Agent Actions category, select the custom invocable action for the agent that you want to call from your flow.
            Only invocable actions associated with active agents are listed.
          2. Enter a name for your action and an optional description.
          3. In the User Message field, enter a sample user message to the agent that defines the task to complete. The agent uses the utterance to search through the topics and actions assigned to it to identify the right action or actions for the task.
            For example, “Generate a summary of the incoming service case in less than 100 characters.”
          4. (Optional) In the Resource field, select variables to include in the message.
            Add the elements you want to reference in the user message prior to the agent invocable action in the flow. For example, to fetch the ID for a record in the user message, add the Get Records element to your flow.
            Don’t include context variables in the user message. Instead, use input fields.
          5. (Optional) Specify a session ID for the conversation with the agent.
            If you include multiple invocable actions associated with the same agent in your flow, you can use the session ID as an input in subsequent actions. If you don’t specify a session ID, a new session is created.
          6. (Optional) If your invocable action is on version 1.1.0, click Configure in the Edit Structured Output section and then define at least one structured output field.
            When you edit an invocable action's stuctured output, the changes applies to earlier versions of the flow, including active versions.
          7. (Optional) If your invocable action calls an Agentforce Service agent, the context variables that you added to the agent populate as inputs. To use a context variable as input, map it to a variable. If you don’t want to use a context variable, leave the field blank. Use Agentforce Builder to add or remove context variables.
          8. (Optional) If your invocable action is on version 1.1.0, define the fields that you want the action to return as output to the flow. To make sure that the action always returns a specific field, mark the field as required.
          9. Save your changes.
          10. When you’re ready, give your users access and activate your flow.

          To test your agent’s topic and action configuration, in Agentforce Builder, enter your user message in the preview conversation. To preview your agent’s response, use the Debug Flow feature in Flow Builder. Apex testing isn't supported for custom agent invocable actions.

          If your invocable action is on version 1.1.0, the agent responds with an Apex object that includes the fields you specified.

          If your invocable action is on version 1.0.0, the agent responds with a text-string response. You can use an Apex class in a flow to parse the agent response. See Extend Flows with Apex.

          {
            sessionId: "uuid",
            message: {
              type: text,
              value: AGENT RESPONSE
            }
          }
           
          Loading
          Salesforce Help | Article