Sub topic 1
What Agentforce Is and How Agents Are Structured
Agentforce is Salesforce’s platform for building AI agents that understand requests, decide what to do, and use Salesforce data or actions to complete work. An agent is more than a chat interface. It combines a reasoning engine with a defined audience, topics, instructions, actions, and permissions.
Prerequisites
This chapter assumes you understand Salesforce objects, records, and permission sets. You should also know the basic purpose of Flow or Apex and have a general idea of how a large language model generates responses.
Agent Types and Starting Templates
Agentforce provides templates for common jobs. The two main types are:
| Agent type | Main audience | Typical purpose |
|---|---|---|
| Service agent | Customers or other external users | Answer questions and resolve support requests |
| Employee agent | Internal Salesforce users | Help employees find information or complete work |
A service agent might look up an order for a customer. An employee agent might summarize cases assigned to the current employee. The template gives you a starting structure, but the agent still needs carefully defined topics, actions, and access settings.
Topics and Instructions
A topic defines a category of work that the agent can handle. It normally includes:
- A classification description that helps the agent recognize related requests.
- A scope statement that limits the work.
- Instructions that specify the required steps, response rules, and boundaries.
For example, an Order Status topic can tell the agent to ask for an order number, call a status action, and report the returned status. It can also tell the agent not to discuss refunds in that topic.
The topic description helps selection. The instructions control behavior after selection. A common error is writing broad instructions such as “help with orders.” Specific boundaries produce more predictable results.
Actions
An action is an operation the agent can call. Actions can use built-in capabilities, Flow, or an Apex invocable method. An action should define its inputs, perform a limited task, and return clear outputs.
public with sharing class GetOrderStatusAction {
public class Request {
@InvocableVariable(required=true)
public String orderNumber;
}
public class Response {
@InvocableVariable
public String status;
}
@InvocableMethod(label='Get Order Status')
public static List<Response> getStatus(List<Request> requests) {
Set<String> numbers = new Set<String>();
for (Request request : requests) numbers.add(request.orderNumber);
Map<String, String> statuses = new Map<String, String>();
for (Order order : [
SELECT OrderNumber, Status
FROM Order
WHERE OrderNumber IN :numbers
]) {
statuses.put(order.OrderNumber, order.Status);
}
List<Response> results = new List<Response>();
for (Request request : requests) {
Response response = new Response();
response.status = statuses.containsKey(request.orderNumber)
? statuses.get(request.orderNumber)
: 'Order not found';
results.add(response);
}
return results;
}
}Exercise
What is the difference between a topic and an action?
Show answer
A topic defines the type and boundaries of work. An action performs a specific operation and returns results.