Sub topic 3
Autolaunched flows as the foundation
This chapter assumes you know the Salesforce data model (objects, fields, records), the basics of Flow Builder (variables, elements, resources), and how to open Setup and assign permission sets. It also assumes you know what an AI agent is.
Why autolaunched flows
An Agentforce action that runs a flow needs a flow that can start without a person on screen. An autolaunched flow is a flow with no start trigger and no user interface. Something else has to call it. In this case the caller is the agent.
Other flow types don't fit this role:
| Flow type | How it starts | Fit for an agent action |
|---|---|---|
| Autolaunched flow | Called by another process, such as an agent, Apex, or a subflow element | Yes |
| Screen flow | A user opens it and sees screens | No, the agent can't fill in screens |
| Record-triggered flow | A record is created, updated, or deleted | No, it responds to data changes, not to the agent |
| Schedule-triggered flow | A set time | No |
The agent supplies values, the flow runs, and the flow returns values. The agent then uses those values in its reply.
What the agent sees
The agent does not see your flow elements. It sees only the flow's name, its description, and its input and output variables. Everything you build inside the flow is hidden. This makes the flow's variables the contract between the flow and the agent, which the next chapter covers in detail.
Building the skeleton
Start with a flow that does one job. This example looks up a case and returns its status.
- In Setup, open Flow and choose New Flow.
- Select Autolaunched Flow (No Trigger) and click Create.
- Create a Text variable named
caseNumberand select Available for input. - Create a Text variable named
caseStatusand select Available for output. - Add a Get Records element that finds the Case whose
CaseNumberequals{!caseNumber}. - Add an Assignment element that sets
caseStatusto the Status of the record found. - Save the flow with the API name
Get_Case_Status, then activate it.
Only active flows can be added as actions. Save an inactive version while you work, and activate it when it's ready to test.
The two variables look like this in the flow's metadata:
<variables>
<name>caseNumber</name>
<dataType>String</dataType>
<isCollection>false</isCollection>
<isInput>true</isInput>
<isOutput>false</isOutput>
<description>The Case Number of the case to look up, for example 00001026.</description>
</variables>
<variables>
<name>caseStatus</name>
<dataType>String</dataType>
<isCollection>false</isCollection>
<isInput>false</isInput>
<isOutput>true</isOutput>
<description>The current Status of the case, or a short message if no case was found.</description>
</variables>The isInput and isOutput settings are what make a variable usable by the agent. A variable with both set to false is private to the flow.
Common errors
- Wrong flow type. A screen flow or record-triggered flow won't appear in the list of flows you can add as an action. Check the type first if your flow is missing.
- Flow not active. An inactive flow can't be selected. Activate it and refresh the list.
- Variable not exposed. If an input or output is missing from the action's setup, check that Available for input or Available for output is selected.
- No path for "not found". If Get Records finds nothing,
caseStatusstays empty and the agent has nothing to say. Handle this case in the flow, which a later chapter covers.
Exercise
You built a record-triggered flow that updates a case's priority, and you want an agent to run it on request. Why can't you add it as an action, and what flow type should you build?
Show answer
A record-triggered flow starts only when a record is created, updated, or deleted, so the agent has no way to call it with input values. Build an autolaunched flow (no trigger) with input and output variables instead, and have the agent call that.
Exercise
Your autolaunched flow is active and runs correctly in Flow Builder, but the agent can't pass it a case number. What is the most likely cause?
Show answer
The caseNumber variable isn't marked Available for input. Select that setting, save the flow, and activate the new version.