Sub topic 1
How Agentforce Actions Run
Prerequisites
Assume you know basic Salesforce records and objects, understand what an Agentforce agent does, and have seen a Flow or Apex invocable method.
How Agentforce actions run
An Agentforce action is an operation the agent can select and run to fulfill a request. Actions can be built from:
- A Flow
- An Apex invocable method
- A prompt template
The agent interprets the user's message, selects a topic, gathers required inputs, and chooses an available action. The action then receives those inputs and returns a result to the conversation.
For example, an Apex action can accept a case ID and a new status:
public with sharing class UpdateCaseStatusAction {
public class Request {
@InvocableVariable(required=true)
public Id caseId;
@InvocableVariable(required=true)
public String newStatus;
}
@InvocableMethod(label='Update Case Status')
public static List<String> updateStatus(List<Request> requests) {
List<Case> casesToUpdate = new List<Case>();
for (Request request : requests) {
casesToUpdate.add(new Case(
Id = request.caseId,
Status = request.newStatus
));
}
update casesToUpdate;
return new List<String>{'Case status updated'};
}
}The action's label, description, input labels, and input descriptions help the agent decide when to use it and what values to collect.
Spotting actions that change data
An action changes data when it creates, updates, or deletes a Salesforce record. Updating a case status, creating a task, and deleting a contact are examples.
A read-only action only retrieves information. It might search cases or calculate a value without saving changes.
| Action type | Example | User approval |
|---|---|---|
| Read-only | Find open cases | Usually not needed |
| Data-changing | Set a case to Closed | Usually needed |
Inspect the Flow elements or Apex statements to identify writes. Statements such as insert, update, and delete change records. A data-changing action deserves extra review because the agent may misunderstand the user's intent or use an incorrect record.
Why a data-changing action should ask first
Confirmation gives the user a final opportunity to catch an incorrect record, field value, or interpretation. It is especially important when the change is difficult to reverse, affects other users, or triggers automation.
The agent should summarize the pending change in concrete terms, then wait. For example: “I will set case 5001R00000AbCdE to Closed. Do you want me to continue?” A decline or missing answer must leave the action unexecuted.
Exercise
Which action needs confirmation: finding a customer's open cases or changing a case's priority to Urgent?
Show answer
Changing the case's priority to Urgent changes Salesforce data, so the agent should ask for approval first.