Sub topic 10
Adding the flow to a topic in Agent Builder
An active autolaunched flow does nothing for an agent until you register it as an action and attach it to a topic. This chapter covers that registration step. It covers where it happens, what the flow must look like beforehand, what you fill in, and what breaks most often.
Prerequisites
This chapter assumes you have:
- Built an autolaunched flow with input and output variables, as covered in the earlier chapters on flow basics and variables.
- Written descriptions for those variables.
- Permission to use Agent Builder (typically through an Agentforce-related permission set) and permission to view the flow in Setup.
- A basic idea of what a topic is: a named job the agent can handle, with its own instructions and a list of actions.
What registration does
An agent never calls a flow directly. It calls an action, and the action is a wrapper that points to the flow. The wrapper holds the text the language model reads: a name, instructions, and settings for each input and output.
The same flow can sit behind several actions, and the same action can be used in several topics. Agent Builder stores the action as an asset, so reuse does not mean copying it.
Check the flow before you register it
Agent Builder lists only flows that qualify. If your flow is missing from the list, check these points first.
- Flow type. It must be an autolaunched flow with no trigger. Screen flows and record-triggered flows do not appear.
- Active version. The flow needs an active version. A flow that exists only as a draft or an inactive version cannot be selected.
- Variables. Every value the agent supplies must be a variable marked "Available for input". Every value you want back must be marked "Available for output".
- Descriptions. Each variable should have a description, because the model reads them.
The following metadata shows the variables for a case lookup flow. The caseNumber variable accepts input, and caseStatus returns output:
<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>A variable that is neither input nor output is private to the flow. The agent cannot see it or set it.
Adding the action to a topic
The exact labels change between releases, so treat the steps below as the shape of the process rather than a script.
- In Setup, open Agentforce Agents and open your agent in Agent Builder.
- Go to the Topics tab and select the topic that should own this job. If the job fits no existing topic, create one first. A topic needs a clear scope and instructions of its own.
- In the topic's action list, choose to add a new action.
- For the reference action type, choose Flow.
- Select your flow from the list. The list shows flow labels, so give flows distinct labels.
- Enter an Agent Action Name and Instructions. Agent Builder may prefill these from the flow's label and description, so rewrite them rather than accept the defaults.
- Review the inputs and outputs that Agent Builder read from the flow. Set the options described in the next section.
- Save the action, then confirm it appears in the topic's list.
If you want the same action in a second topic, add it from the existing actions rather than creating a duplicate.
What you enter
This sketch shows the values for the case lookup example:
Action name: Get Case Status
Flow: Get_Case_Status (autolaunched flow)
Action instructions: Use this action when the customer asks about the status of an existing case and has given a case number.
Input caseNumber: Collect from the user. Ask for it if it was not provided.
Output caseStatus: Tell the customer the status in plain language.Each field has a different job.
| Field | Who reads it | What it should say |
|---|---|---|
| Action name | The model, and you in lists | A verb phrase that names the outcome, such as "Get Case Status" |
| Action instructions | The model | When to call the action, and when not to |
| Input instructions | The model | Where the value comes from and what to do if it is missing |
| Output instructions | The model | How to present the result to the customer |
The action instructions answer "when", while the variable descriptions answer "what". Do not repeat the same sentence in both places. Put selection guidance in the action instructions and value format in the input description.
Input and output settings
Each input has settings that control where its value comes from. Typical options are:
- Require input. The agent must have a value before it runs the action. If it has none, it asks the customer.
- Collect data from user. The agent may take the value from the conversation or ask for it. If you turn this off, the value must come from somewhere else, such as a variable set by an earlier action in the same conversation.
Outputs have their own settings:
- Show in conversation. The agent may display the value to the customer.
- Filter from agent action. The agent does not see the value at all. Use it for values that exist only for internal chaining.
Use the filter for anything the customer should not see. Hiding an output in the reply is not as strong as filtering it, because a value the model can see may still end up in its answer.
Common errors
The flow is not in the list. Check the type and active version first, then the permissions of your own user. A flow you cannot see in Setup cannot be selected.
The agent never calls the action. The topic probably does not match the customer's request, or the action instructions are too vague. Test with a message that quotes the instructions almost word for word. If it works then, the problem is the wording of the topic or action, not the registration.
The agent calls the wrong action. Two actions with overlapping instructions compete. Rewrite each so that the "use this when" statements do not overlap, or remove one.
The agent asks for a value you already have. The input is marked to be collected from the user, but a better source exists. Change the input settings or pass the value in from an earlier step.
You changed the flow and the action behaves as before. The action reads the flow's variables when you set it up. After you add, rename, or remove a variable, open the action and check that its input and output list matches the new flow. Renaming a variable is a breaking change, because the action and any saved instructions refer to the old name.
The action runs but returns nothing. The output variable is probably not marked "Available for output", or the flow never assigns it on the path that ran. The earlier chapter on fault paths covers the second case.
Verifying the result
After saving, open the agent preview, send a message that should trigger the topic, and read the action trace for that turn. Confirm three things: the model chose the right topic, it called your action, and the input value matches what you typed. The next chapters cover this testing in detail, but a quick check here saves you from debugging a flow that was never called.
Exercise
You registered a flow as an action, and it works in the preview. A colleague then renames the input variable caseNumber to caseNum in the flow and activates the new version. What should you check, and why?
Show answer
Open the action in Agent Builder and confirm its input list matches the renamed variable. The action stores a reference to the variable name, so the rename can leave the action pointing to an input that no longer exists. Also re-read the input description and instructions, which may still refer to the old name, then retest in the preview.
Exercise
A flow you built does not appear in the list of flows when you add an action. Name three things to check.
Show answer
Any three of: the flow is an autolaunched flow with no trigger; it has an active version; your user can see the flow in Setup; the variables meant for the agent are marked available for input or output.