Sub topic 10
Implementing an action with Flow
This chapter assumes you can build an autolaunched flow, know what a Flow variable is, and have seen Agentforce Builder. It shows how a flow's variables become the inputs and outputs the agent reads.
What the agent sees in a flow
An agent can call an autolaunched flow as an action. It never sees your elements, formulas, or logic. It sees only the flow's label and description, plus each variable that you expose and that variable's label, description, and data type. If those are vague, the agent has to guess.
Expose variables on purpose
A flow variable is private by default. To make it part of the action's interface, open the variable and select Available for input or Available for output under the advanced options.
| Variable setting | Effect on the action |
|---|---|
| Available for input | The agent can fill the variable before the flow runs. |
| Available for output | The agent can read the variable after the flow finishes. |
| Neither selected | The variable is internal and invisible to the agent. |
Expose only what the agent needs. Keep intermediate values, such as record IDs used between elements, internal.
Describe each variable
The Description field on a variable plays the same role as an @InvocableVariable description in Apex. Write it for the agent, not for the next flow builder.
Input variable
API Name: orderNumber
Data Type: Text
Available for input: yes
Description: The order number the customer provided, for example 00000101.
Ask the customer if it was not given. Do not guess.
Output variable
API Name: statusMessage
Data Type: Text
Available for output: yes
Description: A short plain-language message describing the outcome,
including when no order matches the number.Describe the flow itself the same way. The flow description tells the agent when to call it. Write something like "Looks up the status of one order by its order number. Use when the customer asks where their order stands."
Build the flow around a single job
A good action flow does one thing and returns a result that the agent can explain. The following diagram shows a lookup flow with a fault path.
Every path assigns the output variable. If a path leaves it empty, the agent receives nothing to report and may invent an answer.
Choose types the agent can fill
- Use Text, Number, Boolean, and Date for inputs the customer states directly.
- Pass a record ID only when an earlier action returned it. Customers don't know IDs.
- Use a collection variable only when you need a list. The agent must then supply several values, which is harder than supplying one.
- Prefer a text output with a finished sentence over many raw fields, unless the agent needs the fields to reason further.
Connect the flow to the agent
- Activate the flow. Only active autolaunched flows are available as actions.
- In Agentforce Builder, open the topic and add an action.
- Set the reference action type to Flow and select your flow.
- Review the generated action instructions and the input and output descriptions. They come from your flow and variable text. Edit them in the flow if they are wrong, so the two stay in sync.
- Mark inputs as required, and choose whether the agent should collect each from the user. The next chapters cover these settings in detail.
Common mistakes
- Leaving the default description or none, so the agent can't tell when to call the flow.
- Exposing a variable as output but assigning it only on the success path.
- Naming variables
var1oroutput, which tells the agent nothing. - Building a flow that shows a screen. Action flows must run without user interaction, so use an autolaunched flow.
Exercise
A Flow has an output variable statusMessage that is assigned only when Get Records finds an order. The agent sometimes tells customers an order is "being processed" when the number does not exist. What is the likely cause, and how do you fix it?
Show answer
The variable is empty when no record is found, so the agent has no information and fills the gap itself. Fix it by assigning statusMessage on every path: add a "no order found" branch and a fault path that each set a clear message. Also describe the variable as "including when no order matches the number".