Sub topic 3
The agent user
This chapter assumes you know Salesforce users, profiles, and permission sets. It also assumes you know what an Agentforce agent, a topic, and an action are. The chapter covers what the agent user is, how to set it up, and the mistakes that most often cause problems.
What the agent user is
Some Agentforce agents do not run as the person who talks to them. They run as a dedicated Salesforce user, called the agent user. Every record the agent reads and every change it makes happens under this user's permissions. The customer typing in the chat has no effect on those permissions.
This means the agent user is the main boundary on what the agent can touch. Topics and instructions guide behavior, but the agent user's access is enforced by the platform. If the user cannot read an object, the agent cannot read it, whatever the prompt says.
The chapter on agent types covers which agents use this model. Here, assume you are building an agent that runs as a dedicated user, such as a customer-facing service agent.
How the agent user is built
An agent user is a regular user record with a few specific traits.
- It uses a license and profile intended for agents. Salesforce provides a minimum-access profile for this purpose, and you add access on top of it.
- It has no human owner who logs in. Nobody should know or use its credentials.
- It receives all of its data access through permission sets, not through the profile.
The profile should grant almost nothing. Permission sets then add exactly what the agent's actions need, which keeps the access easy to read and audit.
Giving the agent user its access
Create a permission set for each job the agent does, and assign it to the agent user. The following permission set gives read-only access to orders and the Status field.
<?xml version="1.0" encoding="UTF-8"?>
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
<label>Agent Order Read</label>
<description>Read-only access to orders for the service agent user</description>
<hasActivationRequired>false</hasActivationRequired>
<objectPermissions>
<allowCreate>false</allowCreate>
<allowDelete>false</allowDelete>
<allowEdit>false</allowEdit>
<allowRead>true</allowRead>
<modifyAllRecords>false</modifyAllRecords>
<object>Order</object>
<viewAllRecords>false</viewAllRecords>
</objectPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Order.Status</field>
<readable>true</readable>
</fieldPermissions>
</PermissionSet>Read the permissions line by line. Read is the only object right that is on. Create, edit, and delete are off. The viewAllRecords and modifyAllRecords flags are also off, so sharing still limits which orders the user can see. Field access is limited to Order.Status, so a query for other order fields will not return them.
The next chapters cover permission sets and sharing in more depth. For now, keep one idea in mind: start with nothing, then add only what an action needs.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| The agent says it cannot find a record that exists | The agent user lacks read access to the object, or sharing hides the record | Check object permissions, then sharing for that user |
| An action returns blank fields | Field-level security hides those fields | Add field permissions in the permission set |
| The agent can see far more than expected | The agent user has `viewAllRecords`, `modifyAllRecords`, or an admin profile | Remove broad rights and rebuild with narrow permission sets |
| Two agents behave identically in audits | They share one agent user | Create one agent user per agent |
Two habits prevent most of these problems. Give each agent its own agent user, so you can see which agent did what and change one agent's access without affecting another. Also test with the agent user's access in mind. An admin who tests an action under their own login will see results the agent never sees.
Exercise
A service agent runs as a dedicated agent user. An action that looks up order status works when an administrator tests it, but the agent reports that it cannot find any orders. Give two likely causes on the agent user's side, and say where you would check first.
Show answer
Likely causes: the agent user has no read permission on Order (or on the Status field), or sharing does not give the agent user access to those orders. Check the permission sets assigned to the agent user first, then the object and field permissions, then the sharing settings. The administrator's test worked because the administrator has broader access than the agent user.