Sub topic 4
Inputs, outputs, and how the agent fills them
This chapter assumes you know what a topic and an action are, and that you have seen the action list inside a topic in Agentforce Builder. It also assumes you know the basic Salesforce data model (objects, fields, records, Ids). Here you will learn what an action's inputs and outputs are, how the agent decides what to put in each input, and how the outputs feed the rest of the conversation.
The contract of an action
Every action has a contract with two sides.
- Inputs are the values the action needs to run. A record lookup needs a name or an Id. An email action needs a recipient and some context.
- Outputs are the values the action returns. A lookup returns a record Id. A summary action returns text. A query returns a list of records.
The agent reads this contract as text. For each input and output it sees a name, a data type, and a description. It uses those descriptions to decide which action fits a request and what to pass in. The descriptions are the main way you steer behavior.
What slot filling means
Slot filling is the process of choosing a value for each input, which is called a slot. For each input the agent looks in these places, roughly in this order:
- The current message. The user said "Summarize the Acme account", so a name input can be filled with "Acme".
- Earlier conversation. An account named three turns ago can fill an account input now.
- Outputs of earlier actions. A record Id returned by a lookup can fill the Id input of a later action.
- Variables. Values stored in agent variables, such as the signed-in user's context, can fill an input when the action is configured to use them.
- The user. If a required input is still empty, the agent asks.
The agent is a language model making these choices, so this is not a strict lookup order. Clear descriptions and clear instructions make the result consistent.
Input settings in Agentforce Builder
When you open an action in a topic, each input has settings that change how slot filling works. Labels can differ slightly between releases, so check your org's Builder.
| Setting | Effect |
|---|---|
| Require input | The action does not run until the input has a value. If the agent has none, it asks. |
| Collect data from user | The agent may ask the user for the value. If turned off, the agent must get it from context or a variable. |
| Description | Tells the agent what the value means and what format it takes. |
Two combinations matter most:
- Required and collectable. The agent asks if the value is missing. This is the usual setup for something like a record name.
- Required but not collectable. The value must come from context. Use this for an Id that should come from a previous action, not from the user. If nothing supplies it, the action cannot run, which tells you the earlier step in the chain is missing.
An input that is neither required nor collectable is filled only when the agent happens to have a value. Do not rely on it.
Output settings
Outputs also have settings that control what happens after the action runs. Again, labels vary by release.
| Setting | Effect |
|---|---|
| Show in conversation | The output value can be displayed to the user in the reply. |
| Filter from agent | The agent does not see the value in its reasoning, and the value can still be passed to later steps in some configurations. Use it to keep large or sensitive values out of the model's view. |
Turn off display for values the user does not need, such as internal Ids. A user can still follow the conversation without seeing a raw Id, and the agent can still use it in the next action.
Descriptions are the real interface
The agent cannot see your Flow or Apex code. It sees names and descriptions. Compare two inputs on the same action:
- Weak:
namedescribed as "Name". - Strong:
accountNamedescribed as "The account's name as the user typed it. Do not add suffixes such as Inc or Ltd."
The strong version tells the agent what to pass and what not to change. Write each description to answer three questions: what is this value, what format is it in, and where does it come from?
Custom actions make this visible. In Apex, the descriptions come from the invocable annotations, so write them with the same care:
public with sharing class OpenCaseCounter {
public class Request {
@InvocableVariable(label='Account Id' description='The account whose open cases are counted' required=true)
public Id accountId;
}
public class Result {
@InvocableVariable(label='Open Case Count' description='Number of open cases for the account')
public Integer openCases;
}
@InvocableMethod(label='Count Open Cases' description='Returns the number of open cases for an account')
public static List<Result> countOpenCases(List<Request> requests) {
Set<Id> accountIds = new Set<Id>();
for (Request r : requests) {
accountIds.add(r.accountId);
}
Map<Id, Integer> counts = new Map<Id, Integer>();
for (AggregateResult ar : [
SELECT AccountId acct, COUNT(Id) total
FROM Case
WHERE IsClosed = false AND AccountId IN :accountIds
GROUP BY AccountId
]) {
counts.put((Id) ar.get('acct'), (Integer) ar.get('total'));
}
List<Result> results = new List<Result>();
for (Request r : requests) {
Result res = new Result();
res.openCases = counts.containsKey(r.accountId) ? counts.get(r.accountId) : 0;
results.add(res);
}
return results;
}
}The required=true flag maps to a required input. The description text is what the agent reads when it decides what to put in accountId. The input is an Id, not a name, so the agent needs a way to get one. That is usually a lookup action that runs first.
Passing outputs into inputs
An output from one action becomes available for later inputs. The common pattern is:
- The user names an account.
- A lookup action takes the name as input and returns a record Id as output.
- A summary or update action takes that Id as input.
The agent only makes this connection if the types and descriptions line up and the topic instructions point to the sequence. Instructions like the following make the order explicit:
Topic: Account Support
Instructions:
1. When the user names an account, first find the account record, then use the result for any later step.
2. Use the summary action when the user asks for an overview of an account.
3. Before updating a record, restate the field and the new value and ask the user to confirm.
4. If you cannot find exactly one matching record, ask the user to clarify instead of guessing.Instruction 1 tells the agent to pass the lookup's output into later actions. Instruction 3 uses the agent's ability to ask the user before an action with side effects. Instruction 4 covers a failed or ambiguous output, which is a common edge case.
Edge cases and common errors
- Ambiguous values. "Update Acme" could match several records. If the lookup returns many results and nothing tells the agent to stop, it may pick one. Add an instruction to ask when the match is not unique.
- Name passed where an Id is needed. If an input expects an Id and the agent has only a name, it may pass the name and the action fails. Make the description say "Salesforce record Id" and make sure a lookup runs first.
- Over-eager guessing. If an input is optional, the agent may skip asking the user even when the value matters. Mark it required if the action is wrong without it.
- Type mismatches. A date, a picklist value, or a number must match the input's type. Describe the accepted format, for example "Date in YYYY-MM-DD format".
- Empty outputs. A query with no results returns an empty list, and the agent must handle it. Tell it what to say in that case, not leave it to improvise.
- Stale context. If the user switches from one account to another mid-conversation, an earlier Id may still be in history. Instruct the agent to run the lookup again when the user names a new record.
Checking what was passed
In the Builder's conversation preview, you can open the details of a turn to see which actions ran, the input values passed, and the outputs returned. Use this whenever behavior is surprising. If an input holds a wrong value, check, in order, the input description, the instructions, and whether an earlier action actually returned what you expected. A later chapter covers this inspection in detail.
Exercise
A "Get Account Summary" action has a required input accountId described as "Salesforce Id of the account". A user types "Summarize Globex", and the agent asks "What is the account Id?" What is the most likely cause, and how do you fix it?
Show answer
The topic has no lookup step, or its instructions do not tell the agent to find the account first, so the agent has only a name and no Id to fill the input. Add a lookup action (such as Identify Record by Name) to the topic, and add an instruction like "When the user names an account, first find the account record, then use the result for any later step." Also check that the Id input is not set to be collected from the user if it should come from the lookup's output.
Exercise
Why might you turn off display for an output such as a record Id, and what does that not prevent?
Show answer
Users rarely need to see raw Ids, so hiding the value keeps replies readable. It does not prevent the agent from using that value as an input to a later action, because display settings control what appears in the reply, not whether the value can be used in the chain.