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. |
| 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.
-
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.
- Enter a name for your action and an optional description.
-
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.”
-
(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.
-
(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.
-
(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.
- (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.
- (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.
- Save your changes.
- 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
}
}
