Sub topic 4
Designing inputs the agent can fill
This chapter assumes you know what an Agentforce agent, topic, and action are. It also assumes you can read Flow variables or Apex classes. You will learn how the agent decides what value goes into each input, and how to write inputs so it gets that value right.
How the agent fills an input
When the agent picks an action, it must supply a value for each input. It does this by reading the input's label, description, and data type, then looking in the conversation for a matching value. The agent does not see your code, your field names in SOQL, or your intent. It sees only the metadata you wrote.
That makes each input a small prompt. If the text is vague, the agent guesses. If the text is specific, the agent can pull the right value from what the customer said, or ask for it.
Write one input per piece of information
Each input should hold one thing the customer can name. An order number is a good input. A single input called Details that expects the order number, the date, and a reason forces the agent to build a string you must later parse.
Prefer these habits:
- Name the input after the business concept, such as
Order Number, not after a field or variable, such asIdorvar1. - Ask for what the customer knows. Customers know an order number. They rarely know a record ID.
- Split compound values into separate inputs so each can be filled and checked on its own.
Write descriptions that guide the value
A good input description covers four points:
- What the value is, in business terms.
- An example of its format.
- What to do if the value is missing.
- What not to do, such as guessing.
Compare a weak and a strong version of the same input.
Weak input description:
Label: Id
Description: The id
Stronger input description:
Label: Order Number
Description: The order number the customer provided, for example 00000101. Ask the customer if it was not given. Do not guess.The weak version gives the agent nothing to match against. It might fill the input with a case ID, an account ID, or an invented value. The strong version names the concept, shows the format, and tells the agent how to behave when the value is absent.
See it in an Apex input
In Apex, the same guidance goes in the @InvocableVariable annotation on a request class.
public class Request {
@InvocableVariable(
label='Order Number'
description='The order number the customer provided, for example 00000101. Ask the customer if it was not given. Do not guess.'
required=true
)
public String orderNumber;
}The label is the short name the agent uses to refer to the input. The description carries the instructions. The required=true setting marks the input as one the action cannot run without. The next chapter covers required inputs in more detail.
In Flow, you get the same effect by setting a clear API name and description on each variable and enabling Available for input.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Agent passes a wrong ID or a made-up value | Description is vague or missing an example | Add format, example, and "do not guess" |
| Agent asks the user for something it already has | Input label names an internal concept the customer never used | Rename it to match the customer's words |
| Action fails on unexpected text | Input is a free-text string where a fixed set of values is expected | Describe the allowed values in the description |
| Two inputs get swapped | Labels and descriptions overlap | Make each description say how it differs from the other |
Exercise
An action has one input with the label "Id" and the description "The id". The agent sometimes sends a case ID when the action needs an order number. Rewrite the label and description so the agent supplies the right value.
Show answer
Label: Order Number. Description: "The order number the customer provided, for example 00000101. Ask the customer if it was not given. Do not guess." The label names the business concept, the example shows the format, and the last two sentences say what to do when the value is missing.