@salesforce/afv-skills 1.31.0 → 1.32.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.
Files changed (98) hide show
  1. package/package.json +1 -1
  2. package/skills/agentforce-bot-upgrade/SKILL.md +217 -0
  3. package/skills/agentforce-bot-upgrade/references/extraction-blueprint.md +242 -0
  4. package/skills/agentforce-bot-upgrade/references/generate-agent-spec.md +128 -0
  5. package/skills/agentforce-bot-upgrade/references/handoff-output-format.md +208 -0
  6. package/skills/agentforce-bot-upgrade/references/input-contract.md +101 -0
  7. package/skills/agentforce-bot-upgrade/references/mapping-rules.md +113 -0
  8. package/skills/agentforce-bot-upgrade/references/planner-workflow-reference.md +78 -0
  9. package/skills/agentforce-bot-upgrade/references/post-conversion-enhancements-reference.md +67 -0
  10. package/skills/agentforce-bot-upgrade/references/quality-checklist.md +33 -0
  11. package/skills/agentforce-bot-upgrade/references/sf-cli-bot-reference.md +116 -0
  12. package/skills/dx-devops-work-item-manage/SKILL.md +270 -0
  13. package/skills/dx-devops-work-item-manage/examples/common-workflows.md +479 -0
  14. package/skills/dx-devops-work-item-manage/references/cli-commands.md +476 -0
  15. package/skills/dx-org-manage/SKILL.md +8 -5
  16. package/skills/dx-org-trial-expiration-check/SKILL.md +239 -0
  17. package/skills/dx-org-trial-expiration-check/scripts/check_expiration.sh +588 -0
  18. package/skills/experience-ui-bundle-app-coordinate/SKILL.md +12 -9
  19. package/skills/experience-ui-bundle-custom-app-generate/SKILL.md +29 -5
  20. package/skills/experience-ui-bundle-custom-app-generate/references/configure-metadata-custom-application.md +1 -1
  21. package/skills/experience-ui-bundle-custom-app-generate/scripts/resolve-uibundle-path.sh +30 -0
  22. package/skills/experience-ui-bundle-features-generate/SKILL.md +86 -11
  23. package/skills/experience-ui-bundle-features-generate/references/conflict-resolution-schema.json +20 -0
  24. package/skills/experience-ui-bundle-features-generate/scripts/verify-react-bundle.sh +14 -0
  25. package/skills/experience-ui-bundle-frontend-generate/SKILL.md +6 -1
  26. package/skills/experience-ui-bundle-frontend-generate/references/component.md +34 -1
  27. package/skills/experience-ui-bundle-frontend-generate/references/page.md +1 -1
  28. package/skills/experience-ui-bundle-project-generate/SKILL.md +111 -0
  29. package/skills/experience-ui-bundle-project-generate/scripts/flatten-project.mjs +33 -0
  30. package/skills/platform-custom-lightning-type-generate/SKILL.md +9 -14
  31. package/skills/platform-custom-lightning-type-generate/references/widget-rendition.md +27 -111
  32. package/skills/platform-lightning-type-widget-coordinate/SKILL.md +214 -0
  33. package/skills/platform-lightning-type-widget-coordinate/examples/existing-lightning-type-with-widget-prompt.md +80 -0
  34. package/skills/platform-lightning-type-widget-coordinate/examples/new-lightning-type-with-widget-prompt.md +75 -0
  35. package/skills/platform-lightning-type-widget-coordinate/references/build-plan-format.md +67 -0
  36. package/skills/platform-lightning-type-widget-coordinate/references/lightning-type-discovery.md +124 -0
  37. package/skills/platform-lightning-type-widget-coordinate/references/validation-gates.md +130 -0
  38. package/skills/platform-sharing-owd-configure/SKILL.md +142 -0
  39. package/skills/platform-sharing-owd-configure/examples/get_owd_output.md +38 -0
  40. package/skills/platform-sharing-owd-configure/examples/update_owd_output.md +44 -0
  41. package/skills/platform-sharing-owd-configure/references/access_levels.md +49 -0
  42. package/skills/platform-sharing-owd-configure/references/metadata_api_approach.md +69 -0
  43. package/skills/platform-sharing-rules-generate/SKILL.md +89 -19
  44. package/skills/platform-sharing-rules-generate/examples/test-cases.md +381 -0
  45. package/skills/platform-widget-generate/SKILL.md +241 -0
  46. package/skills/platform-widget-generate/examples/conditional.json +73 -0
  47. package/skills/platform-widget-generate/examples/list-with-foreach.json +66 -0
  48. package/skills/platform-widget-generate/examples/single-object.json +64 -0
  49. package/skills/platform-widget-generate/references/schema-from-lightning-type.md +76 -0
  50. package/skills/platform-widget-generate/references/widget-bundle-layout.md +116 -0
  51. package/skills/platform-widget-generate/references/widget-meta-directives.md +130 -0
  52. package/skills/sales-agentforce-pipeline-management-configure/SKILL.md +268 -0
  53. package/skills/sales-agentforce-pipeline-management-configure/assets/field-completion-template.genAiPromptTemplate-meta.xml +141 -0
  54. package/skills/sales-agentforce-pipeline-management-configure/assets/pipeline_management_flow.flow-meta.xml +548 -0
  55. package/skills/sales-agentforce-pipeline-management-configure/assets/sales_management_agent.agent +2938 -0
  56. package/skills/sales-agentforce-pipeline-management-configure/assets/sales_management_agent.bundle-meta.xml +4 -0
  57. package/skills/sales-agentforce-pipeline-management-configure/assets/sfdx-project.json +12 -0
  58. package/skills/sales-agentforce-pipeline-management-configure/assets/stage-descriptions/bant.txt +11 -0
  59. package/skills/sales-agentforce-pipeline-management-configure/assets/stage-descriptions/meddic.txt +11 -0
  60. package/skills/sales-agentforce-pipeline-management-configure/assets/stage-descriptions/spiced.txt +11 -0
  61. package/skills/sales-agentforce-pipeline-management-configure/examples/custom-prompt-instructions.md +317 -0
  62. package/skills/sales-agentforce-pipeline-management-configure/references/admin-communication.md +355 -0
  63. package/skills/sales-agentforce-pipeline-management-configure/references/agent-creation.md +383 -0
  64. package/skills/sales-agentforce-pipeline-management-configure/references/auth-and-cli.md +146 -0
  65. package/skills/sales-agentforce-pipeline-management-configure/references/automation-matrix.md +23 -0
  66. package/skills/sales-agentforce-pipeline-management-configure/references/autonomous-updates.md +215 -0
  67. package/skills/sales-agentforce-pipeline-management-configure/references/canonical-agent-path.md +75 -0
  68. package/skills/sales-agentforce-pipeline-management-configure/references/data-sources.md +155 -0
  69. package/skills/sales-agentforce-pipeline-management-configure/references/field-completion-prompt-template.md +120 -0
  70. package/skills/sales-agentforce-pipeline-management-configure/references/field-completion-prompts.md +149 -0
  71. package/skills/sales-agentforce-pipeline-management-configure/references/flags.md +13 -0
  72. package/skills/sales-agentforce-pipeline-management-configure/references/flow-clone-from-template.md +447 -0
  73. package/skills/sales-agentforce-pipeline-management-configure/references/metadata-inventory.md +330 -0
  74. package/skills/sales-agentforce-pipeline-management-configure/references/opportunity-stages.md +246 -0
  75. package/skills/sales-agentforce-pipeline-management-configure/references/repair-diagnostics.md +265 -0
  76. package/skills/sales-agentforce-pipeline-management-configure/references/setup-order.md +263 -0
  77. package/skills/sales-agentforce-pipeline-management-configure/references/soap-api-enablement.md +528 -0
  78. package/skills/sales-agentforce-pipeline-management-configure/scripts/CHANGES.md +180 -0
  79. package/skills/sales-agentforce-pipeline-management-configure/scripts/README.md +56 -0
  80. package/skills/sales-agentforce-pipeline-management-configure/scripts/add-field-suggestion.sh +679 -0
  81. package/skills/sales-agentforce-pipeline-management-configure/scripts/create-agent.sh +302 -0
  82. package/skills/sales-agentforce-pipeline-management-configure/scripts/create-flow.sh +250 -0
  83. package/skills/sales-agentforce-pipeline-management-configure/scripts/define-agent-access.sh +430 -0
  84. package/skills/sales-agentforce-pipeline-management-configure/scripts/deploy-settings.sh +77 -0
  85. package/skills/sales-agentforce-pipeline-management-configure/scripts/enable-deal-agent.sh +241 -0
  86. package/skills/sales-agentforce-pipeline-management-configure/scripts/enable-prerequisites.sh +538 -0
  87. package/skills/sales-agentforce-pipeline-management-configure/scripts/flow-debug-and-verify.sh +385 -0
  88. package/skills/sales-agentforce-pipeline-management-configure/scripts/retrieve-settings.sh +131 -0
  89. package/skills/sales-agentforce-pipeline-management-configure/scripts/setup-all.sh +2791 -0
  90. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/agent-bundle-publish.sh +189 -0
  91. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/agent-detection.sh +239 -0
  92. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/flow-builder.sh +238 -0
  93. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/psg.sh +48 -0
  94. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/soap.sh +140 -0
  95. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/stage-descriptions.sh +448 -0
  96. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/test-opp.sh +166 -0
  97. package/skills/sales-agentforce-pipeline-management-configure/scripts/verify-all.sh +636 -0
  98. package/skills/sales-agentforce-pipeline-management-configure/scripts/verify-prompt-generation.sh +346 -0
@@ -0,0 +1,265 @@
1
+ # Repair Diagnostics for Partially Configured Orgs
2
+
3
+ This reference provides a complete diagnostic checklist for orgs with incomplete Pipeline Management configuration.
4
+
5
+ ---
6
+
7
+ ## Diagnostic Checklist
8
+
9
+ Run these checks in order to identify what's missing or misconfigured:
10
+
11
+ ### 1. Prerequisites
12
+
13
+ `readMetadata` on `EinsteinGptSettings` (`EinsteinGpt`) → expect `<enableEinsteinGptPlatform>true</enableEinsteinGptPlatform>`; `readMetadata` on `EinsteinCopilotSettings` (`EinsteinCopilot`) → expect `<enableEinsteinGptCopilot>true</enableEinsteinGptCopilot>`; `readMetadata` on `AgentPlatformSettings` (`AgentPlatform`) → expect `<enableAgentPlatform>true</enableAgentPlatform>`.
14
+
15
+ Canonical snippets: `references/soap-api-enablement.md` → **§1 Einstein Generative AI Platform**, **§2 Agentforce Agent**, and **§2b Agentforce Studio (Agent Platform)**.
16
+
17
+ **If any is false**: enable via the SOAP API using the same reference. `AgentPlatformSettings.enableAgentPlatform` gates the Deal Agent — a disabled state here explains an otherwise-opaque `SalesDealAgentSettings.enableDealAgent` failure.
18
+
19
+ ### 2. Pipeline Management Enabled
20
+
21
+ `readMetadata` on `SalesDealAgentSettings` (`SalesDealAgent`) via API v64.0+ → expect `<enableDealAgent>true</enableDealAgent>`.
22
+
23
+ Canonical snippet: `references/soap-api-enablement.md` → **§6 Pipeline Management**.
24
+
25
+ **If false**: enable via the SOAP API v64.0 (same reference).
26
+
27
+ ### 3. Permission Set Groups Exist
28
+
29
+ ```bash
30
+ sf data query -q "SELECT Id, MasterLabel, DeveloperName FROM PermissionSetGroup WHERE DeveloperName IN ('SalesManagementUserPsg','SalesManagementAgentUserPsg')" --target-org $ORG --use-tooling-api --json 2>/dev/null
31
+ # Expected: 2 records
32
+ ```
33
+
34
+ **If 0 records**: Pipeline Management not fully provisioned — toggle off/on via SOAP API
35
+
36
+ ### 4. Sales Management Agent Exists
37
+
38
+ ```bash
39
+ # The agent is the SalesAgent BotDefinition. Use standard SOQL (NOT --use-tooling-api,
40
+ # which does not support BotDefinition) and do NOT select Status (no such column).
41
+ sf data query -q "SELECT Id, DeveloperName FROM BotDefinition WHERE DeveloperName = 'SalesAgent'" --target-org $ORG --json 2>/dev/null
42
+ # Expected: 1 record
43
+ ```
44
+
45
+ **If 0 records**: Agent not created — see `references/agent-creation.md`. Note the agent
46
+ user (checked separately below) is provisioned with the PSGs during enablement and exists
47
+ even when the agent does not, so it is NOT evidence the agent was created.
48
+
49
+ ### 5. Agent User Exists
50
+
51
+ ```bash
52
+ sf data query -q "SELECT Id, Username, IsActive FROM User WHERE Username LIKE '%salesmanagementagentuser%'" --target-org $ORG --json 2>/dev/null
53
+ # Expected: 1 record with IsActive = true
54
+ ```
55
+
56
+ **If 0 records**: Agent user not created — see `references/agent-creation.md`
57
+ **If IsActive = false**: Activate user via Data API or Setup UI
58
+
59
+ ### 6. Agent User Has Correct PSG
60
+
61
+ ```bash
62
+ AGENT_USER_ID=$(sf data query -q "SELECT Id FROM User WHERE Username LIKE '%salesmanagementagentuser%'" --target-org $ORG --json 2>/dev/null | jq -r '.result.records[0].Id')
63
+
64
+ sf data query -q "SELECT PermissionSetGroup.DeveloperName FROM PermissionSetAssignment WHERE AssigneeId = '${AGENT_USER_ID}' AND PermissionSetGroup.DeveloperName = 'SalesManagementAgentUserPsg'" --target-org $ORG --json 2>/dev/null
65
+ # Expected: 1 record
66
+ ```
67
+
68
+ **If 0 records**: PSG not assigned — assign via Data API
69
+
70
+ ### 7. Schedule-Triggered Flow Exists and Is Active
71
+
72
+ ```bash
73
+ sf data query -q "SELECT Id, ApiName, IsActive FROM FlowDefinitionView WHERE SourceTemplateId='sales_pipe_mgmt__OppSuggGenSchFlow' AND IsTemplate=false" --target-org $ORG --json 2>/dev/null
74
+ # Expected: 1 record with IsActive = true
75
+ ```
76
+
77
+ **If 0 records**: Flow not cloned from template — see `references/flow-clone-from-template.md`
78
+ **If IsActive = false**: Flow deactivated — reactivate via Tooling API PATCH or Metadata API deploy
79
+
80
+ ### 8. Prompt Templates Exist
81
+
82
+ ```bash
83
+ # Note: GenAiPromptTemplate is not queryable — check via flow retrieval or UI
84
+ sf project retrieve start --metadata "Flow:sales_pipe_mgmt__GetOppGroundingData" --target-org $ORG --json 2>/dev/null
85
+ # If retrieval succeeds, prompt flow exists
86
+ ```
87
+
88
+ **If retrieval fails**: Prompt templates not provisioned — toggle Pipeline Management off/on
89
+
90
+ ### 9. Stage Descriptions Exist
91
+
92
+ ```bash
93
+ sf data query -q "SELECT COUNT() FROM OpptStageDescription" --target-org $ORG --use-tooling-api --json 2>/dev/null
94
+ # Expected: At least 1 record per active stage
95
+ ```
96
+
97
+ **If 0 records**: Stage descriptions missing — see `references/opportunity-stages.md`
98
+
99
+ ### 10. Data Sources Have Recent Activity
100
+
101
+ ```bash
102
+ # Notes
103
+ sf data query -q "SELECT COUNT() FROM ContentNote WHERE CreatedDate = LAST_N_DAYS:30" --target-org $ORG 2>/dev/null
104
+
105
+ # Opportunities
106
+ sf data query -q "SELECT COUNT() FROM Opportunity WHERE LastActivityDate = LAST_N_DAYS:7 AND IsClosed = false" --target-org $ORG 2>/dev/null
107
+
108
+ # Emails (if Einstein Activity Capture enabled)
109
+ sf data query -q "SELECT COUNT() FROM EmailMessage WHERE CreatedDate = LAST_N_DAYS:30" --target-org $ORG 2>/dev/null
110
+ ```
111
+
112
+ **If all 0**: No data sources — agent will produce no suggestions even if fully configured
113
+
114
+ ---
115
+
116
+ ## Common Repair Scenarios
117
+
118
+ ### Scenario 1: Flow Deactivated
119
+
120
+ **Symptoms**: Agent exists, PSGs exist, but no `AiGenActionItem` records (`Type = 'FIELD_UPDATE'`) created
121
+
122
+ **Diagnosis**: Flow is inactive
123
+
124
+ **Fix**:
125
+ ```bash
126
+ # Get flow ID
127
+ FLOW_ID=$(sf data query -q "SELECT Id FROM FlowDefinitionView WHERE SourceTemplateId='sales_pipe_mgmt__OppSuggGenSchFlow' AND IsTemplate=false" --target-org $ORG --json 2>/dev/null | jq -r '.result.records[0].Id')
128
+
129
+ # Reactivate via Tooling API PATCH
130
+ curl -X PATCH "${INSTANCE_URL}/services/data/v64.0/tooling/sobjects/Flow/${FLOW_ID}" \
131
+ -H "Authorization: Bearer ${ACCESS_TOKEN}" \
132
+ -H "Content-Type: application/json" \
133
+ -d '{"Metadata":{"status":"Active"}}' 2>/dev/null
134
+ ```
135
+
136
+ ### Scenario 2: Agent Not Active
137
+
138
+ **Symptoms**: `BotDefinition` exists but `BotVersion.Status = 'Inactive'`
139
+
140
+ **Diagnosis**: Agent exists but not activated
141
+
142
+ **Fix** — preferred method (matches `scripts/create-agent.sh` and `references/agent-creation.md`):
143
+ ```bash
144
+ # Resolve the latest published version and activate it.
145
+ # Retry on transient NoAgentsInOrgError right after publish.
146
+ VERSION=$(sf data query -q "SELECT VersionNumber FROM BotVersion WHERE BotDefinition.DeveloperName = 'SalesAgent' ORDER BY VersionNumber DESC LIMIT 1" --target-org $ORG --json 2>/dev/null | jq -r '.result.records[0].VersionNumber // empty')
147
+ if [[ -z "$VERSION" ]]; then
148
+ echo "Error: BotVersion not found or not queryable yet"
149
+ echo "The agent may have been published but BotVersion is not provisioned yet (async)"
150
+ exit 1
151
+ fi
152
+ sf agent activate --api-name SalesAgent --version "$VERSION" --target-org $ORG --json
153
+ ```
154
+
155
+ **Fallback** — Metadata API (only if `sf agent activate` is unavailable or fails):
156
+ ```bash
157
+ sf project retrieve start --metadata "Bot:SalesAgent" --target-org $ORG --json 2>/dev/null
158
+ # Edit force-app/main/default/bots/SalesAgent.bot-meta.xml
159
+ sed -i '' 's|<status>Draft</status>|<status>Active</status>|g' force-app/main/default/bots/SalesAgent.bot-meta.xml
160
+ sf project deploy start --metadata "Bot:SalesAgent" --target-org $ORG --json 2>/dev/null
161
+ ```
162
+
163
+ ### Scenario 3: Agent Doesn't Exist
164
+
165
+ **Symptoms**: PSGs exist but `BotDefinition` query returns 0 records
166
+
167
+ **Diagnosis**: Agent auto-creation failed
168
+
169
+ **Fix**: Publish the authoring bundle — `bash scripts/create-agent.sh <org-alias>` checks for the `SalesAgent` BotDefinition and, only if it is missing, publishes the bundle to create it (then activates). Do NOT use the SOAP `enableDealAgent` toggle to "re-provision" the agent; cycling the flag only re-creates the agent user and PSGs, not the agent. See `references/agent-creation.md`.
170
+
171
+ ### Scenario 4: Missing Stage Descriptions
172
+
173
+ **Symptoms**: Next Step suggestions work, but Stage suggestions never appear
174
+
175
+ **Diagnosis**: No `OpptStageDescription` records
176
+
177
+ **Fix**: See `references/opportunity-stages.md` for bulk-create script
178
+
179
+ ### Scenario 5: Permission Set Group Not Assigned
180
+
181
+ **Symptoms**: User can't see Pipeline Inspection or agent doesn't generate suggestions
182
+
183
+ **Diagnosis**: User missing `SalesManagementUserPsg` or agent missing `SalesManagementAgentUserPsg`
184
+
185
+ **Fix**:
186
+ ```bash
187
+ # For user
188
+ PSG_ID=$(sf data query -q "SELECT Id FROM PermissionSetGroup WHERE DeveloperName = 'SalesManagementUserPsg'" --target-org $ORG --json 2>/dev/null | jq -r '.result.records[0].Id')
189
+ USER_ID=$(sf data query -q "SELECT Id FROM User WHERE Username = 'user@example.com'" --target-org $ORG --json 2>/dev/null | jq -r '.result.records[0].Id')
190
+ sf data create record --sobject PermissionSetAssignment --values "AssigneeId='${USER_ID}' PermissionSetGroupId='${PSG_ID}'" --target-org $ORG --json 2>/dev/null
191
+
192
+ # For agent
193
+ AGENT_PSG_ID=$(sf data query -q "SELECT Id FROM PermissionSetGroup WHERE DeveloperName = 'SalesManagementAgentUserPsg'" --target-org $ORG --json 2>/dev/null | jq -r '.result.records[0].Id')
194
+ AGENT_USER_ID=$(sf data query -q "SELECT Id FROM User WHERE Username LIKE '%salesmanagementagentuser%'" --target-org $ORG --json 2>/dev/null | jq -r '.result.records[0].Id')
195
+ sf data create record --sobject PermissionSetAssignment --values "AssigneeId='${AGENT_USER_ID}' PermissionSetGroupId='${AGENT_PSG_ID}'" --target-org $ORG --json 2>/dev/null
196
+ ```
197
+
198
+ ### Scenario 5b: Agent Access Not Defined (users can't launch the agent) — W-23242378
199
+
200
+ **Symptoms**: The agent is active and users hold `SalesManagementUserPsg`, but users cannot launch or chat with the Sales Agent (it does not appear as an available agent for them).
201
+
202
+ **Diagnosis**: The Pipeline Management agent (a `BotDefinition` matched by `AgentTemplate`) has not been added to the **Agent Access** section of any permission set the users hold. Agent Access can only live on a **custom** permission set — the managed `SalesManagementUserPsg` cannot be edited directly. Verify:
203
+ ```bash
204
+ # Custom access permset present?
205
+ sf data query -q "SELECT Id FROM PermissionSet WHERE Name = 'Sales_Agent_Access'" --target-org $ORG --json 2>/dev/null
206
+ # Agent granted on it? (BotDefinition detected by AgentTemplate, not a hardcoded name)
207
+ # Two-step lookup: find the bot by AgentTemplate, then confirm it has an Active
208
+ # BotVersion. The single-query correlated-subquery form hangs 60+s on some orgs.
209
+ BOT_DEF_ID=$(sf data query -q "SELECT Id FROM BotDefinition WHERE AgentTemplate IN ('SalesMgmt__NGASalesAgent','SalesMgmt__SalesAgent') ORDER BY LastModifiedDate DESC LIMIT 1" --target-org $ORG --json 2>/dev/null | jq -r '.result.records[0].Id')
210
+ ACTIVE_COUNT=$(sf data query -q "SELECT COUNT() FROM BotVersion WHERE BotDefinitionId = '${BOT_DEF_ID}' AND Status = 'Active'" --target-org $ORG --json 2>/dev/null | jq -r '.result.totalSize // 0')
211
+ PS_ID=$(sf data query -q "SELECT Id FROM PermissionSet WHERE Name = 'Sales_Agent_Access'" --target-org $ORG --json 2>/dev/null | jq -r '.result.records[0].Id')
212
+ sf data query -q "SELECT Id FROM SetupEntityAccess WHERE ParentId = '${PS_ID}' AND SetupEntityId = '${BOT_DEF_ID}'" --target-org $ORG --json 2>/dev/null
213
+ ```
214
+
215
+ **Fix**: Run the dedicated script (idempotent — safe to re-run):
216
+ ```bash
217
+ bash scripts/define-agent-access.sh $ORG
218
+ ```
219
+ It creates the custom permset `Sales_Agent_Access` (License=None), grants Agent Access to the Pipeline Management BotDefinition (`SetupEntityAccess`, standard Data API — `SetupEntityType` is derived, do NOT set it), links the permset into `SalesManagementUserPsg` via `PermissionSetGroupComponent` (Tooling API), and confirms the PSG recalculates (poll `Status` until `Updated`). If the custom permset can't be linked into the managed PSG, it falls back to assigning the permset directly to the PSG's users.
220
+
221
+ **Fallback limitations** — the direct-assignment fallback only runs when the component link into the managed PSG fails, and it has two constraints worth knowing:
222
+ - **Point-in-time only**: it assigns the permset to users who hold the PSG *at the moment the script runs*. Users granted `SalesManagementUserPsg` *afterward* will NOT automatically get `Sales_Agent_Access` — you must re-run the script for them. (When the component link succeeds, this is a non-issue: PSG recalculation reaches all current and future members.)
223
+ - **Bounded fan-out**: the fallback processes at most 200 users (one sequential API call each). On larger orgs, fix the component link instead of relying on the fallback, so a single recalculation covers everyone.
224
+
225
+ **Note**: The autonomous agent user does NOT need Agent Access — this is only for human interactive users.
226
+
227
+ ### Scenario 6: No Recent Data Sources
228
+
229
+ **Symptoms**: Everything configured correctly but no suggestions generated
230
+
231
+ **Diagnosis**: No recent notes, emails, or opportunities
232
+
233
+ **Fix**:
234
+ - Create test notes on open opportunities
235
+ - Verify Einstein Activity Capture is syncing emails
236
+ - Verify Einstein Conversation Insights is syncing call transcripts
237
+ - Wait for next flow run (daily schedule)
238
+
239
+ ---
240
+
241
+ ## Complete Repair Script
242
+
243
+ For a comprehensive configuration check covering all components, use the dedicated verification script:
244
+
245
+ ```bash
246
+ bash scripts/verify-all.sh <org-alias>
247
+ ```
248
+
249
+ This runs all diagnostic checks (Prerequisites, Agent, PSGs, Flow, Stage Descriptions, Data Sources) and reports PASS/WARN/FAIL for each component with actionable fix instructions.
250
+
251
+ For individual component repair, use the targeted scripts:
252
+ - `scripts/enable-deal-agent.sh` — Re-enable Pipeline Management
253
+ - `scripts/create-flow.sh` — Deploy or activate the suggestion flow
254
+ - `scripts/create-agent.sh` — Re-provision agent user
255
+ - `scripts/define-agent-access.sh` — Define Agent Access so users can launch the agent (W-23242378)
256
+
257
+ ---
258
+
259
+ ## Notes
260
+
261
+ - Always run diagnostics top-to-bottom (prerequisites first, then features)
262
+ - Use SOAP API for Settings verification (most reliable)
263
+ - `BotDefinition` may not be queryable even when agent exists (depends on provisioning state)
264
+ - The authoritative enablement indicator is `SalesDealAgentSettings.enableDealAgent` (SOAP `readMetadata`). Partial configuration ("setup has run") is signaled by ANY of: an agent user holding `SalesManagementAgentUserPsg`, a scheduled flow cloned from `sales_pipe_mgmt__OppSuggGenSchFlow` (`IsTemplate=false`), or a PM `BotDefinition`. Permission set group existence alone only means the org holds the Agentforce-for-Sales license — it is NOT an enablement indicator
265
+ - Always use `2>/dev/null` on `sf ... --json` piped to jq
@@ -0,0 +1,263 @@
1
+ # Setup Order — Quick Reference
2
+
3
+ Tested sequence for enabling Agentforce Pipeline Management in a greenfield org. All commands verified in Enterprise Edition with Agentforce for Sales add-on.
4
+
5
+ ---
6
+
7
+ ## Authentication
8
+
9
+ ```bash
10
+ ORG="pipeline-mgmt-org"
11
+ BROWSER=/usr/bin/open sf org login web --instance-url https://login.salesforce.com --alias $ORG
12
+
13
+ # Get instance URL and access token
14
+ INSTANCE_URL=$(sf org display --target-org $ORG --json 2>/dev/null | jq -r '.result.instanceUrl')
15
+ ACCESS_TOKEN=$(sf org display --target-org $ORG --json 2>/dev/null | jq -r '.result.accessToken')
16
+
17
+ # Newer CLI versions (2.108+) redact the token — use fallback
18
+ if [[ -z "$ACCESS_TOKEN" || "$ACCESS_TOKEN" == *"REDACTED"* ]]; then
19
+ ACCESS_TOKEN=$(echo "y" | sf org auth show-access-token --target-org $ORG --no-prompt --json 2>/dev/null | jq -r '.result.accessToken // empty')
20
+ fi
21
+ ```
22
+
23
+ ---
24
+
25
+ ## Step 1: Enable Prerequisites (SOAP API v62.0)
26
+
27
+ Enable **in this exact order** (dependency chain: #1 → #2 → #3). See `references/soap-api-enablement.md` for full scripts.
28
+
29
+ | # | Setting | Metadata Type | Required? | Depends On | Verification |
30
+ |---|---------|---------------|-----------|------------|--------------|
31
+ | 1 | Einstein Generative AI | `EinsteinGptSettings` | **required** | — | SOAP `readMetadata` → `<enableEinsteinGptPlatform>true</enableEinsteinGptPlatform>` |
32
+ | 2 | Agentforce Agent | `EinsteinCopilotSettings` | **required** | **#1 must be enabled first** | SOAP `readMetadata` → `<enableEinsteinGptCopilot>true</enableEinsteinGptCopilot>` |
33
+ | 3 | Agentforce Studio / Agent Platform | `AgentPlatformSettings` | **required** | **#2 must be enabled first** — gates the Deal Agent | SOAP `readMetadata` → `<enableAgentPlatform>true</enableAgentPlatform>` |
34
+ | 4 | Notes (API: EnhancedNotesSettings) | `EnhancedNotesSettings` | **required** | — | `SELECT count() FROM ContentNote` succeeds |
35
+ | 5 | Enhanced Email | `EmailAdministrationSettings` | optional (recommended) | — | SOAP `readMetadata` → `<enableEnhancedEmailEnabled>true</enableEnhancedEmailEnabled>` |
36
+ | 6 | Opportunity Team Selling | `OpportunitySettings` | **required** | No Opportunity Splitting | `SELECT count() FROM OpportunityTeamMember` succeeds |
37
+
38
+ **Do NOT use CLI Metadata deploy** (`sf project deploy start`) — it has a silent failure mode where it reports success but the org reverts the setting.
39
+
40
+ **Do NOT enable `BotSettings`** (`enableBots`) — that is for legacy messaging bots and is completely unrelated to Pipeline Management. It requires legal terms acceptance and will fail. Use `EinsteinCopilotSettings` for Agentforce Agent instead.
41
+
42
+ ---
43
+
44
+ ## Step 2: Enable Pipeline Management (SOAP API v64.0)
45
+
46
+ **Critical**: Must use API v64.0+ (v62.0 returns "Property 'enableDealAgent' not valid"). `updateMetadata` on `SalesDealAgentSettings` with `<enableDealAgent>true</enableDealAgent>` and `<enableDealAgentAutoApproveAllTasks>false</enableDealAgentAutoApproveAllTasks>`, then `readMetadata` to confirm.
47
+
48
+ See the canonical SOAP snippets in `references/soap-api-enablement.md` → **§6 Pipeline Management**.
49
+
50
+ ---
51
+
52
+ ## Step 2b: Enable Pipeline Inspection
53
+
54
+ **Required.** Pipeline Inspection provides the UI where sales reps view and accept/dismiss agent suggestions. Suggestions still generate without it, but users have no way to see them — this is a required setting for the feature to be usable, not optional.
55
+
56
+ `updateMetadata` on `OpportunitySettings` with `<enablePipelineInspection>true</enablePipelineInspection>`, then `readMetadata` to confirm.
57
+
58
+ See the canonical SOAP snippets in `references/soap-api-enablement.md` → **§7 Pipeline Inspection**.
59
+
60
+ ---
61
+
62
+ ## Step 3: Verify Auto-Created Components
63
+
64
+ After enabling Pipeline Management, these components should auto-create:
65
+
66
+ ```bash
67
+ # Check permission set groups
68
+ sf data query -q "SELECT Id, MasterLabel, DeveloperName FROM PermissionSetGroup WHERE DeveloperName IN ('SalesManagementUserPsg','SalesManagementAgentUserPsg')" --target-org $ORG --use-tooling-api --json 2>/dev/null
69
+
70
+ # Check agent (may not exist in all editions — auto-creation varies)
71
+ sf data query -q "SELECT Id, DeveloperName FROM BotDefinition WHERE DeveloperName = 'SalesAgent'" --target-org $ORG --json 2>/dev/null
72
+
73
+ # Check agent user (if agent exists)
74
+ sf data query -q "SELECT Id, Username FROM User WHERE Username LIKE '%salesmanagementagentuser%'" --target-org $ORG --json 2>/dev/null
75
+ ```
76
+
77
+ **Note:** The agent is the `SalesAgent` BotDefinition — check for it directly. The agent user is NOT a substitute signal: it is provisioned with the PSGs during enablement and exists even when the agent was never created.
78
+
79
+ If the agent doesn't exist, see `references/agent-creation.md` for creation methods.
80
+
81
+ ---
82
+
83
+ ## Step 3b: Clone Flow from Template
84
+
85
+ The schedule-triggered flow must be cloned from the template `sales_pipe_mgmt__OppSuggGenSchFlow`. The template is provisioned on enablement but never activates.
86
+
87
+ **Detection (use SourceTemplateId — NOT label-based):**
88
+ ```bash
89
+ # Check if user already cloned the template
90
+ sf data query -q "SELECT Id, ApiName, IsActive FROM FlowDefinitionView WHERE SourceTemplateId='sales_pipe_mgmt__OppSuggGenSchFlow' AND IsTemplate=false" --target-org $ORG --json 2>/dev/null
91
+ # If 0 records → need to clone
92
+ ```
93
+
94
+ **Clone method:**
95
+
96
+ **Managed namespace flows CANNOT be retrieved via Metadata API or SOAP readMetadata** — both return nil/errors. The ONLY working method is:
97
+
98
+ 1. **Manual clone via Setup UI:**
99
+ - Navigate to Setup → Flows
100
+ - Find "Opportunity Suggestion Generator Schedule Flow" (API name: `sales_pipe_mgmt__OppSuggGenSchFlow`)
101
+ - Click "Save As..." to create a copy
102
+ - Name it "Process Field Update Suggestions" (or any name you choose)
103
+ - Set schedule start date to today or future date
104
+ - Activate the flow
105
+
106
+ 2. **Automation after manual clone:**
107
+
108
+ Once cloned via UI, you CAN retrieve and redeploy the CLONE (not the template) to automate activation:
109
+
110
+ ```bash
111
+ # Retrieve your cloned flow (replace with your chosen name)
112
+ CLONE_NAME="Process_Field_Update_Suggestions"
113
+ sf project retrieve start --metadata "Flow:${CLONE_NAME}" --target-org $ORG --json 2>/dev/null
114
+
115
+ CLONE_FILE="force-app/main/default/flows/${CLONE_NAME}.flow-meta.xml"
116
+
117
+ # Transform status to Active and update schedule
118
+ sed -i '' 's|<status>Draft</status>|<status>Active</status>|g' "$CLONE_FILE"
119
+ TODAY=$(date +%Y-%m-%d)
120
+ sed -i '' "s|<startDate>[^<]*</startDate>|<startDate>${TODAY}</startDate>|g" "$CLONE_FILE"
121
+
122
+ # Deploy the activated flow
123
+ sf project deploy start --metadata "Flow:${CLONE_NAME}" --target-org $ORG --json 2>/dev/null
124
+ ```
125
+
126
+ **Reference: Non-functional API retrieval (for future reference):**
127
+
128
+ ```bash
129
+ # ❌ This ALWAYS FAILS — managed namespace flows are blocked from retrieval
130
+ sf project retrieve start --metadata "Flow:sales_pipe_mgmt__OppSuggGenSchFlow" --target-org $ORG --json 2>/dev/null
131
+ # Error: "Entity of type 'Flow' named 'sales_pipe_mgmt__OppSuggGenSchFlow' cannot be found"
132
+
133
+ # ❌ SOAP readMetadata also returns nil
134
+ ```
135
+
136
+ **Verify:**
137
+ ```bash
138
+ sf data query -q "SELECT Id, ApiName, IsActive FROM FlowDefinitionView WHERE SourceTemplateId='sales_pipe_mgmt__OppSuggGenSchFlow' AND IsTemplate=false" --target-org $ORG --json 2>/dev/null
139
+ # Expected: IsActive = true
140
+ ```
141
+
142
+ See `references/flow-clone-from-template.md` for complete details.
143
+
144
+ ---
145
+
146
+ ## Step 4: Assign Permissions
147
+
148
+ ```bash
149
+ # Get PSG and user IDs
150
+ PSG_ID=$(sf data query -q "SELECT Id FROM PermissionSetGroup WHERE DeveloperName = 'SalesManagementUserPsg'" --target-org $ORG --json 2>/dev/null | jq -r '.result.records[0].Id')
151
+ USER_ID=$(sf data query -q "SELECT Id FROM User WHERE Username = 'user@example.com'" --target-org $ORG --json 2>/dev/null | jq -r '.result.records[0].Id')
152
+
153
+ # Assign via Data API (works in all CLI versions)
154
+ sf data create record --sobject PermissionSetAssignment --values "AssigneeId='${USER_ID}' PermissionSetGroupId='${PSG_ID}'" --target-org $ORG --json 2>/dev/null
155
+ # DUPLICATE_VALUE error means assignment already exists — that's success
156
+ ```
157
+
158
+ **If using Agentforce Data Library:**
159
+ ```bash
160
+ sf org assign permset --name DataCloudUser --on-behalf-of user@example.com --target-org $ORG --json 2>/dev/null
161
+ ```
162
+
163
+ ---
164
+
165
+ ## Step 5: Define Opportunity Stage Descriptions
166
+
167
+ Stage descriptions are stored in `OpptStageDescription` (Tooling API entity). The agent reads these to understand stage semantics. **Stage suggestions fail if any active stage lacks a description.**
168
+
169
+ **CRITICAL — Visibility Prerequisite**: `OpptStageDescription` is ONLY visible via Tooling API AFTER Pipeline Management is enabled (Step 2 above). Queries return `INVALID_TYPE` or empty results before enablement. Do NOT attempt stage description queries before confirming `enableDealAgent=true`.
170
+
171
+ **Important:** Stage descriptions MAY be auto-provisioned when Pipeline Management is enabled. Always CHECK for existing descriptions first to avoid DUPLICATE_VALUE errors.
172
+
173
+ **Query active stages:**
174
+ ```bash
175
+ sf data query -q "SELECT MasterLabel, ApiName FROM OpportunityStage WHERE IsActive = true ORDER BY SortOrder" --target-org $ORG --json 2>/dev/null
176
+ ```
177
+
178
+ **Check for existing stage descriptions:**
179
+ ```bash
180
+ sf data query -q "SELECT Id, OpportunityStageApiName, Description FROM OpptStageDescription" --target-org $ORG --use-tooling-api --json 2>/dev/null
181
+ ```
182
+
183
+ **Check-then-create-or-update pattern:**
184
+
185
+ ```bash
186
+ # Query existing descriptions
187
+ EXISTING=$(sf data query -q "SELECT Id, OpportunityStageApiName FROM OpptStageDescription WHERE OpportunityStageApiName='Prospecting'" --target-org $ORG --use-tooling-api --json 2>/dev/null)
188
+ RECORD_ID=$(echo "$EXISTING" | jq -r '.result.records[0].Id // empty')
189
+
190
+ if [ -z "$RECORD_ID" ]; then
191
+ # Create new description
192
+ sf data create record --sobject OpptStageDescription \
193
+ --values "DeveloperName='Prospecting' MasterLabel='Prospecting' OpportunityStageApiName='Prospecting' Description='Initial outreach and qualification. Entry: Lead converted or manual creation. Exit: Meeting scheduled or qualified out.'" \
194
+ --target-org $ORG --use-tooling-api --json 2>/dev/null
195
+ else
196
+ # Update existing description
197
+ sf data update record --sobject OpptStageDescription --record-id "$RECORD_ID" \
198
+ --values "Description='Initial outreach and qualification. Entry: Lead converted or manual creation. Exit: Meeting scheduled or qualified out.'" \
199
+ --target-org $ORG --use-tooling-api --json 2>/dev/null
200
+ fi
201
+ ```
202
+
203
+ Repeat for all active stages. See `references/opportunity-stages.md` for default descriptions by methodology.
204
+
205
+ ---
206
+
207
+ ## Step 6: Verify Data Sources
208
+
209
+ The agent needs recent activity to generate suggestions:
210
+
211
+ ```bash
212
+ # Check notes
213
+ sf data query -q "SELECT COUNT() FROM ContentNote WHERE CreatedDate = LAST_N_DAYS:30" --target-org $ORG 2>/dev/null
214
+
215
+ # Check recent opportunities
216
+ sf data query -q "SELECT COUNT() FROM Opportunity WHERE LastActivityDate = LAST_N_DAYS:7 AND IsClosed = false" --target-org $ORG 2>/dev/null
217
+
218
+ # Check emails (if Einstein Activity Capture enabled)
219
+ sf data query -q "SELECT COUNT() FROM EmailMessage WHERE CreatedDate = LAST_N_DAYS:30" --target-org $ORG 2>/dev/null
220
+ ```
221
+
222
+ If no recent activity, the agent will produce no suggestions even after full setup.
223
+
224
+ For configuring additional data sources (Einstein Conversation Insights, Einstein Activity Capture), see `references/data-sources.md`.
225
+
226
+ ---
227
+
228
+ ## Step 7: Enable Agent Analytics
229
+
230
+ Note: Not required for suggestion generation. Enables visibility into agent performance metrics.
231
+
232
+ Agent Analytics tracks suggestion acceptance rates. UI-only configuration:
233
+
234
+ 1. Go to Setup → Einstein Feedback and Monitoring → Agent Analytics
235
+ 2. Enable for the Sales Management agent
236
+ 3. Configure tracking preferences
237
+
238
+ ---
239
+
240
+ ## Troubleshooting
241
+
242
+ **If agent doesn't exist after 30 minutes:**
243
+ - See `references/agent-creation.md` for agent creation methods. The `BotDefinition:SalesAgent` is created by `sf agent publish authoring-bundle --api-name SalesAgent` (wrapped by `publish_and_activate_agent()` in `shared/agent-bundle-publish.sh`); the SOAP `enableDealAgent` toggle only re-provisions the agent user and PSGs, not the BotDefinition.
244
+
245
+ **If flow doesn't clone successfully:**
246
+ - See `references/flow-clone-from-template.md` for detailed troubleshooting
247
+
248
+ **If partially configured:**
249
+ - See `references/repair-diagnostics.md` for diagnostic checklist
250
+
251
+ **If prerequisites fail to enable:**
252
+ - See `references/soap-api-enablement.md` for troubleshooting SOAP API calls
253
+
254
+ ---
255
+
256
+ ## Notes
257
+
258
+ - Always use `2>/dev/null` on `sf ... --json` piped to jq (strips CLI warnings that corrupt JSON)
259
+ - Do NOT use CLI Metadata deploy for DealAgent enablement — SOAP API v64.0 only
260
+ - Do NOT enable `BotSettings` — legacy messaging bots, unrelated
261
+ - Pipeline Management does NOT use a managed package
262
+ - Flow uses `getOrExecFieldUpdtSuggestion` action type (preserved in clone — no manual construction)
263
+ - Flow detection uses `SourceTemplateId` (NOT label-based)