Sub topic 7
Employee agents: assistants for internal users
What this chapter covers
This chapter assumes you know basic Salesforce concepts (objects, records, permission sets) and have read the earlier chapters on topics, instructions, and actions. It explains how an employee agent differs from a service agent, how it uses the signed-in user's identity, and where it typically goes wrong.
By the end you should be able to describe what an employee agent is for, write a topic for one, and predict what data it will and will not show.
What an employee agent is
An employee agent is an Agentforce agent whose users are people inside your company. Examples are sales reps, support staff, and administrators. It helps them find information, summarize records, and complete routine tasks without leaving the tools they already use.
It is built from the same parts as a service agent: topics, instructions, and actions. The reasoning engine selects a topic and calls actions the same way. The differences are in who is talking to it, whose permissions apply, and where it runs.
| Aspect | Service agent | Employee agent |
|---|---|---|
| Audience | Customers and other external users | Internal users |
| Identity for data access | A dedicated agent user | The signed-in user (the running user) |
| Typical channels | Web chat, messaging, and similar customer channels | Salesforce UI, Slack, and other internal surfaces |
| Escalation | Often hands off to a human through Omni-Channel | Usually none, because the user is already an employee |
| Main risk | Exposing data to the wrong customer | Returning data the employee should not see |
Identity: the running user
A service agent acts as a single agent user that you configure. An employee agent acts as the person asking the question. Each action runs with that person's permissions, so two employees can ask the same question and get different answers.
This is useful because you do not have to build a separate access model for the agent. Profiles, permission sets, sharing rules, and field-level security already describe what each employee can see. The agent inherits them.
It also means that the safety of an employee agent depends on how your actions are written. An action that bypasses sharing can return data the employee could not open themselves.
Topics for employee agents
A topic for an employee agent has the same structure as one for a service agent. It has a classification description that helps the agent choose it, a scope, and instructions. The wording differs because the audience is internal and the permissions come from 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 three choices in this topic:
- The classification description names the audience ("an employee") and the subject ("cases assigned to them or their team"). This helps the reasoning engine pick the topic and avoid unrelated requests.
- The scope states a limit: only cases the employee can already view. The instructions repeat this limit in plain language.
- The last instruction says what to do when access is denied. Without it, the agent may guess or apologize vaguely.
Keep each topic narrow. A topic called "Everything about cases" gives the reasoning engine too many ways to match, and it makes the instructions long and contradictory.
Actions that respect the user
Employee agent actions often call Flow or Apex. For Apex, the key keyword is with sharing. It makes the class enforce record sharing for the running user. The following invocable method is a service-style example, but the same pattern applies to any employee action.
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;
}
}Three details matter here:
with sharingrestricts the query to orders the running user can see.- The method accepts and returns lists. Invocable methods can receive several requests at once, so the query runs once for the whole batch instead of once per request.
- When an order is hidden by sharing, the query returns no row, and the method returns "Order not found". The employee cannot tell a missing order from a hidden one. That is usually the behavior you want.
with sharing does not enforce field-level security or object permissions on its own. If a field must be hidden from some employees, add a check such as WITH USER_MODE in the query or use Security.stripInaccessible. Treat this as a design decision for each action, not as something the agent handles.
Where employee agents run
Employee agents run on internal surfaces. The common ones are the Salesforce application, where the agent appears in a panel next to the records an employee is working on, and Slack. Because the user is already signed in, the agent does not need to verify who they are. The platform passes the user's identity to the actions.
This has a practical effect on testing. If you test an employee agent as an administrator, you may see results that regular employees will never see. Test as a user with the same profile and permission sets as your target group.
Common errors
- Actions that run in system mode. An Apex class declared without
with sharing, or a Flow set to run in system context, can return records the employee cannot open. The agent will present them without any warning. - Testing only as an administrator. Everything works, and then real users report "not found" replies. Check the permission sets of the people who will use the agent.
- Vague scope. If the scope does not say what the topic must refuse, the agent may attempt related requests, such as editing records when you only intended it to summarize them.
- Missing access-denied instructions. The agent invents an explanation. Tell it exactly what to say.
- Treating the agent as a security boundary. Instructions guide behavior, but they do not enforce access. Permissions do. If a rule matters for security, put it in sharing, field-level security, or the action itself.
Summary of design rules
- Give each topic one clear job and a short list of instructions.
- State the audience and the limit in the scope.
- Write every action with the running user's access in mind.
- Test with real permission sets, not only as an administrator.
- Enforce security in the platform, and use instructions only for behavior and tone.
Exercise
An employee asks the agent for the status of an order and gets "Order not found", but a colleague in another team finds the same order immediately. The Apex class is declared with sharing. What is the most likely cause, and how would you confirm it?
Show answer
The first employee probably lacks sharing access to that order, so the query returns no row and the method falls back to "Order not found". The agent is working as designed. To confirm, check the record's sharing settings and the employee's role, profile, and permission sets, or run the same query as that user through a test that uses System.runAs. If the employee should have access, change the sharing rules or permissions, not the action.
Exercise
You are writing a topic that lets employees view cases. Name two things the instructions should say that are specific to an internal audience, and one thing they cannot guarantee.
Show answer
They should say to use the action that retrieves cases for the current user, and what to reply when the employee asks about data they cannot access. They cannot guarantee security, because instructions guide the agent's wording and choices while access is enforced by sharing, object permissions, and field-level security.