Sub topic 2
Agent types and the templates you start from
This chapter covers the agent types in Agentforce and the templates you start from when you create one. It assumes you know basic Salesforce concepts (objects, records, permission sets), have a beginner's familiarity with Flow or Apex, and have a general idea of what a large language model does. The chapter before this one introduced how agents are structured from topics, instructions, and actions. Here you will see how the choice of agent type sets the starting values for those parts.
Why the agent type is the first decision
When you create an agent in Agent Builder, the first choice is the agent type. The type is a starting point. It decides who the agent is meant to talk to, which identity it runs under, which channels it can be connected to, and which topics and actions come preconfigured.
Two types matter most in this tutorial:
- A service agent is an agent that talks to external users, usually customers, on channels such as a website chat or messaging. It runs under a dedicated agent user.
- An employee agent is an agent that helps internal users, such as sales reps or support staff, inside Salesforce and connected workplace apps. It runs as the employee who is using it.
A template is a prebuilt agent definition that you copy and then edit. It contains an agent type, a set of topics, instructions, and actions. You rarely build every piece from scratch.
The exact names of templates, and which ones are available, change between Salesforce releases and between orgs. Treat the names in this chapter as examples, and check the options in your own org's Agent Builder.
What a type decides
The table below compares the two types on the points you will configure first.
| Decision | Service agent | Employee agent |
|---|---|---|
| Audience | Customers and other external users | Employees and other internal users |
| Identity at run time | A dedicated agent user that you configure | The user who is chatting with the agent |
| Data access | Limited by the agent user's permissions | Limited by that employee's own permissions |
| Typical channels | Messaging, web chat, and similar customer channels | Salesforce UI, and workplace apps such as Slack |
| Typical first topics | Order status, returns, general questions | Case summaries, record updates, internal knowledge |
| Escalation | A human service rep through Omni-Channel | Usually none, since the user is already an employee |
Later chapters cover identity, channels, and escalation in detail. For now, keep one point in mind: the type fixes the identity model. A service agent has no logged-in human behind it, so it needs its own user. An employee agent always has a logged-in human behind it, so it borrows that person's access.
How a template is organized
A template is not a different kind of object from an agent. It is an agent definition with the same parts you will build by hand later. Opening a template shows these pieces:
- Agent type and role. The type, plus a short description of the role the agent plays, such as handling customer service questions.
- Topics. Each topic has a classification description, a scope, and instructions. The agent uses the description to decide which topic matches a request.
- Actions. Each topic lists the actions the agent may call. A template action is often backed by a standard Flow or Apex action that ships with Salesforce, and you can swap it for your own.
- Agent-level settings. Settings such as the agent name, a welcome message, an error message, and the agent user for service agents.
The diagram shows how these pieces nest.
Once you save an agent from a template, it is an independent copy. Changing the template later does not change agents you already created from it.
Starting from a service agent template
A service agent template begins with topics aimed at common support work. A typical set includes a topic that answers general questions from knowledge, a topic for looking up order or case status, and a topic for handling requests the agent cannot do, such as an escalation topic.
Here is the kind of topic you would find or write when you customize such a template. The classification description is short because the agent compares it with the customer's message. The instructions are specific because they control what the agent does after the topic is chosen.
Topic: Order Status
Classification description: Customer asks where an order is or what state it is in.
Scope: Look up the status of a single order using the Get Order Status action.
Instructions:
- Ask for the order number if the customer has not given one.
- Call the Get Order Status action with that order number.
- Report only the status returned by the action.
- If the action returns 'Order not found', ask the customer to check the number once, then offer to connect them with a human agent.
- Do not discuss refunds or cancellations in this topic.The last instruction matters as much as the first. A scope boundary stops the agent from drifting into subjects it has no action for. Templates ship with sensible boundaries, but they cannot know your business rules, so review each one.
The topic above relies on a Get Order Status action. If your org does not already have one, you can write it as an Apex invocable method:
public with sharing class GetOrderStatusAction {
public class Request {
@InvocableVariable(label='Order Number' required=true)
public String orderNumber;
}
public class Response {
@InvocableVariable(label='Order Status')
public String status;
}
@InvocableMethod(
label='Get Order Status'
description='Returns the status of an order for a given order number'
)
public static List<Response> getStatus(List<Request> requests) {
Set<String> orderNumbers = new Set<String>();
for (Request r : requests) {
orderNumbers.add(r.orderNumber);
}
Map<String, String> statusByNumber = new Map<String, String>();
for (Order o : [SELECT OrderNumber, Status FROM Order WHERE OrderNumber IN :orderNumbers]) {
statusByNumber.put(o.OrderNumber, o.Status);
}
List<Response> results = new List<Response>();
for (Request r : requests) {
Response res = new Response();
res.status = statusByNumber.containsKey(r.orderNumber)
? statusByNumber.get(r.orderNumber)
: 'Order not found';
results.add(res);
}
return results;
}
}Two details in this class come up repeatedly. The with sharing keyword makes the query respect record access rules for the user the code runs as. The method takes and returns lists, so it handles several requests in one call without running a query per request. Chapter on custom actions covers the pattern fully.
Starting from an employee agent template
An employee agent template begins with topics for internal tasks. Examples include summarizing records, answering questions from internal knowledge, and helping with routine updates. The structure is the same as a service agent topic. The difference is in the assumptions the instructions make about the user.
Topic: My Open Cases
Classification description: An employee asks about support cases assigned to them or their team.
Scope: Summarize cases the employee already has permission to view.
Instructions:
- Use the Get Open Cases action to retrieve cases for the current user.
- Present each case with its number, subject, and status.
- If the employee asks about data they cannot access, say that you cannot show it and suggest contacting their administrator.Notice what is missing compared with the service topic. There is no step to ask the user who they are, because the agent already knows. There is no offer to hand off to a human, because the user is staff. The final instruction exists because the action returns only what the employee's permissions allow, and the agent should explain an empty result rather than guess.
Common mistakes when starting from a template
- Leaving unused topics enabled. A template may include topics you do not need. Each extra topic is another candidate the agent can pick by mistake. Remove or disable what you will not support.
- Keeping template actions without checking them. A standard action may touch objects or fields your org handles differently. Open each action and confirm its inputs, outputs, and the data it reads.
- Writing overlapping classification descriptions. If two topics describe similar requests, the agent may choose the wrong one. Make each description describe a distinct request.
- Granting the agent user broad access. For a service agent, start with a minimal permission set and add access only when a specific action needs it.
- Choosing the type by channel alone. The type also decides identity and data access. Pick it based on who the user is first, then check that the channel you want supports that type.
A short selection checklist
Before you pick a template, answer these questions in order:
- Is the person talking to the agent a customer or an employee?
- Will they be logged in to your Salesforce org or workplace app?
- Should the agent see only what that person can see, or a fixed set of data you choose?
- Does the conversation sometimes need a human rep to take over?
Customers and a fixed data set point to a service agent. Logged-in staff and personal access point to an employee agent. The final chapter of this tutorial returns to this decision with full use cases.
Exercise
A company wants an assistant that lets sales reps ask for a summary of their own open opportunities inside Salesforce. Which agent type fits, which identity does it run under, and why is a dedicated agent user not needed?
Show answer
An employee agent fits, because the users are internal staff working inside Salesforce. It runs as the rep who is chatting with it, so the data returned is limited to what that rep's permissions already allow. A dedicated agent user is not needed because the logged-in rep supplies the identity and access, and the agent does not need a separate account to decide what data it can read.
Exercise
You create a service agent from a template. It includes a topic for refund requests, but your company handles refunds only by phone. What should you do with that topic, and what risk does leaving it enabled create?
Show answer
Disable or remove the refund topic, or rewrite its instructions to direct customers to the phone process. Leaving it enabled gives the agent another topic to choose from, so it may match a customer's request to it and then try to handle something it has no approved action for, which can give customers wrong or misleading answers.