Sub topic 5
Defining input and output variables
This chapter assumes you know Flow Builder basics (variables, resources, elements) and how to create an autolaunched flow. It covers how variables become the inputs and outputs the agent sees.
Why variables are the action's contract
An agent action has no screen and no user interface. When the agent calls your flow, it passes values into the flow's input variables. When the flow finishes, the agent reads the output variables and uses them to compose a reply.
The agent's language model sees only the variables you expose, along with their names and descriptions. It does not see your flow's elements or logic. Any variable you leave unexposed is invisible to the agent.
The two settings that matter
Each variable has two checkboxes in Flow Builder: Available for input and Available for output. They map to isInput and isOutput in the flow metadata.
- An input variable has
isInputset to true. The agent fills it before the flow runs. - An output variable has
isOutputset to true. The flow fills it, and the agent reads it afterward. - A variable with both settings off is internal working storage, such as a loop counter or a record variable used between elements.
This metadata shows one input and one 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>The description element is the text the model reads. The next chapter covers how to write good descriptions. Here, just make sure every exposed variable has one.
Choosing names and data types
Pick names that say what the value is. caseNumber tells the model what to collect. var1 or inputText forces it to guess.
Keep inputs simple. Text, number, boolean, and date variables are easy for an agent to collect from a conversation. A customer can say a case number, but they cannot supply a whole record. If your flow needs a record, take an identifier or a search value as input and look the record up inside the flow.
Collection variables (isCollection set to true) can return several values. Use them sparingly, because a long list is harder for the agent to summarize than a single value.
Output only what the agent needs to answer. Returning a status and a short message is better than returning every field on the record. Fewer outputs mean fewer chances for the agent to misreport something.
Common errors
| Symptom | Likely cause |
|---|---|
| Variable does not appear when you add the action | **Available for input** or **Available for output** was not checked |
| The agent asks for the wrong value or guesses | Vague name or missing description |
| The agent reports blank results | The output variable is never assigned on some path, for example when Get Records finds nothing |
| The agent asks for data the customer cannot provide | The input requires an internal ID instead of something the customer knows |
Assign a default value to each output variable, or assign it on every path through the flow. The error-handling chapter returns to this.
If you change a variable's name, type, or settings after registering the action, review the action's inputs and outputs in Agent Builder. Treat the variable list as an interface and change it deliberately.
Exercise
A flow looks up an Account by name and returns its owner's name. The flow has a Text variable accountName and a Text variable ownerName, but neither shows up as an input or output when you add the flow as an action. What do you check first, and how should each variable be configured?
Show answer
Check the availability settings on each variable. accountName needs Available for input checked (isInput true), and ownerName needs Available for output checked (isOutput true). Also add a description to each, for example "The name of the account to look up" and "The full name of the account owner, or a short message if no account was found."