Sub topic 7
Designing Actions So the Confirmation Is Clear
This chapter assumes you know what an Agentforce agent is, how to open an agent in Agent Builder, and how to write a basic Flow or Apex invocable method. You should also know that the "Require user confirmation" setting exists. The earlier chapters cover it. Here the question is different: once the agent asks for approval, will the user be able to tell what they are approving?
Why action design controls confirmation quality
The confirmation setting makes the agent pause before it runs an action. It does not write the question for you. The agent builds the question from what it can see:
- the action name
- the action description
- the input names and input descriptions
- the values it has collected so far
- your topic instructions
If those pieces are vague, the confirmation will be vague too. A prompt like "Do you want me to run Update Record?" is technically a confirmation, but it gives the user nothing to check. Approving it is the same as not being asked.
The rest of the chapter works through each design element in turn.
Name the action for what it does
The action name is the first thing the agent and the user see. Use a verb and a specific object.
- Good:
Update Case Status,Delete Draft Quote,Reassign Opportunity Owner - Weak:
Update Record,Case Helper,Run Process
A narrow name also limits what the agent can do with the action. An action called Update Record that accepts any object and field can change anything the running user can edit. The confirmation cannot be specific because the action is not specific. Prefer one action per kind of change.
Say in the description that data changes
The description tells the agent when to use the action and what happens when it runs. For a data-changing action, include three things:
- The effect, in plain words: "Changes the Status field of one case."
- An explicit statement that it modifies data: "This modifies data."
- Any limits: "Only one case per call" or "Cannot be undone."
The Apex example from this tutorial does this in its @InvocableMethod description. For a Flow, put the same text in the description of the Flow when you create the action. In Agent Builder, the instructions field on the action is where you can add further guidance for the agent.
Keep the description true. If the Flow also sends an email or sets a second field, say so. A description that hides a side effect means the confirmation hides it as well, and the user approves a change they were never told about.
Design inputs the user can verify
The inputs are the values the agent must collect, and they become the details in the confirmation. Three rules help.
Prefer values a person can recognize. A 15-character record Id such as 5001R00000AbCdE is hard to check by eye. If the user types a case number, the agent can echo it back, and the user can compare. When the user does not know the Id, add a separate read-only action that looks up a record by a human-readable value, such as a case number or account name. The agent then confirms with a name rather than an Id. A read action does not need confirmation, so this adds no friction.
Describe each input with an example and the allowed values. The agent uses the input description to decide what to ask for and what to put in the message. Compare:
| Input | Weak description | Clear description |
|---|---|---|
| `newStatus` | Status | The new value for the Status field, for example Closed. Use only existing case status values. |
| `caseId` | Case | The Id of the case to update |
| `reason` | Reason | Short reason for the change, written by the user. Do not make one up. |
Keep inputs narrow. Avoid inputs like "fields to update" that carry a free-form list or JSON. The agent has to guess the structure, and the confirmation turns into a block of text the user cannot read. One input per value that changes is easier to display and easier to validate.
A related decision is who supplies each input. If a value should come from the user, mark it required and describe it as something to collect. If the agent could fill it from the conversation, you need the confirmation to show that value anyway, because the user may not have said it. Never rely on a default the user has not seen.
Return an output that reports what happened
Confirmation happens before the action, but the result message happens after, and the user reads it to learn whether the change worked. Return a short, specific output such as Case 5001R00000AbCdE set to Closed rather than Success. If the record was not found or the update failed, return that in the message instead of throwing an unhandled exception, so the agent can tell the user in plain language.
A fuller Apex example
The Apex action from the spine updates a case but reports only the new value. The version below also reads the current status first and reports the old and new values. It runs with the user's permissions, and it returns one result per request in the same order, which invocable methods require.
public with sharing class UpdateCaseStatusAction {
public class Request {
@InvocableVariable(required=true label='Case Id' description='The Id of the case to update')
public Id caseId;
@InvocableVariable(required=true label='New Status' description='The new value for the Status field, for example Closed. Use only existing case status values.')
public String newStatus;
}
public class Result {
@InvocableVariable(label='Message' description='Outcome of the update, including the old and new status')
public String message;
}
@InvocableMethod(
label='Update Case Status'
description='Changes the Status field of one case. This modifies data and does not send any email.'
)
public static List<Result> updateStatus(List<Request> requests) {
Set<Id> ids = new Set<Id>();
for (Request r : requests) {
ids.add(r.caseId);
}
Map<Id, Case> existing = new Map<Id, Case>(
[SELECT Id, Status FROM Case WHERE Id IN :ids WITH USER_MODE]
);
List<Case> toUpdate = new List<Case>();
List<Result> results = new List<Result>();
for (Request r : requests) {
Result res = new Result();
Case c = existing.get(r.caseId);
if (c == null) {
res.message = 'Case ' + r.caseId + ' was not found or is not visible to you. Nothing was changed.';
} else {
String oldStatus = c.Status;
toUpdate.add(new Case(Id = c.Id, Status = r.newStatus));
res.message = 'Case ' + c.Id + ' changed from ' + oldStatus + ' to ' + r.newStatus;
}
results.add(res);
}
update as user toUpdate;
return results;
}
}Several design choices here support a clear confirmation. The method description says it modifies data and has no side effects. The newStatus description limits the allowed values. A missing case produces an explicit "nothing was changed" message. The output reports old and new values, so the user can see exactly what happened.
You can also use the same lookup to build a pre-check action. A read-only action that returns the current status lets the agent say "Case X is currently Open. I will set it to Closed. Go ahead?" before asking for approval, which makes the confirmation more informative than the input values alone.
Edge cases to plan for
- Several records in one request. If the user says "close all my open cases," the confirmation should state the count and, for small numbers, list the records. If your action handles only one record per call, say so in the description and let the topic instructions tell the agent to confirm each call.
- Values the agent inferred. If the user says "close it" and the agent works out which case from earlier in the conversation, the confirmation must name that case. Add a line to the topic instructions such as "Always name the record and the new value in the confirmation."
- Generic actions. An action that takes an object name and a field name can only produce a generic confirmation. Split it into specific actions, or add a record summary to the output of a lookup step.
- Description drift. When someone edits the Flow or Apex later and adds a side effect, the description must change too. Review the descriptions when you review the logic.
- Renamed actions. Topic instructions often mention an action by name. If you rename the action, update the instructions so they still match.
- Optional inputs with silent defaults. If an input is optional and the Flow applies a default, mention the default in the description so the agent can state it.
A quick design checklist
Before you rely on the confirmation setting for an action, check each item:
- The name has a verb and a specific object.
- The description says that data changes and lists every side effect.
- Each input has a plain-language description, an example, and its allowed values.
- The user can recognize the input values, or a lookup action converts them.
- The output reports what changed, and failures return a readable message.
- Topic instructions tell the agent to name the record and the new value before asking.
You can test all six in conversation preview, which a later chapter covers. If the agent's confirmation leaves out a detail you expected, trace it back to this list. The missing detail is almost always missing from a description, an input, or the instructions.
Exercise
An action called Update Record takes objectName, recordId, and fieldsJson as inputs. Give two reasons it produces poor confirmations, and describe how you would redesign it for changing an opportunity's stage.
Show answer
The name and the inputs are generic, so the agent can only say something like "I will update a record," and the user cannot tell which record or which field changes. The fieldsJson input is also a free-form structure that the agent must guess and that the user cannot read easily. Redesign it as Update Opportunity Stage with two inputs: the opportunity (identified by a name or Id the user can recognize, possibly through a read-only lookup action) and newStage, described with an example and the allowed stage values. The description should state that it modifies data. The confirmation can then say "I will move Acme Renewal to Closed Won."
Exercise
A Flow action named Close Case also sends a satisfaction survey email to the contact. Its description reads "Closes a case." What is wrong, and how would you fix it?
Show answer
The description hides a side effect. The agent will confirm only the closing, so the user approves without knowing an email will go out. Update the description to say that it sets the case status to Closed, sends a survey email to the case contact, and modifies data. Add a line to the topic instructions so the agent mentions the email in the confirmation. If the two steps are independent, consider splitting them into separate actions.