Sub topic 3
What actions are and the types that exist
This chapter assumes you know the basic Salesforce data model (objects, fields, records), can find your way around Setup, and understand that an agent uses a large language model (LLM) to interpret requests. You should also know what a topic is: a scoped job with a description and instructions.
What an action is
An action is a unit of work an agent can run. The LLM does not read or change Salesforce data on its own. It chooses an action, supplies inputs, and the platform runs it and returns the outputs. The agent then uses those outputs to write a reply or pick the next step.
Each action has a name, a description, inputs, and outputs. The agent reads the name and description to decide whether the action fits the user's request. Clear descriptions lead to better choices.
How actions run at runtime
An action belongs to a topic. The agent only considers actions in the topic it has selected, so the topic limits what the agent can do.
Types of actions
Actions differ by what runs behind them. The table lists the types you will meet.
| Type | What runs | Typical use |
|---|---|---|
| Standard | Prebuilt capability from Salesforce | Query records, summarize a record, draft an email |
| Flow | A Flow you build | Multi-step business logic with declarative tools |
| Apex | An invocable Apex method | Logic that needs code |
| Prompt template | A prompt template | Generating text from record data |
This tutorial focuses on standard actions. They need no code and are the quickest way to give an agent useful behavior. The other types are called custom actions, and a later chapter explains when to use them.
A custom action for comparison
A custom Apex action shows the same parts every action has: a described input, a described output, and a method the agent can call. This example counts open cases for an account.
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 with sharing keyword makes the method respect sharing rules, so the agent only counts records the running user can see. The label and description fields are what the agent reads when it decides whether to call the action.
Common errors
- Vague action descriptions. The agent may pick the wrong action or skip the right one.
- Expecting an action to be available outside its topic. Add it to every topic that needs it.
- Treating the model as the source of data. If a fact must come from Salesforce, the topic needs an action that retrieves it.
Exercise
Why does the agent need an action to read an account's open cases, instead of answering from the model alone?
Show answer
The model has no direct access to Salesforce data. An action runs on the platform, retrieves the records the user is allowed to see, and returns them as outputs the agent can use in its reply.
Exercise
A standard action exists in one topic, but the agent cannot use it in another topic. What is the likely cause and fix?
Show answer
Actions belong to a topic, and the agent only considers actions in the selected topic. Add the action to the second topic.