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 basic Apex or build a Flow with input variables. An input is a value the agent must supply when it calls an action. The agent does not read your code. It reads the label, the description, and the data type of each input, and it decides from those what to put there.
What the agent does with an input
When a customer sends a message, the agent's language model picks an action. It then builds a value for each input from the conversation so far. Three sources feed that step:
- What the user said in this conversation.
- Values stored in variables or earlier action results.
- The text you wrote in the input's label and description.
If those sources do not give a clear answer, the model may ask the user, leave the input empty, or make a guess. Your design work is to make the clear answer easy to find and the guess unlikely.
The last branch is the one to design against. A weak description does not stop the action from running. It lets the action run with a wrong value.
Write the label for a person, the description for the model
The label is a short noun phrase. The description is a full instruction. Use the label to name the business concept, not the storage detail. Use the description to cover what the value is, what it looks like, where it comes from, and what to do if it is missing.
Compare these two definitions 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 fails in three ways. "Id" could mean a record Id, an order number, or a case number. "The id" gives no format, so the model cannot tell a valid value from an invalid one. It also gives no instruction for the missing case.
A useful description answers four questions:
- What is this value in business terms?
- What does a valid value look like? Give one example.
- Where should the agent get it? From the user, from a prior action, or from a variable.
- What should the agent do if it does not have the value?
The example in the description matters more than it seems. A sample such as 00000101 shows length and character set at once. Use a realistic sample, but one that is obviously not a real customer record.
One input, one meaning
Each input should carry one idea. Avoid inputs such as "Search Text" that accept an order number, an email address, or a name depending on the day. The model then has to guess which kind of value the user gave, and the action has to guess how to interpret it.
Two patterns help:
- Split the input. Use separate
Order NumberandCustomer Emailinputs, and say in each description that the other one exists. - Name the format. If the input accepts only a date in a given format, say so in the description and use a date type where the platform allows it (see the data types chapter).
Use names that do not collide
If an action has inputs called Account and Account Name, the model has to choose between them. State the difference in the descriptions: "The 18-character Salesforce record Id of the account" against "The company name as the customer typed it". Better, avoid exposing a record Id at all unless a previous action returned it. Users do not know record Ids, and the agent cannot invent them.
Inputs the agent should not invent
Some inputs must come from the user or from a trusted earlier step. Examples are order numbers, amounts, email addresses used to send messages, and any value that triggers a change to a record. For these, the description should say so directly:
- "Ask the customer if it was not given."
- "Do not guess."
- "Use only the value returned by the Find Account action."
The phrase "Do not guess" is plain, and it works. Without it, a model that is trying to be helpful may fill a gap with a plausible value. With a read-only lookup, that gives a wrong answer. With an update action, it changes the wrong record.
Whether the agent asks or proceeds is also controlled by whether the input is required. The next chapter covers that setting. For now, note that the description and the required setting work together. A required input with a vague description still produces a bad question. An optional input with a strong "Do not guess" instruction tends to be left empty instead of invented.
Show the design in an Apex action
In Apex, the label and description live in the @InvocableVariable annotation. Here is a complete lookup action. Read the input and output annotations as the agent would.
public with sharing class GetOrderStatus {
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;
}
public class Response {
@InvocableVariable(
label='Order Status'
description='Current status of the order, such as Draft or Activated. Empty if no order was found.'
)
public String status;
@InvocableVariable(
label='Result Message'
description='A short plain-language message describing the outcome, including when no order matches the number.'
)
public String message;
}
@InvocableMethod(
label='Get Order Status'
description='Looks up the status of one order by its order number. Use when the customer asks where their order stands.'
)
public static List<Response> getStatus(List<Request> requests) {
Set<String> numbers = new Set<String>();
for (Request r : requests) {
numbers.add(r.orderNumber);
}
Map<String, Order> byNumber = new Map<String, Order>();
for (Order o : [SELECT OrderNumber, Status FROM Order WHERE OrderNumber IN :numbers WITH USER_MODE]) {
byNumber.put(o.OrderNumber, o);
}
List<Response> results = new List<Response>();
for (Request r : requests) {
Response res = new Response();
Order o = byNumber.get(r.orderNumber);
if (o == null) {
res.message = 'No order was found with number ' + r.orderNumber + '.';
} else {
res.status = o.Status;
res.message = 'Order ' + r.orderNumber + ' has status ' + o.Status + '.';
}
results.add(res);
}
return results;
}
}Points to notice on the input side:
- There is one input, and it has one meaning. The class name
Requestis a wrapper, which Apex requires for invocable methods with more than one field. - The description gives an example, a source (the customer), and a missing-value rule.
- The method description says when to use the action. That text decides whether the agent selects the action at all, so it must match the way customers phrase the request.
- The method takes a list because invocable methods run in bulk. The agent normally sends one request, but your code must handle a list.
In Flow, the same information goes into the description field of each input variable. Mark the variable as available for input so that it appears on the action.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| The agent passes a name where an order number is expected | The label is generic, such as "Id" or "Value" | Rename to the business concept and add a format example |
| The agent runs the action without asking the user | The input is optional and the description has no missing-value rule | Mark it required, or add "Ask the customer if it was not given" |
| The agent asks the user for a record Id | The input exposes a storage detail | Take a business key instead, or fill the Id from a prior action |
| The agent fills the wrong one of two similar inputs | Two descriptions overlap | Say in each description how it differs from the other |
| The agent invents a value such as a date | No source is named | Name the source and add "Do not guess" |
Edge cases
- Descriptions are not validation. Telling the agent that an order number has eight digits does not stop a wrong value from arriving. Check format in your Apex or Flow, and return a clear message when the check fails.
- Long descriptions cost attention. A paragraph per input makes the action hard for the model to weigh against other actions in the topic. Keep each description to one to three sentences.
- Renaming an input can break references. If a Flow, a topic instruction, or a saved test refers to the old name, update those places in the same change.
- Example values can leak into answers. If you write an example such as
00000101, the agent might repeat it in a reply. Use values that are clearly samples.
Review checklist
- Each input has a label that names a business concept.
- Each description states what the value is, what it looks like, where it comes from, and what to do if it is missing.
- No two inputs overlap in meaning.
- Inputs that must come from the user say "Do not guess".
- The action validates the values it receives, and does not trust the description to do so.
Exercise
An action called Update Shipping Address has one input with the label "Value" and the description "The value to set". The agent keeps writing the customer's email address into the address field. Rewrite the label and description, and say which two parts of your rewrite fix the problem.
Show answer
Label: "New Shipping Address". Description: "The full street address the customer wants orders shipped to, for example 12 Main Street, Springfield. Ask the customer if it was not given. Do not guess." The label fixes the problem by naming the business concept, so "Value" no longer fits any text. The description fixes it by giving the kind of value, an example format, and a rule for the missing case.
Exercise
A lookup action has one input named "Search Text". Customers sometimes give an order number and sometimes an email address. What is the problem, and how would you redesign the inputs?
Show answer
One input carries two meanings, so the agent and the action must both guess which kind of value it holds. Split it into "Order Number" and "Customer Email", each with its own example and a note about the other input, and have the action use whichever one was supplied.