@salesforce/afv-skills 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -5
- package/skills/accessing-webapp-data/SKILL.md +178 -0
- package/skills/agentforce-development/SKILL.md +427 -0
- package/skills/agentforce-development/assets/README-legacy.md +89 -0
- package/skills/agentforce-development/assets/agent-spec-template.md +90 -0
- package/skills/agentforce-development/assets/agents/README.md +45 -0
- package/skills/agentforce-development/assets/agents/hello-world.agent +60 -0
- package/skills/agentforce-development/assets/agents/multi-topic.agent +105 -0
- package/skills/agentforce-development/assets/agents/production-faq.agent +101 -0
- package/skills/agentforce-development/assets/agents/production-faq.bundle-meta.xml +4 -0
- package/skills/agentforce-development/assets/agents/simple-qa.agent +72 -0
- package/skills/agentforce-development/assets/apex/models-api-queueable.cls +225 -0
- package/skills/agentforce-development/assets/bundle-meta.xml +23 -0
- package/skills/agentforce-development/assets/components/apex-action.agent +52 -0
- package/skills/agentforce-development/assets/components/error-handling.agent +58 -0
- package/skills/agentforce-development/assets/components/escalation-setup.agent +169 -0
- package/skills/agentforce-development/assets/components/flow-action.agent +66 -0
- package/skills/agentforce-development/assets/components/n-ary-conditions.agent +110 -0
- package/skills/agentforce-development/assets/components/topic-with-actions.agent +40 -0
- package/skills/agentforce-development/assets/deterministic-routing.agent +166 -0
- package/skills/agentforce-development/assets/escalation-pattern.agent +209 -0
- package/skills/agentforce-development/assets/flow-action-lookup.agent +115 -0
- package/skills/agentforce-development/assets/hub-and-spoke.agent +104 -0
- package/skills/agentforce-development/assets/invocable-apex-template.cls +187 -0
- package/skills/agentforce-development/assets/local-info-agent-annotated.agent +355 -0
- package/skills/agentforce-development/assets/metadata/basic-prompt-template.promptTemplate-meta.xml +109 -0
- package/skills/agentforce-development/assets/metadata/genai-function-apex.xml +92 -0
- package/skills/agentforce-development/assets/metadata/genai-function-flow.xml +57 -0
- package/skills/agentforce-development/assets/metadata/genai-plugin.xml +72 -0
- package/skills/agentforce-development/assets/metadata/http-callout-flow.flow-meta.xml +348 -0
- package/skills/agentforce-development/assets/metadata/record-grounded-prompt.promptTemplate-meta.xml +136 -0
- package/skills/agentforce-development/assets/minimal-starter.agent +42 -0
- package/skills/agentforce-development/assets/patterns/README.md +254 -0
- package/skills/agentforce-development/assets/patterns/action-callbacks.agent +178 -0
- package/skills/agentforce-development/assets/patterns/advanced-input-bindings.agent +141 -0
- package/skills/agentforce-development/assets/patterns/bidirectional-routing.agent +156 -0
- package/skills/agentforce-development/assets/patterns/critical-input-collection.agent +244 -0
- package/skills/agentforce-development/assets/patterns/delegation-routing.agent +89 -0
- package/skills/agentforce-development/assets/patterns/lifecycle-events.agent +127 -0
- package/skills/agentforce-development/assets/patterns/llm-controlled-actions.agent +184 -0
- package/skills/agentforce-development/assets/patterns/multi-step-workflow.agent +282 -0
- package/skills/agentforce-development/assets/patterns/open-gate-routing.agent +286 -0
- package/skills/agentforce-development/assets/patterns/procedural-instructions.agent +273 -0
- package/skills/agentforce-development/assets/patterns/prompt-template-action.agent +188 -0
- package/skills/agentforce-development/assets/patterns/system-instruction-overrides.agent +293 -0
- package/skills/agentforce-development/assets/prompt-rag-search.agent +131 -0
- package/skills/agentforce-development/assets/template-multi-topic.agent +160 -0
- package/skills/agentforce-development/assets/template-single-topic.agent +81 -0
- package/skills/agentforce-development/assets/verification-gate.agent +208 -0
- package/skills/agentforce-development/references/action-prompt-templates.md +164 -0
- package/skills/agentforce-development/references/actions-reference.md +592 -0
- package/skills/agentforce-development/references/agent-access-guide.md +72 -0
- package/skills/agentforce-development/references/agent-design-and-spec-creation.md +1010 -0
- package/skills/agentforce-development/references/agent-metadata-and-lifecycle.md +575 -0
- package/skills/agentforce-development/references/agent-script-core-language.md +1218 -0
- package/skills/agentforce-development/references/agent-topic-map-diagrams.md +323 -0
- package/skills/agentforce-development/references/agent-user-setup.md +526 -0
- package/skills/agentforce-development/references/agent-validation-and-debugging.md +803 -0
- package/skills/agentforce-development/references/known-issues.md +353 -0
- package/skills/agentforce-development/references/minimal-examples.md +67 -0
- package/skills/agentforce-development/references/production-gotchas.md +279 -0
- package/skills/agentforce-development/references/salesforce-cli-for-agents.md +393 -0
- package/skills/agentforce-development/references/version-history.md +23 -0
- package/skills/building-webapp-data-visualization/SKILL.md +72 -0
- package/skills/building-webapp-data-visualization/implementation/bar-line-chart.md +316 -0
- package/skills/building-webapp-data-visualization/implementation/dashboard-layout.md +189 -0
- package/skills/building-webapp-data-visualization/implementation/donut-chart.md +181 -0
- package/skills/building-webapp-data-visualization/implementation/stat-card.md +150 -0
- package/skills/building-webapp-react-components/SKILL.md +96 -0
- package/skills/building-webapp-react-components/implementation/component.md +78 -0
- package/skills/building-webapp-react-components/implementation/header-footer.md +132 -0
- package/skills/building-webapp-react-components/implementation/page.md +93 -0
- package/skills/configuring-webapp-csp-trusted-sites/SKILL.md +90 -0
- package/skills/configuring-webapp-csp-trusted-sites/implementation/metadata-format.md +281 -0
- package/skills/configuring-webapp-metadata/SKILL.md +158 -0
- package/skills/creating-webapp/SKILL.md +141 -0
- package/skills/deploying-webapp-to-salesforce/SKILL.md +229 -0
- package/skills/exploring-webapp-graphql-schema/SKILL.md +149 -0
- package/skills/fetching-webapp-rest-api/SKILL.md +167 -0
- package/skills/{salesforce-custom-application → generating-custom-application}/SKILL.md +2 -4
- package/skills/{salesforce-custom-field → generating-custom-field}/SKILL.md +1 -5
- package/skills/{salesforce-custom-lightning-type → generating-custom-lightning-type}/SKILL.md +36 -2
- package/skills/{salesforce-custom-object → generating-custom-object}/SKILL.md +1 -1
- package/skills/generating-custom-tab/SKILL.md +154 -0
- package/skills/generating-experience-lwr-site/SKILL.md +196 -0
- package/skills/generating-experience-lwr-site/docs/bootstrap-template-byo-lwr.md +224 -0
- package/skills/generating-experience-lwr-site/docs/configure-content-brandingSet.md +131 -0
- package/skills/generating-experience-lwr-site/docs/configure-content-route.md +232 -0
- package/skills/generating-experience-lwr-site/docs/configure-content-themeLayout.md +141 -0
- package/skills/generating-experience-lwr-site/docs/configure-content-view.md +233 -0
- package/skills/generating-experience-lwr-site/docs/configure-guest-sharing-rules.md +42 -0
- package/skills/generating-experience-lwr-site/docs/handle-component-and-region-ids.md +27 -0
- package/skills/generating-experience-lwr-site/docs/handle-ui-components.md +215 -0
- package/skills/generating-experience-react-site/SKILL.md +67 -0
- package/skills/generating-experience-react-site/docs/configure-metadata-custom-site.md +41 -0
- package/skills/generating-experience-react-site/docs/configure-metadata-digital-experience-bundle.md +17 -0
- package/skills/generating-experience-react-site/docs/configure-metadata-digital-experience-config.md +21 -0
- package/skills/generating-experience-react-site/docs/configure-metadata-digital-experience.md +38 -0
- package/skills/generating-experience-react-site/docs/configure-metadata-network.md +72 -0
- package/skills/{salesforce-flexipage → generating-flexipage}/SKILL.md +86 -9
- package/skills/{salesforce-flow → generating-flow}/SKILL.md +3 -3
- package/skills/generating-fragment/SKILL.md +117 -0
- package/skills/generating-lightning-app/SKILL.md +423 -0
- package/skills/{salesforce-list-view → generating-list-view}/SKILL.md +1 -1
- package/skills/generating-permission-set/SKILL.md +174 -0
- package/skills/{salesforce-validation-rule → generating-validation-rule}/SKILL.md +1 -1
- package/skills/generating-webapp-graphql-mutation-query/SKILL.md +258 -0
- package/skills/generating-webapp-graphql-read-query/SKILL.md +253 -0
- package/skills/implementing-webapp-file-upload/SKILL.md +396 -0
- package/skills/installing-webapp-features/SKILL.md +210 -0
- package/skills/managing-webapp-agentforce-conversation-client/SKILL.md +186 -0
- package/skills/managing-webapp-agentforce-conversation-client/references/constraints.md +134 -0
- package/skills/managing-webapp-agentforce-conversation-client/references/examples.md +132 -0
- package/skills/managing-webapp-agentforce-conversation-client/references/style-tokens.md +101 -0
- package/skills/managing-webapp-agentforce-conversation-client/references/troubleshooting.md +57 -0
- package/skills/switching-org/SKILL.md +28 -0
- package/skills/using-webapp-graphql/SKILL.md +324 -0
- package/skills/using-webapp-graphql/shared-schema.graphqls +1150 -0
- package/skills/apex-class/SKILL.md +0 -253
- package/skills/apex-class/examples/AccountDeduplicationBatch.cls +0 -148
- package/skills/apex-class/examples/AccountSelector.cls +0 -193
- package/skills/apex-class/examples/AccountService.cls +0 -201
- package/skills/apex-class/templates/abstract.cls +0 -128
- package/skills/apex-class/templates/batch.cls +0 -125
- package/skills/apex-class/templates/domain.cls +0 -102
- package/skills/apex-class/templates/dto.cls +0 -108
- package/skills/apex-class/templates/exception.cls +0 -51
- package/skills/apex-class/templates/interface.cls +0 -25
- package/skills/apex-class/templates/queueable.cls +0 -92
- package/skills/apex-class/templates/schedulable.cls +0 -75
- package/skills/apex-class/templates/selector.cls +0 -92
- package/skills/apex-class/templates/service.cls +0 -69
- package/skills/apex-class/templates/utility.cls +0 -97
- package/skills/apex-test-class/SKILL.md +0 -101
- package/skills/apex-test-class/references/assertion-patterns.md +0 -209
- package/skills/apex-test-class/references/async-testing.md +0 -276
- package/skills/apex-test-class/references/mocking-patterns.md +0 -219
- package/skills/apex-test-class/references/test-data-factory.md +0 -176
- package/skills/deployment-readiness-check/SKILL.md +0 -257
- package/skills/deployment-readiness-check/assets/deployment_checklist.md +0 -286
- package/skills/deployment-readiness-check/references/rollback_procedures.md +0 -308
- package/skills/deployment-readiness-check/scripts/check_metadata.sh +0 -207
- package/skills/salesforce-custom-tab/SKILL.md +0 -78
- package/skills/salesforce-experience-site/SKILL.md +0 -178
- package/skills/salesforce-fragment/SKILL.md +0 -42
- package/skills/salesforce-lightning-app-build/SKILL.md +0 -254
- package/skills/salesforce-web-app-creating-records/SKILL.md +0 -84
- package/skills/salesforce-web-app-feature/SKILL.md +0 -70
- package/skills/salesforce-web-app-list-and-create-records/SKILL.md +0 -36
- package/skills/salesforce-web-application/SKILL.md +0 -34
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
# Agent User Setup & Permission Model
|
|
2
|
+
Complete provisioning workflow for Einstein Agent Users and permission sets. Validated against ORM1, ORM2, AutomotiveSupport, and SalesforceProductAssistant agents.
|
|
3
|
+
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## License Requirement
|
|
7
|
+
PID_DigitalAgent (typically included with Agentforce licenses)
|
|
8
|
+
|
|
9
|
+
## Agent Type Decision Matrix
|
|
10
|
+
|
|
11
|
+
| Aspect | AgentforceServiceAgent | AgentforceEmployeeAgent |
|
|
12
|
+
|--------|------------------------|-------------------------|
|
|
13
|
+
| **Use Case** | Customer-facing, external users | Internal employees |
|
|
14
|
+
| **Runs As** | Dedicated Einstein Agent User | Logged-in user |
|
|
15
|
+
| **Einstein Agent User?** | Required | Not needed |
|
|
16
|
+
| **System PS (`AgentforceServiceAgentUser`)** | Required | Not needed |
|
|
17
|
+
| **Custom PS (`{AgentName}_Access`)** | Assigned to agent user | Assigned to employees |
|
|
18
|
+
| **`default_agent_user` in config** | Required | Omit entirely |
|
|
19
|
+
| **Respects Sharing Rules** | No (consistent permissions) | Yes (user's data access) |
|
|
20
|
+
|
|
21
|
+
**How to check agent type**: Look at the `agent_type` field in the `config:` block of your `.agent` file, or query: `sf data query --query "SELECT DeveloperName, Type FROM BotDefinition WHERE DeveloperName = 'AgentName'" -o TARGET_ORG --json`
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## CLI Fast Track: Complete Workflow
|
|
26
|
+
|
|
27
|
+
For CLI-first workflow (tested: ~8 minutes total):
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Step 1: Query existing Einstein Agent Users (30 seconds)
|
|
31
|
+
sf data query \
|
|
32
|
+
--query "SELECT Id, Username, IsActive FROM User WHERE Profile.Name = 'Einstein Agent User' AND IsActive = true" \
|
|
33
|
+
-o TARGET_ORG --json
|
|
34
|
+
|
|
35
|
+
# Step 2: Create Einstein Agent User (2 minutes)
|
|
36
|
+
# Get Profile ID
|
|
37
|
+
PROFILE_ID=$(sf data query \
|
|
38
|
+
--query "SELECT Id FROM Profile WHERE Name = 'Einstein Agent User'" \
|
|
39
|
+
-o TARGET_ORG --json | jq -r '.result.records[0].Id')
|
|
40
|
+
|
|
41
|
+
# For Production/Sandbox (non-scratch org):
|
|
42
|
+
sf data create record --sobject User --values \
|
|
43
|
+
"Username=<agent_name>_user@<orgId>.ext \
|
|
44
|
+
LastName=<AgentName> \
|
|
45
|
+
Email=admin@example.com \
|
|
46
|
+
Alias=<alias> \
|
|
47
|
+
TimeZoneSidKey=America/Los_Angeles \
|
|
48
|
+
LocaleSidKey=en_US \
|
|
49
|
+
EmailEncodingKey=UTF-8 \
|
|
50
|
+
ProfileId=${PROFILE_ID} \
|
|
51
|
+
LanguageLocaleKey=en_US" \
|
|
52
|
+
-o TARGET_ORG --json
|
|
53
|
+
|
|
54
|
+
# For Scratch Orgs (use user definition file):
|
|
55
|
+
# sf org create user --definition-file config/einstein-agent-user.json -o TARGET_ORG
|
|
56
|
+
|
|
57
|
+
# Step 3: Assign System Permission Set (1 minute)
|
|
58
|
+
sf org assign permset \
|
|
59
|
+
--name AgentforceServiceAgentUser \
|
|
60
|
+
--on-behalf-of <agent_name>_user@<orgId>.ext \
|
|
61
|
+
-o TARGET_ORG --json
|
|
62
|
+
|
|
63
|
+
# Step 4: Deploy Custom Permission Set (3 minutes)
|
|
64
|
+
# (Create the .permissionset-meta.xml file first - see Section 3.2 template)
|
|
65
|
+
sf project deploy start \
|
|
66
|
+
--metadata PermissionSet:<AgentName>_Access \
|
|
67
|
+
-o TARGET_ORG --json
|
|
68
|
+
|
|
69
|
+
# Assign custom PS
|
|
70
|
+
sf org assign permset \
|
|
71
|
+
--name <AgentName>_Access \
|
|
72
|
+
--on-behalf-of <agent_name>_user@<orgId>.ext \
|
|
73
|
+
-o TARGET_ORG --json
|
|
74
|
+
|
|
75
|
+
# Step 5: Verify All Permissions (1 minute)
|
|
76
|
+
sf data query \
|
|
77
|
+
--query "SELECT PermissionSet.Name, PermissionSet.Label FROM PermissionSetAssignment WHERE Assignee.Username = '<agent_name>_user@<orgId>.ext' ORDER BY PermissionSet.Name" \
|
|
78
|
+
-o TARGET_ORG --json
|
|
79
|
+
|
|
80
|
+
# Expected: AgentforceServiceAgentUser + <AgentName>_Access
|
|
81
|
+
|
|
82
|
+
# Step 6: Deploy Agent Bundle (unpublished metadata)
|
|
83
|
+
sf project deploy start \
|
|
84
|
+
--source-dir force-app/main/default/aiAuthoringBundles/<AgentName> \
|
|
85
|
+
-o TARGET_ORG --json
|
|
86
|
+
|
|
87
|
+
# Step 7: Test BEFORE Publishing (recommended)
|
|
88
|
+
sf agent preview start \
|
|
89
|
+
--api-name <AgentName> \
|
|
90
|
+
-o TARGET_ORG --json
|
|
91
|
+
# Test all topics and actions to verify permissions
|
|
92
|
+
|
|
93
|
+
# Step 8: Publish & Activate (only after testing passes)
|
|
94
|
+
sf agent publish authoring-bundle \
|
|
95
|
+
--api-name <AgentName> \
|
|
96
|
+
-o TARGET_ORG --json
|
|
97
|
+
|
|
98
|
+
sf agent activate \
|
|
99
|
+
--api-name <AgentName> \
|
|
100
|
+
-o TARGET_ORG
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Critical notes:
|
|
104
|
+
- For **scratch orgs**, use `sf org create user --definition-file`
|
|
105
|
+
- For **production/sandbox**, use `sf data create record` as shown above
|
|
106
|
+
- `sf org create user` only works in scratch orgs — it will fail in production/sandbox
|
|
107
|
+
- Always test with preview BEFORE publishing to avoid version management overhead
|
|
108
|
+
- Assign `AgentforceServiceAgentUser` BEFORE publishing to prevent "Internal Error"
|
|
109
|
+
- Publishing does NOT activate — you must run `sf agent activate` separately
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Service Agent Setup (6 Steps)
|
|
114
|
+
|
|
115
|
+
### Step 1: Create Einstein Agent User
|
|
116
|
+
|
|
117
|
+
Service agents need a dedicated service account with consistent permissions.
|
|
118
|
+
|
|
119
|
+
**Get Org ID first** (needed for username format):
|
|
120
|
+
```bash
|
|
121
|
+
sf org display -o TARGET_ORG --json | jq -r '.result.id'
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Query existing Einstein Agent Users** (skip creation if one exists):
|
|
125
|
+
```bash
|
|
126
|
+
sf data query --query "SELECT Id, Username, IsActive FROM User WHERE Profile.Name = 'Einstein Agent User' AND IsActive = true" -o TARGET_ORG --json
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Create the user** (if none exists):
|
|
130
|
+
|
|
131
|
+
1. Get the Einstein Agent User profile ID:
|
|
132
|
+
```bash
|
|
133
|
+
sf data query --query "SELECT Id FROM Profile WHERE Name = 'Einstein Agent User'" -o TARGET_ORG --json
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
2. Create a user definition file (`config/einstein-agent-user.json`):
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"Username": "{agent_name}_agent@{orgId}.ext",
|
|
140
|
+
"LastName": "{AgentName} Agent",
|
|
141
|
+
"Email": "placeholder@example.com",
|
|
142
|
+
"Alias": "agntuser",
|
|
143
|
+
"ProfileId": "<profile-id-from-step-1>",
|
|
144
|
+
"TimeZoneSidKey": "America/Los_Angeles",
|
|
145
|
+
"LocaleSidKey": "en_US",
|
|
146
|
+
"EmailEncodingKey": "UTF-8",
|
|
147
|
+
"LanguageLocaleKey": "en_US",
|
|
148
|
+
"UserPermissionsKnowledgeUser": true
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
3. Create the user:
|
|
153
|
+
|
|
154
|
+
**Option A: Scratch Org (Definition File)**
|
|
155
|
+
```bash
|
|
156
|
+
sf org create user \
|
|
157
|
+
--definition-file config/einstein-agent-user.json \
|
|
158
|
+
-o TARGET_ORG
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**Option B: Production/Sandbox (Direct Record Creation)**
|
|
162
|
+
```bash
|
|
163
|
+
# Get Profile ID first
|
|
164
|
+
PROFILE_ID=$(sf data query \
|
|
165
|
+
--query "SELECT Id FROM Profile WHERE Name = 'Einstein Agent User'" \
|
|
166
|
+
-o TARGET_ORG --json | jq -r '.result.records[0].Id')
|
|
167
|
+
|
|
168
|
+
# Create user directly
|
|
169
|
+
sf data create record --sobject User --values \
|
|
170
|
+
"Username='{agent_name}_agent@{orgId}.ext' LastName='{AgentName} Agent' Email='placeholder@example.com' Alias='agntuser' ProfileId='${PROFILE_ID}' TimeZoneSidKey='America/Los_Angeles' LocaleSidKey='en_US' EmailEncodingKey='UTF-8' LanguageLocaleKey='en_US'" \
|
|
171
|
+
-o TARGET_ORG --json
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Note**: `sf org create user` only works in scratch orgs. For production/sandbox, use `sf data create record`. Attempting `sf org create user` in a non-scratch org fails with an authorization error.
|
|
175
|
+
|
|
176
|
+
4. Verify creation:
|
|
177
|
+
```bash
|
|
178
|
+
sf data query --query "SELECT Id, Username, IsActive FROM User WHERE Username = '{agent_name}_agent@{orgId}.ext'" -o TARGET_ORG --json
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Username format**: `{agent_name}_agent@{orgId}.ext` (production) or `{agent_name}.{suffix}@{orgfarm}.salesforce.com` (dev/scratch). Always query the target org to confirm the exact format.
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
### Step 2: Assign System Permission Set (`AgentforceServiceAgentUser`)
|
|
186
|
+
|
|
187
|
+
Critical: Must be assigned BEFORE publishing the agent. Without it, publish fails with "Internal Error".
|
|
188
|
+
|
|
189
|
+
Via Setup UI:
|
|
190
|
+
1. Setup > Permission Sets > search "AgentforceServiceAgentUser"
|
|
191
|
+
2. Manage Assignments > Add Assignments > select the Einstein Agent User > Save
|
|
192
|
+
|
|
193
|
+
Via CLI:
|
|
194
|
+
```bash
|
|
195
|
+
sf org assign permset --name AgentforceServiceAgentUser --on-behalf-of "{agent_name}_agent@{orgId}.ext" -o TARGET_ORG --json
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Verify assignment:
|
|
199
|
+
```bash
|
|
200
|
+
sf data query --query "SELECT Id, PermissionSet.Name FROM PermissionSetAssignment WHERE Assignee.Username = '{agent_name}_agent@{orgId}.ext' AND PermissionSet.Name = 'AgentforceServiceAgentUser'" -o TARGET_ORG --json
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
### Step 3: Create Custom Permission Set for Apex Classes
|
|
206
|
+
|
|
207
|
+
The custom PS grants the agent user permission to execute your Apex invocable actions.
|
|
208
|
+
|
|
209
|
+
Naming convention: `{AgentName}_Access` (e.g., `AutomotiveSupport_Access`)
|
|
210
|
+
|
|
211
|
+
File: `force-app/main/default/permissionsets/{AgentName}_Access.permissionset-meta.xml`
|
|
212
|
+
|
|
213
|
+
```xml
|
|
214
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
215
|
+
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
|
|
216
|
+
<description>Grants access to {AgentName} Agent Apex classes</description>
|
|
217
|
+
<hasActivationRequired>false</hasActivationRequired>
|
|
218
|
+
<label>{AgentName} Access</label>
|
|
219
|
+
|
|
220
|
+
<!-- Add one entry per Apex class the agent calls -->
|
|
221
|
+
<classAccesses>
|
|
222
|
+
<apexClass>YourApexClassName</apexClass>
|
|
223
|
+
<enabled>true</enabled>
|
|
224
|
+
</classAccesses>
|
|
225
|
+
<!-- Repeat for ALL Apex classes referenced via apex:// in agent script -->
|
|
226
|
+
</PermissionSet>
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Key rule: Include EVERY Apex class referenced via `apex://` in your agent script. Missing even one causes "invocable action does not exist" at runtime.
|
|
230
|
+
|
|
231
|
+
Deploy the permission set:
|
|
232
|
+
```bash
|
|
233
|
+
sf project deploy start --source-dir force-app/main/default/permissionsets/{AgentName}_Access.permissionset-meta.xml -o TARGET_ORG --json
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
### Step 4: Assign Custom Permission Set to Agent User
|
|
239
|
+
|
|
240
|
+
Via CLI:
|
|
241
|
+
```bash
|
|
242
|
+
sf org assign permset --name {AgentName}_Access --on-behalf-of "{agent_name}_agent@{orgId}.ext" -o TARGET_ORG --json
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Verify both permission sets are assigned:
|
|
246
|
+
```bash
|
|
247
|
+
sf data query --query "SELECT PermissionSet.Name FROM PermissionSetAssignment WHERE Assignee.Username = '{agent_name}_agent@{orgId}.ext'" -o TARGET_ORG --json
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Expected output includes both:
|
|
251
|
+
- `AgentforceServiceAgentUser` (system)
|
|
252
|
+
- `{AgentName}_Access` (custom)
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
### Step 5: Set `default_agent_user` in Agent Config
|
|
257
|
+
|
|
258
|
+
In your `.agent` file:
|
|
259
|
+
```yaml
|
|
260
|
+
config:
|
|
261
|
+
developer_name: "AgentName"
|
|
262
|
+
agent_description: "Your agent description"
|
|
263
|
+
agent_type: "AgentforceServiceAgent"
|
|
264
|
+
default_agent_user: "{agent_name}_agent@{orgId}.ext" # Service agents ONLY
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
### Step 6: Deploy, Test, Publish & Activate
|
|
270
|
+
|
|
271
|
+
**Validated workflow pattern**: Deploy as unpublished metadata, test with preview, then publish only when tests pass. This avoids version management overhead during iteration.
|
|
272
|
+
|
|
273
|
+
#### 6.1: Deploy Agent Bundle (Unpublished)
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
sf project deploy start \
|
|
277
|
+
--source-dir force-app/main/default/aiAuthoringBundles/<AgentName> \
|
|
278
|
+
-o TARGET_ORG --json
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
This deploys the agent as **unpublished metadata** — you can edit freely without version management.
|
|
282
|
+
|
|
283
|
+
#### 6.2: Test with Preview (Before Publishing)
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
sf agent preview start \
|
|
287
|
+
--api-name <AgentName> \
|
|
288
|
+
-o TARGET_ORG --json
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
What to test:
|
|
292
|
+
1. All topics trigger correctly
|
|
293
|
+
2. All Apex actions execute without "Insufficient Privileges" errors
|
|
294
|
+
3. Agent responds with expected data
|
|
295
|
+
4. No compilation errors
|
|
296
|
+
|
|
297
|
+
If testing reveals problems, edit your agent script or Apex classes, redeploy, and test again — no publish required.
|
|
298
|
+
|
|
299
|
+
**⚠️ `WITH USER_MODE` Object Permissions:** Apex using `WITH USER_MODE` requires the Einstein Agent User to have read access on queried objects. Class-level access alone is not enough. Missing object permissions fail silently — 0 rows, no error. If live preview returns empty but simulated works, check Setup > Profiles > Einstein Agent User > Object Permissions. Fix by adding `<objectPermissions>` to your custom PS:
|
|
300
|
+
|
|
301
|
+
```xml
|
|
302
|
+
<objectPermissions>
|
|
303
|
+
<allowRead>true</allowRead>
|
|
304
|
+
<object>Vehicle__c</object>
|
|
305
|
+
</objectPermissions>
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
See [preview-test-loop.md](preview-test-loop.md) for the complete smoke test workflow.
|
|
309
|
+
|
|
310
|
+
#### 6.3: Publish Agent
|
|
311
|
+
|
|
312
|
+
Only publish after all tests pass.
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
sf agent publish authoring-bundle \
|
|
316
|
+
--api-name <AgentName> \
|
|
317
|
+
-o TARGET_ORG --json
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
**Publishing does NOT activate.** The new BotVersion is created as `Inactive`. You must explicitly activate.
|
|
321
|
+
|
|
322
|
+
#### 6.4: Activate Agent
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
sf agent activate \
|
|
326
|
+
--api-name <AgentName> \
|
|
327
|
+
-o TARGET_ORG
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
`sf agent activate` does NOT support `--json`. It prints a plain-text confirmation.
|
|
331
|
+
|
|
332
|
+
#### 6.5: Verify Activation
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
sf data query \
|
|
336
|
+
--query "SELECT Id, DeveloperName, Status FROM BotVersion WHERE BotDefinition.DeveloperName = '<AgentName>' ORDER BY CreatedDate DESC LIMIT 1" \
|
|
337
|
+
-o TARGET_ORG --json
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Expected: `Status = 'Active'`
|
|
341
|
+
|
|
342
|
+
After publish: Any further changes require version management. Test thoroughly before publishing.
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
## Employee Agent Setup
|
|
347
|
+
|
|
348
|
+
Employee agents run as the logged-in user. The permission model is simpler.
|
|
349
|
+
|
|
350
|
+
### What You DO NOT Need
|
|
351
|
+
|
|
352
|
+
- No Einstein Agent User creation
|
|
353
|
+
- No `AgentforceServiceAgentUser` system permission set
|
|
354
|
+
- No `default_agent_user` in agent config
|
|
355
|
+
|
|
356
|
+
### What You DO Need
|
|
357
|
+
|
|
358
|
+
Custom permission set(s) assigned to **employees** who will use the agent.
|
|
359
|
+
|
|
360
|
+
### Step 1: Create Custom Permission Set
|
|
361
|
+
|
|
362
|
+
Same XML template as Step 3 above. Include `<classAccesses>` for all Apex classes the agent calls.
|
|
363
|
+
|
|
364
|
+
### Step 2: Assign to Employees
|
|
365
|
+
|
|
366
|
+
Assign the custom PS to employees (not to a service account):
|
|
367
|
+
|
|
368
|
+
```bash
|
|
369
|
+
sf org assign permset --name {AgentName}_Access --on-behalf-of "employee@company.com" -o TARGET_ORG --json
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
Or use Permission Set Groups for role-based access.
|
|
373
|
+
|
|
374
|
+
### Step 3: Configure Agent Script (No `default_agent_user`)
|
|
375
|
+
|
|
376
|
+
```yaml
|
|
377
|
+
config:
|
|
378
|
+
developer_name: "Employee_Agent"
|
|
379
|
+
agent_description: "Internal employee assistant"
|
|
380
|
+
agent_type: "AgentforceEmployeeAgent"
|
|
381
|
+
# NO default_agent_user — agent runs as logged-in user
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
### Step 4: Publish
|
|
385
|
+
|
|
386
|
+
```bash
|
|
387
|
+
sf agent publish authoring-bundle --api-name Employee_Agent -o TARGET_ORG --json
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## Auto-Generated Permission Set Warning
|
|
393
|
+
|
|
394
|
+
Salesforce auto-generates `NextGen_{AgentName}_Permissions` when an agent is published. Do NOT rely on this PS — it is often incomplete.
|
|
395
|
+
|
|
396
|
+
### ORM1 Testing Example
|
|
397
|
+
- Agent script referenced 4 Apex classes: `OrderManagementVerification`, `FraudRiskCalculator`, `OrderLookupService`, `ShipmentTracker`
|
|
398
|
+
- Auto-generated `NextGen_ORM1_Permissions` only included 3 classes (missing `ShipmentTracker`)
|
|
399
|
+
- Runtime error: "invocable action track_delivery does not exist"
|
|
400
|
+
- Fix: Created custom `ORM1_Access` with all 4 classes — no errors
|
|
401
|
+
|
|
402
|
+
Best practice: Always create your own custom `{AgentName}_Access` PS with explicit `<classAccesses>` for every Apex class. Ignore the auto-generated PS.
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
## End-to-End Verification Checklist
|
|
407
|
+
|
|
408
|
+
Run this combined query to verify all setup steps for a Service Agent:
|
|
409
|
+
|
|
410
|
+
```bash
|
|
411
|
+
# 1. Einstein Agent User exists and is active
|
|
412
|
+
sf data query --query "SELECT Id, Username, IsActive, Profile.Name FROM User WHERE Username = '{agent_name}_agent@{orgId}.ext'" -o TARGET_ORG --json
|
|
413
|
+
|
|
414
|
+
# 2. System PS assigned
|
|
415
|
+
sf data query --query "SELECT PermissionSet.Name FROM PermissionSetAssignment WHERE Assignee.Username = '{agent_name}_agent@{orgId}.ext' AND PermissionSet.Name = 'AgentforceServiceAgentUser'" -o TARGET_ORG --json
|
|
416
|
+
|
|
417
|
+
# 3. Custom PS assigned
|
|
418
|
+
sf data query --query "SELECT PermissionSet.Name FROM PermissionSetAssignment WHERE Assignee.Username = '{agent_name}_agent@{orgId}.ext' AND PermissionSet.Name = '{AgentName}_Access'" -o TARGET_ORG --json
|
|
419
|
+
|
|
420
|
+
# 4. All permission sets for user (combined view)
|
|
421
|
+
sf data query --query "SELECT PermissionSet.Name, PermissionSet.Label FROM PermissionSetAssignment WHERE Assignee.Username = '{agent_name}_agent@{orgId}.ext'" -o TARGET_ORG --json
|
|
422
|
+
|
|
423
|
+
# 5. Agent config has default_agent_user
|
|
424
|
+
# Check your .agent file's config: block
|
|
425
|
+
|
|
426
|
+
# 6. Agent publishes successfully
|
|
427
|
+
sf agent publish authoring-bundle --api-name AgentName -o TARGET_ORG --json
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
Checklist:
|
|
431
|
+
- [ ] Einstein Agent User created and active (`IsActive = true`)
|
|
432
|
+
- [ ] Profile is "Einstein Agent User" (or "Minimum Access - Salesforce")
|
|
433
|
+
- [ ] `AgentforceServiceAgentUser` system PS assigned
|
|
434
|
+
- [ ] Custom `{AgentName}_Access` PS deployed with ALL Apex classes
|
|
435
|
+
- [ ] Custom PS assigned to the agent user
|
|
436
|
+
- [ ] `default_agent_user` set in `.agent` config block
|
|
437
|
+
- [ ] Agent tested with preview before publishing
|
|
438
|
+
- [ ] Agent publishes without error
|
|
439
|
+
- [ ] Agent activated (publish does NOT auto-activate)
|
|
440
|
+
|
|
441
|
+
---
|
|
442
|
+
|
|
443
|
+
## Common Pitfalls (Validated)
|
|
444
|
+
|
|
445
|
+
### 1. "Internal Error" on First Publish
|
|
446
|
+
- **Cause:** Publishing before assigning `AgentforceServiceAgentUser`
|
|
447
|
+
- **Prevention:** Assign system PS (Step 2) before publishing (Step 6.3)
|
|
448
|
+
- **Result:** First-time publish success (no retries needed)
|
|
449
|
+
|
|
450
|
+
### 2. "Insufficient Privileges" on Apex Actions
|
|
451
|
+
- **Cause:** Missing `<classAccesses>` in custom permission set
|
|
452
|
+
- **Prevention:** Custom PS template includes all Apex classes (Step 3)
|
|
453
|
+
- **Result:** All actions execute without permission errors
|
|
454
|
+
|
|
455
|
+
### 3. Testing After Publishing
|
|
456
|
+
- **Cause:** Publishing before testing, then needing version management for fixes
|
|
457
|
+
- **Prevention:** Deploy → Test → Publish workflow (Step 6.1-6.3)
|
|
458
|
+
- **Result:** No version management overhead during development
|
|
459
|
+
|
|
460
|
+
### 4. Wrong User Creation Command
|
|
461
|
+
- **Cause:** Using `sf org create user` in non-scratch orgs
|
|
462
|
+
- **Prevention:** Step 1 provides correct commands for each org type (Option A vs B)
|
|
463
|
+
- **Result:** User created successfully without authorization errors
|
|
464
|
+
|
|
465
|
+
### 5. Auto-Generated Permission Set Gaps
|
|
466
|
+
- **Cause:** Relying on `NextGen_{AgentName}_Permissions` (often incomplete)
|
|
467
|
+
- **Prevention:** Custom PS with explicit Apex access (Step 3)
|
|
468
|
+
- **Result:** All Apex classes accessible from the start
|
|
469
|
+
|
|
470
|
+
### 6. Forgot to Activate After Publish
|
|
471
|
+
- **Cause:** Assuming publish automatically activates
|
|
472
|
+
- **Prevention:** Step 6 splits publish and activate into separate steps with verification
|
|
473
|
+
- **Result:** Agent is both published AND activated
|
|
474
|
+
|
|
475
|
+
---
|
|
476
|
+
|
|
477
|
+
## Troubleshooting
|
|
478
|
+
|
|
479
|
+
| Error | Cause | Fix |
|
|
480
|
+
|-------|-------|-----|
|
|
481
|
+
| "Internal Error" on publish | `AgentforceServiceAgentUser` PS not assigned to Einstein Agent User | Assign system PS (Step 2), wait 2-3 min, retry publish |
|
|
482
|
+
| "Insufficient Privileges" at runtime | Custom PS missing or incomplete `<classAccesses>` | Verify custom PS includes ALL Apex classes, redeploy + reassign |
|
|
483
|
+
| "invocable action does not exist" | Apex class not in custom PS (auto-generated PS incomplete) | Create custom `{AgentName}_Access` with all `<classAccesses>` (Step 3) |
|
|
484
|
+
| "Invalid default_agent_user" | Username typo or user not active | Query Einstein Agent Users, verify exact username + `IsActive = true` |
|
|
485
|
+
| Agent runs but returns wrong data | Employee agent using wrong user context | Verify `agent_type` — Service agents use dedicated user, Employee agents use logged-in user |
|
|
486
|
+
| `sf org create user` fails | Used in production/sandbox org | Use `sf data create record` instead (Step 1, Option B) |
|
|
487
|
+
|
|
488
|
+
---
|
|
489
|
+
|
|
490
|
+
## Permission Set XML Template (Complete Example)
|
|
491
|
+
|
|
492
|
+
**AutomotiveSupport agent** (5 Apex classes):
|
|
493
|
+
|
|
494
|
+
```xml
|
|
495
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
496
|
+
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
|
|
497
|
+
<description>Grants access to Automotive Support Agent Apex classes</description>
|
|
498
|
+
<hasActivationRequired>false</hasActivationRequired>
|
|
499
|
+
<label>Automotive Support Access</label>
|
|
500
|
+
|
|
501
|
+
<classAccesses>
|
|
502
|
+
<apexClass>VehicleLookupService</apexClass>
|
|
503
|
+
<enabled>true</enabled>
|
|
504
|
+
</classAccesses>
|
|
505
|
+
<classAccesses>
|
|
506
|
+
<apexClass>ErrorCodeDiagnosticsService</apexClass>
|
|
507
|
+
<enabled>true</enabled>
|
|
508
|
+
</classAccesses>
|
|
509
|
+
<classAccesses>
|
|
510
|
+
<apexClass>CheckEngineDiagnosticsService</apexClass>
|
|
511
|
+
<enabled>true</enabled>
|
|
512
|
+
</classAccesses>
|
|
513
|
+
<classAccesses>
|
|
514
|
+
<apexClass>BehaviorAnalysisService</apexClass>
|
|
515
|
+
<enabled>true</enabled>
|
|
516
|
+
</classAccesses>
|
|
517
|
+
<classAccesses>
|
|
518
|
+
<apexClass>ServiceSchedulerService</apexClass>
|
|
519
|
+
<enabled>true</enabled>
|
|
520
|
+
</classAccesses>
|
|
521
|
+
</PermissionSet>
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
---
|
|
525
|
+
|
|
526
|
+
*Validated against: ORM1, ORM2, AutomotiveSupport, SalesforceProductAssistant agents. Last validated: 2026-03-07.*
|