Sub topic 6
Service Agents: Customer-Facing Support
A service agent is an Agentforce agent that talks to your customers. This chapter covers how it differs from an employee agent, how it gets its identity and data access, how its topics and actions are shaped by that audience, and the errors that appear most often in practice.
Prerequisites assumed: you know Salesforce objects, records, and permission sets. You have a beginner's grasp of Flow or Apex. You know in general terms what a large language model does. Earlier chapters covered topics, instructions, actions, and the reasoning engine, so this chapter only applies them to the service case.
What makes a service agent different
A service agent and an employee agent are built from the same parts: topics, instructions, and actions. The difference is the audience and the identity the agent acts under.
- Audience: the people asking are external. They are customers, prospects, or guests who often have no Salesforce login.
- Identity: the agent runs as a dedicated agent user, not as the person chatting. That user's permissions decide what the agent can read and change.
- Channels: service agents run on customer-facing channels, such as a messaging deployment in an Experience Cloud site or a web chat window.
- Escalation: when the agent cannot help, it hands the conversation to a human through Omni-Channel.
The audience drives the design. You cannot assume the customer is authenticated, and you cannot assume the customer's data access matches the agent's.
Identity: the agent user
A service agent acts as its agent user, a Salesforce user record created for the agent. Every record the agent reads, and every action it performs, is checked against that user's profile and permission sets.
This has two consequences.
- The agent user is the ceiling. If the agent user can see every Order in the org, the agent can return any order's status to anyone who types its number. The customer's own access does not narrow it.
- Least privilege is your main safeguard. Grant the agent user only the object and field permissions its topics need. Assign a dedicated permission set instead of cloning an administrator profile.
Compare this with an employee agent, covered in the next chapter. An employee agent runs in the context of the signed-in employee, so the employee's own permissions govern what comes back. A service agent has no such natural limit, so you must create one.
| Aspect | Service agent | Employee agent |
|---|---|---|
| Typical user | Customer or guest | Internal employee |
| Acts as | Dedicated agent user | The signed-in employee |
| Access ceiling | Agent user's permissions | Employee's permissions |
| Typical channel | Messaging, web chat, Experience site | Salesforce app, Slack, internal surfaces |
| Human handoff | Omni-Channel escalation | Usually not needed |
Topics for customer-facing work
Topics for a service agent should be narrow and written from the customer's point of view. The classification description is what the reasoning engine matches against the customer's message, so it should describe the customer's need rather than your internal process.
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.Look at the choices in these instructions.
- A defined scope. "A single order" and "Do not discuss refunds" keep the topic from growing into areas it was not tested for.
- A bounded retry. The agent asks the customer to check the number once, and then escalates. Without a limit, the agent can loop on a wrong order number.
- Report only the status. The instruction stops the model from adding details it was not given.
Instructions are guidance to the model, not enforced rules. They reduce the chance of off-topic answers but do not guarantee it. Permissions are the hard control.
Actions run with the agent user's access
The Order Status topic calls an action. One way to build it is an invocable Apex method. Because the agent user is the access ceiling, the class should declare with sharing so sharing rules apply to the query.
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;
}
}The method takes a list and returns a list, so it is bulk-safe. It runs one query for all requests instead of one per request. The description on the method matters, because the reasoning engine uses it, along with the labels, to decide when to call the action.
This is the most important design point for service agents. The with sharing keyword enforces the agent user's access. It does not enforce the customer's identity. You need to add that check yourself.
Grounding and the Trust Layer in a service context
Service agents answer public-facing questions, so the quality of their source material matters. Ground answers in knowledge articles and CRM data rather than letting the model answer from general training. Instructions such as "Report only the status returned by the action" keep the response tied to retrieved data.
Prompts and responses also pass through the Einstein Trust Layer, which can mask sensitive data before it reaches the model and applies toxicity checks. Later chapters cover this in detail. For service work, remember that the Trust Layer reduces risk but does not replace correct permissions.
Escalation as part of the design
A service agent should have a planned way out. Typical triggers include:
- The customer asks for a person.
- An action fails or returns no result after a bounded retry.
- The topic is out of scope, such as a refund request in the Order Status topic.
- The customer shows frustration.
Escalation routes the conversation into Omni-Channel, where a queue or skill-based routing assigns it to a human. The handoff should carry context, so the human does not ask the customer to repeat what they already said. Plan the routing configuration and staffing hours before you go live. An escalation into an empty queue leaves the customer waiting with no agent.
Common errors
| Problem | Likely cause | Fix |
|---|---|---|
| Agent returns data the customer should not see | Agent user has broad permissions, or the action does not verify identity | Reduce the agent user's permission set and add a verification step |
| Wrong topic is chosen | Overlapping classification descriptions | Rewrite descriptions to be distinct and customer-focused |
| Action is never called | Vague action description, or topic instructions do not name it | Name the action in the instructions and improve its description |
| Agent keeps asking the same question | No retry limit in instructions | Add a bounded retry, then escalate |
| Escalation leaves the customer waiting | Omni-Channel routing or queue has no available agents | Configure routing, queues, and business hours |
| Agent answers about topics outside its scope | Instructions lack explicit limits | Add "Do not discuss..." lines and test with out-of-scope prompts |
Design checklist
- Create a dedicated agent user and give it only the permissions the topics require.
- Write narrow topics with customer-focused classification descriptions.
- State what each topic must not do.
- Verify the customer's identity before any action returns personal data.
- Bound retries and define when to escalate.
- Test with real customer phrasing, including off-topic and adversarial messages.
Exercise
A service agent has an Order Status action that uses a with sharing Apex class. The agent user can read all Orders. A customer types another person's order number and gets its status. Which part of the design is missing, and what are two ways to fix it?
Show answer
The design does not verify that the order belongs to the customer. with sharing only applies the agent user's access, and that user can see every order. Two fixes: require the customer to authenticate and filter the query to records tied to that verified contact, or add a verification step in the topic instructions and action, such as matching the order number against the verified customer's email, before returning any status. Reducing the agent user's permissions also helps, but it does not by itself tie results to the asking customer.
Exercise
Your Order Status topic tells the agent to ask the customer to re-check an order number "once" and then offer a human. Why is the limit important, and what could go wrong if you leave it out?
Show answer
Without a limit, the agent can loop, repeatedly asking for a number that does not exist, which frustrates the customer and never resolves the issue. A bounded retry followed by an escalation offer gives the customer a path to help. Note that the instruction guides the model but is not a hard rule, so you should test the behavior.