Sub topic 3
Autolaunched flows as the foundation
This chapter covers the flow type that sits under most Flow-based Agentforce actions: the autolaunched flow. It assumes you know the basic Salesforce data model (objects, fields, records), have built a simple flow in Flow Builder, and can find your way around Setup and permission sets. You also need a general idea of what an AI agent is.
By the end you will know what an autolaunched flow is, how it differs from other flow types, what an agent needs from it, and which mistakes make a flow unusable as an action.
What an autolaunched flow is
An autolaunched flow is a flow with no screen elements and no user interface. Something else starts it: Apex code, a REST API call, a process, another flow, or, in this tutorial, an Agentforce agent. It runs from its start element to its end without asking anyone for input mid-run.
That last point matters for agents. The agent collects what the flow needs from the conversation, passes those values in, waits for the flow to finish, and reads the results back. A flow can't pause and show a screen to ask a follow-up question. All interaction with the customer happens in the agent's conversation, not in the flow.
The flow type you create in Flow Builder is called Autolaunched Flow (No Trigger). You pick it when you choose to start from scratch. Other autolaunched types, such as record-triggered flows and schedule-triggered flows, start by themselves on a data change or a schedule. They can't be called as actions, because the agent has nothing to call.
How it differs from adjacent flow types
| Flow type | What starts it | Has screens | Usable as an agent action |
|---|---|---|---|
| Autolaunched Flow (No Trigger) | Apex, API, another flow, an agent | No | Yes |
| Screen Flow | A user, through a page, button, or tab | Yes | No |
| Record-Triggered Flow | A record being created, updated, or deleted | No | No |
| Schedule-Triggered Flow | A set time and frequency | No | No |
Two points are easy to miss:
- A screen flow can't run inside an agent action because it needs a user interface that the agent doesn't have. If you have an existing screen flow, you have to build a separate autolaunched flow that holds the logic.
- A record-triggered flow can still take part indirectly. If your action updates a record, a record-triggered flow on that object fires as usual. Remember this when you test, because an action can have side effects you didn't build into it.
The parts of an action-ready flow
Every flow you build for an agent has the same three parts.
- Inputs. Variables marked "Available for input". The agent fills these in from the conversation.
- Logic. Elements such as Get Records, Decision, Assignment, and Update Records that do the work.
- Outputs. Variables marked "Available for output". The agent reads these and uses them in its reply.
The diagram shows the order of events when an agent calls such a flow.
The agent never sees your elements, formulas, or decisions. It sees only the flow's name, its input variables, and its output variables. Everything else is a black box. This shapes how you design the flow: the interface is the variables.
A minimal working flow
Here is the plan for a flow named Get_Case_Status that looks up a case by number and returns its status. It is the running example for the rest of the tutorial.
- In Flow Builder, create a new Autolaunched Flow (No Trigger).
- Create the input variable
caseNumber, a Text variable. - Create the output variable
caseStatus, a Text variable. - Add a Get Records element on Case, filtered where
CaseNumberequals{!caseNumber}, returning only the first record and storing all fields (or just the ones you need). - Add a Decision after it that checks whether a record was found.
- In the found branch, add an Assignment that sets
{!caseStatus}to the record'sStatus. - In the not-found branch, add an Assignment that sets
{!caseStatus}to a short message such asNo case was found with that number. - Save and activate the flow.
Case numbers are stored as text with leading zeros, such as 00001026. That is why caseNumber is a Text variable and not a Number. A Number variable would drop the zeros, and the lookup would fail.
The variable definitions for the two variables are stored in the flow's metadata like this:
<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>isInput and isOutput are the settings behind the "Available for input" and "Available for output" checkboxes in Flow Builder. A variable with both set to false is internal to the flow and invisible to the agent. The description elements are what the agent's language model reads to decide what each value means. The next chapters cover input and output variables and descriptions in detail.
Rules that make a flow usable as an action
Check these before you try to register a flow.
- The flow must be active. Only an active version of a flow can be selected in Agent Builder. A saved but inactive flow won't appear in the list.
- It must be autolaunched with no trigger. Screen flows and triggered flows aren't offered.
- It needs at least one input or output where it makes sense. A flow with no inputs can still work, for example one that returns the current open case count. But an action with neither inputs nor outputs gives the agent nothing to pass or report.
- No screens, and no waits on user input. Pause elements that wait for an event don't suit an action that the agent expects to return within the conversation.
- Keep it fast. The customer is waiting for a reply. Avoid long loops over large record sets, and avoid callouts that can hang.
- Use bulk-safe patterns. Put Get Records, Update Records, and similar data elements outside loops. This is a standard Flow rule, but a slow or limit-hitting action hurts the conversation immediately.
Edge cases and common mistakes
Variable names read like labels to the agent. caseNumber tells the model something. var1 and text_2 tell it nothing. Choose names as if you were writing a function signature for a colleague.
Collection variables. A variable can be a collection, which is a list of values. Collections can be passed in and out, but they raise the chance of the agent misreading or formatting them wrongly. Prefer single values when you can, and have the flow summarize a list into one text output when the agent only needs to report it.
Record variables and Apex-defined types. You can mark a record variable as an input or output, but a flat set of text, number, boolean, and date variables is easier for the agent to fill and read. Return the specific fields you need and not a whole record.
Missing data. If Get Records finds nothing and your flow doesn't handle it, the output variable stays empty. The agent then has no result to report and may guess or say something vague. Always give the not-found case an explicit output value. Chapter 8 covers fault paths and error outputs for failures such as a record that can't be updated.
Changing the interface later. When you rename or remove an input or output variable, an action that already uses the flow can break or lose its mapping. Make changes to a new flow version, check the registered action, and test again. Chapter 13 covers versioning.
Hidden side effects. Update Records inside an action changes real data on a customer's request. Keep each flow to one purpose, as Chapter 4 explains, so you can say exactly what a call will do.
Verifying the flow before it meets an agent
Test the flow on its own first. Use the Debug button in Flow Builder, enter a real case number such as 00001026 for caseNumber, and check that caseStatus holds the status. Then run it again with a number that does not exist and confirm that the not-found message appears. If the flow fails when you run it by hand, it will fail when the agent calls it, and the failure will be harder to diagnose in a conversation.
What comes next
You now have a flow whose interface is a set of well-named variables. The next chapters go deeper on each part. Chapter 4 covers keeping the action to a single purpose. Chapter 5 covers defining input and output variables in detail. Chapter 6 covers writing descriptions the agent can use.
Exercise
A colleague has a screen flow that asks the user for a case number, looks up the case, and shows its status on a results screen. They want to use it as an agent action. What do they need to do, and why can't they use it as it is?
Show answer
A screen flow needs a user interface, and an agent action has none, so it can't be selected in Agent Builder. They should build a new Autolaunched Flow (No Trigger) that holds the same logic. The case number becomes an input variable instead of a screen field, and the status becomes an output variable instead of a screen display. Both variables need clear names and descriptions, and the flow must be activated before it can be registered.
Exercise
Your GetCaseStatus flow finds no case for the number the customer gave, and the Decision has no not-found branch. What does the agent receive, and how do you fix it?
Show answer
The output variable caseStatus stays empty, so the agent has nothing reliable to report and may give a vague or invented reply. Fix it by adding a not-found branch that assigns a short message, such as "No case was found with that number.", to caseStatus, so the agent always gets a usable result.
Exercise
Why is caseNumber defined as a Text variable and not a Number variable?
Show answer
Case numbers are stored as text with leading zeros, such as 00001026. A Number variable would drop the leading zeros, so the Get Records filter would not match the stored value.