@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,215 @@
1
+ # Autonomous Updates in Pipeline Management
2
+
3
+ Pipeline Management generates opportunity field update suggestions by default, but requires manual approval. **Autonomous updates** allow the agent to apply approved suggestions automatically without user intervention.
4
+
5
+ ---
6
+
7
+ ## Safety Default: Suggestion-Only Mode
8
+
9
+ By default, Pipeline Management operates in **suggestion-only mode**:
10
+ - Agent generates `AiGenActionItem` records (`Type = 'FIELD_UPDATE'`) with suggested field updates
11
+ - Suggestions appear in Sales Console under "Pipeline Management" component
12
+ - Users manually review and approve/reject each suggestion
13
+ - No automatic writes to opportunity fields
14
+
15
+ This is the **safest mode** for initial deployment and testing.
16
+
17
+ ---
18
+
19
+ ## Global Autonomous Toggle
20
+
21
+ ### Setting: `enableDealAgentAutoApproveAllTasks`
22
+
23
+ Located in `SalesDealAgentSettings` (SOAP API only — CLI deploy silently fails).
24
+
25
+ **When enabled**:
26
+ - Agent automatically applies **all** field update suggestions without user approval
27
+ - Suggestions are still logged as `AiGenActionItem` records but are immediately applied
28
+ - Users see updates in Opportunity field history
29
+ - No review workflow
30
+
31
+ **When disabled** (default):
32
+ - Suggestion-only mode (manual approval required)
33
+
34
+ ---
35
+
36
+ ## Enabling Global Autonomous Updates
37
+
38
+ ### Via SOAP API v64.0
39
+
40
+ ```bash
41
+ ORG="pipeline-mgmt-org"
42
+ AUTH_INFO=$(sf org display --target-org $ORG --json 2>/dev/null)
43
+ ACCESS_TOKEN=$(echo "$AUTH_INFO" | jq -r '.result.accessToken')
44
+ INSTANCE_URL=$(echo "$AUTH_INFO" | jq -r '.result.instanceUrl')
45
+
46
+ curl -s "${INSTANCE_URL}/services/Soap/m/64.0" \
47
+ -H "Content-Type: text/xml; charset=UTF-8" \
48
+ -H "SOAPAction: update" \
49
+ -d "<?xml version='1.0' encoding='utf-8'?>
50
+ <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:met='http://soap.sforce.com/2006/04/metadata'>
51
+ <soapenv:Header>
52
+ <met:SessionHeader>
53
+ <met:sessionId>${ACCESS_TOKEN}</met:sessionId>
54
+ </met:SessionHeader>
55
+ </soapenv:Header>
56
+ <soapenv:Body>
57
+ <met:updateMetadata>
58
+ <met:metadata xsi:type='met:SalesDealAgentSettings' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
59
+ <met:fullName>SalesDealAgent</met:fullName>
60
+ <met:enableDealAgent>true</met:enableDealAgent>
61
+ <met:enableDealAgentAutoApproveAllTasks>true</met:enableDealAgentAutoApproveAllTasks>
62
+ </met:metadata>
63
+ </met:updateMetadata>
64
+ </soapenv:Body>
65
+ </soapenv:Envelope>" | xmllint --format - 2>/dev/null
66
+ ```
67
+
68
+ ### Verification
69
+
70
+ ```bash
71
+ sf data query -q "SELECT enableDealAgent, enableDealAgentAutoApproveAllTasks FROM SalesDealAgentSettings" --target-org $ORG --json 2>/dev/null
72
+ ```
73
+
74
+ **Expected output**:
75
+ ```json
76
+ {
77
+ "enableDealAgent": true,
78
+ "enableDealAgentAutoApproveAllTasks": true
79
+ }
80
+ ```
81
+
82
+ ---
83
+
84
+ ## Per-Field Autonomous Updates
85
+
86
+ **Status**: Not yet available in current Pipeline Management release (as of API v67.0).
87
+
88
+ **Future capability**: Salesforce plans to support per-field autonomous toggles, allowing fine-grained control:
89
+ - Enable autonomous updates for `Stage` (high confidence field)
90
+ - Require manual approval for `Amount` (high impact field)
91
+ - Enable autonomous updates for `NextStep` (low risk field)
92
+
93
+ **Current workaround**: Use global toggle only. If per-field control is required, implement custom Apex trigger to block autonomous updates on specific fields based on business logic.
94
+
95
+ ---
96
+
97
+ ## Daily LLM Request Limits
98
+
99
+ Pipeline Management has **daily LLM request limits** to prevent quota exhaustion:
100
+
101
+ | Limit | Value |
102
+ |-------|-------|
103
+ | Max LLM requests per day | 8,000 |
104
+ | Approximate opportunities processed | ~4,000 (2 requests per opportunity: grounding + suggestion) |
105
+
106
+ The 8,000/day figure was observed live: the suggestion flow's debug log emits `{enqueuedStatus=Successful, currentLLMUsage=N, dailyLLMLimit=8000}`. Confirm the current value for your org/edition — `dailyLLMLimit` in that log line is the source of truth.
107
+
108
+ **What happens when limit is reached**:
109
+ - Agent stops generating new suggestions until next day (UTC reset)
110
+ - Existing suggestions remain visible and actionable
111
+ - No error messages shown to users
112
+
113
+ **Monitoring usage**:
114
+ ```bash
115
+ # Query suggestion records created today
116
+ sf data query -q "SELECT COUNT() FROM AiGenActionItem WHERE Type = 'FIELD_UPDATE' AND CreatedDate = TODAY" --target-org $ORG --json 2>/dev/null
117
+
118
+ # Each AiGenActionItem represents 1 field-update suggestion
119
+ # Grounding + suggestion together consume ~2 LLM requests per opportunity
120
+ ```
121
+
122
+ **Recommendations**:
123
+ - Start with suggestion-only mode to gauge usage patterns
124
+ - Enable autonomous updates only after confirming daily volume stays under 4,000 opportunities
125
+ - Monitor `AiGenActionItem` record creation rate
126
+ - Consider stage-based filtering (only generate suggestions for opportunities in specific stages)
127
+
128
+ ---
129
+
130
+ ## Risk Matrix: When to Enable Autonomous Updates
131
+
132
+ | Scenario | Autonomous Mode | Rationale |
133
+ |----------|-----------------|-----------|
134
+ | Initial deployment | ❌ Disabled | Validate suggestion quality first |
135
+ | Sandbox testing | ✅ Enabled | Test end-to-end flow with real data |
136
+ | Production pilot (< 50 users) | ⚠️ Optional | Depends on confidence in suggestion accuracy |
137
+ | Production rollout (> 50 users) | ❌ Disabled initially | Start with manual approval, enable after 2 weeks |
138
+ | High-value opportunities (> $1M) | ❌ Disabled | Manual approval for high-stakes updates |
139
+ | Standard opportunities (< $100K) | ✅ Enabled | Low risk for autonomous updates |
140
+
141
+ ---
142
+
143
+ ## Disabling Autonomous Updates
144
+
145
+ To revert to suggestion-only mode:
146
+
147
+ ```bash
148
+ curl -s "${INSTANCE_URL}/services/Soap/m/64.0" \
149
+ -H "Content-Type: text/xml; charset=UTF-8" \
150
+ -H "SOAPAction: update" \
151
+ -d "<?xml version='1.0' encoding='utf-8'?>
152
+ <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:met='http://soap.sforce.com/2006/04/metadata'>
153
+ <soapenv:Header>
154
+ <met:SessionHeader>
155
+ <met:sessionId>${ACCESS_TOKEN}</met:sessionId>
156
+ </met:SessionHeader>
157
+ </soapenv:Header>
158
+ <soapenv:Body>
159
+ <met:updateMetadata>
160
+ <met:metadata xsi:type='met:SalesDealAgentSettings' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
161
+ <met:fullName>SalesDealAgent</met:fullName>
162
+ <met:enableDealAgent>true</met:enableDealAgent>
163
+ <met:enableDealAgentAutoApproveAllTasks>false</met:enableDealAgentAutoApproveAllTasks>
164
+ </met:metadata>
165
+ </met:updateMetadata>
166
+ </soapenv:Body>
167
+ </soapenv:Envelope>" | xmllint --format - 2>/dev/null
168
+ ```
169
+
170
+ ---
171
+
172
+ ## Troubleshooting
173
+
174
+ ### Autonomous updates enabled but suggestions still require approval
175
+
176
+ **Symptom**: `enableDealAgentAutoApproveAllTasks = true` but suggestions appear in UI for manual approval
177
+
178
+ **Causes**:
179
+ 1. **Setting not propagated** — Wait up to 5 minutes after SOAP API call
180
+ 2. **User permission mismatch** — Autonomous updates may require specific permission set (verify with Salesforce support)
181
+ 3. **Opportunity-level override** — Some orgs have custom validation rules or process builders blocking automatic updates
182
+
183
+ **Diagnosis**:
184
+ ```bash
185
+ # Check setting value
186
+ sf data query -q "SELECT enableDealAgentAutoApproveAllTasks FROM SalesDealAgentSettings" --target-org $ORG --json 2>/dev/null
187
+
188
+ # Check suggestion status (Subject = the field API name, ParentId = the Opportunity Id)
189
+ sf data query -q "SELECT Id, Subject, Status, ParentId FROM AiGenActionItem WHERE Type = 'FIELD_UPDATE' AND CreatedDate = TODAY LIMIT 10" --target-org $ORG --json 2>/dev/null
190
+ ```
191
+
192
+ ### Autonomous updates apply wrong values
193
+
194
+ **Symptom**: Agent autonomously updates fields but values are incorrect
195
+
196
+ **Causes**:
197
+ 1. **Insufficient grounding data** — Agent lacks recent notes, emails, or call transcripts
198
+ 2. **Stage descriptions missing or outdated** — See `references/opportunity-stages.md`
199
+ 3. **Prompt template misconfiguration** — Custom prompt templates may override default logic
200
+
201
+ **Fix**:
202
+ 1. Disable autonomous updates immediately
203
+ 2. Review `AiGenActionItem` records for patterns (which fields have high error rates — group by `Subject`)
204
+ 3. Add or update stage descriptions for frequently misidentified stages
205
+ 4. Re-enable autonomous updates after validation
206
+
207
+ ---
208
+
209
+ ## Notes
210
+
211
+ - Always test autonomous updates in sandbox before production enablement
212
+ - Use suggestion-only mode for at least 2 weeks in production to validate accuracy
213
+ - Monitor field history on opportunities to detect autonomous update patterns
214
+ - Consider custom Apex triggers for org-specific autonomous update rules (e.g., block updates on closed opportunities)
215
+ - SOAP API v64.0+ required for `SalesDealAgentSettings` (CLI deploy silently fails)
@@ -0,0 +1,75 @@
1
+ # Canonical Agent Path — Two Calls with Interactive Tune-Loop
2
+
3
+ Because an agent-driven run is **always non-interactive** (a piped stdin forces `--non-interactive`), the script cannot pause to let the user shape and approve each field's prompt. So split the run and own the interactive tuning yourself, between the two calls:
4
+
5
+ ```bash
6
+ cd skills/sales-agentforce-pipeline-management-configure/scripts
7
+
8
+ # CALL 1 — enablement through prompt templates, then STOP before the flow.
9
+ # This call still runs ALL prerequisites: Einstein Generative AI, Agentforce Agent, Enhanced
10
+ # Notes, Opportunity Team, Pipeline Inspection, Pipeline Management enablement, agent-user/PSG
11
+ # provisioning, BotDefinition publish/activate, Agent Access — nothing is skipped.
12
+ bash setup-all.sh <org-alias> --fields "NextStep,Risk__c" \
13
+ --field-goal "NextStep:<text>" --field-instruction "NextStep:<text>" \
14
+ --through-phase prompts
15
+
16
+ # TUNE-LOOP (you drive this, per non-StageName field). Generate a note tailored to the
17
+ # field's instruction, seed it, run a synchronous generation, show the result, and LOOP
18
+ # UNTIL THE USER APPROVES:
19
+ bash add-field-suggestion.sh <org-alias> <Field> --skip-flow --force \
20
+ --goal "<goal>" --instruction "<instruction>" \
21
+ --verify-with-note --note "<sample note written to exercise THIS field's instruction>"
22
+ # → shows "Suggested: …" + "Reasoning: …". Relay both to the user.
23
+ # → user approves → next field. User wants a change → re-run with adjusted --goal/--instruction/--note.
24
+ # → NO output (blocked): show why, then ask the user immediately — retry / proceed-unverified / skip.
25
+ # "proceed" wires the field live but flag it as UNVERIFIED.
26
+
27
+ # ALSO show the DEFAULT suggestion for every SELECTED field the user left UNCUSTOMIZED
28
+ # (StageName always; NextStep when no goal/instruction was given), so they can decide to
29
+ # keep or change the default even though they didn't tune it:
30
+ bash scripts/verify-prompt-generation.sh <org-alias> <Field> <oppId>
31
+ # → relay "Suggested / Reasoning". Keep → done. Change NextStep → tune it via add-field-suggestion.sh
32
+ # (above). Change StageName → adjust its stage descriptions (--create-stage-descriptions).
33
+
34
+ # CALL 2 — build & activate the flow (approved fields only), activate agent, recalc PSG, verify.
35
+ bash setup-all.sh <org-alias> --fields "NextStep,Risk__c" --from-phase flow
36
+ ```
37
+
38
+ ## Rules for the Agent Driving This
39
+
40
+ - **The tune-loop IS Call-1 prompt verification.** Seeding a note and running `add-field-suggestion.sh --verify-with-note` (showing "Suggested / Reasoning") is how each field's prompt is verified. There is no separate "run prompt verification" step to trigger afterward — if you completed the tune-loop, verification happened.
41
+ - **Show a default suggestion for every SELECTED field, even uncustomized ones.** `StageName` and an uncustomized `NextStep` still generate a default suggestion — surface it (via `verify-prompt-generation.sh <org> <field> <oppId>`) so the user can decide whether to keep or change the default they never explicitly tuned. `StageName` can't be tuned via `add-field-suggestion.sh` (managed picklist template, no override), but its suggestion is shaped by its **stage descriptions** — change those (`--create-stage-descriptions` / edit `OpptStageDescription`) to change it. Never pull in fields the user didn't select.
42
+ - **`StageName` needs stage descriptions to generate.** Its grounding is created in **Call 1** (Phase 4c.5, only when `StageName` is selected) *before* the StageName prompt is tested — so a StageName default can be shown during Call 1's tune-loop.
43
+ - **Call 2 (`--from-phase flow`) is MANDATORY.** Call 1 stops *before* the flow is built, so a run that ends after Call 1 has **no** `Process_Field_Update_Suggestions` flow and generates **zero** scheduled suggestions. The setup is incomplete until Call 2 builds and activates the flow. Always run both calls.
44
+ - **Collect goal/instruction up front** (clarifying Q5) for every non-`StageName` field the user wants customized. Do **not** silently keep the OOTB/default prompt without asking — the script cannot ask for you.
45
+ - **Loop until the user approves** each field's suggestion. Do not treat the first generation as final.
46
+ - Pass the SAME `--fields` set to both calls. StageName (if selected) needs no per-field tune *iteration* (managed picklist template), but DO still show its default suggestion for the user to accept or adjust.
47
+ - To re-inspect any field's prompt outside the loop, run `bash scripts/verify-prompt-generation.sh <org> <field>` (pass the **field** name — e.g. `NextStep`, `Risk__c` — not a raw template name; it resolves the managed/derived template for you).
48
+ - Prefer this two-call path over a single unattended run whenever a human is available to review prompts.
49
+
50
+ ## How to Narrate to the User
51
+
52
+ Run all commands in background. Narrate in plain language. Check exit codes and translate errors to admin-friendly messages. See `references/admin-communication.md` for detailed patterns.
53
+
54
+ **Step 0 — License check** (30 sec): "Checking if your org is licensed..." → pass "Ready" or warn "[blocker]"
55
+
56
+ **Call 1 — Setup platform & prompts** (2-4 min): "Setting up the platform and agent..." → pass "Ready. Let me show you sample suggestions..." or warn "[auto-retry or explain]"
57
+
58
+ **Tune-loop** (1-4 min per field): "Generating sample for [Field]..." → Show suggestion + "Does this look good?" → Iterate if needed or handle timeout/error with choices
59
+
60
+ **Call 2 — Activate** (1-2 min): "Activating the automation..." → pass "Pipeline Management is live!" or warn "[explain + offer retry/manual]"
61
+
62
+ ## Internal Step Map (Reference Only)
63
+
64
+ The narration lines above are the user-facing view. The internal step map below is *your* reference for what each call does — surface it only when a step fails and you need to explain what broke.
65
+
66
+ **Call 1 — Enablement through prompt templates** *(stops before the flow)* — `--through-phase prompts`
67
+
68
+ - **Step 1 — Enabling prerequisites & the data source**: SOAP API prerequisites, platform prerequisites (Einstein Generative AI, Agentforce Agent, Enhanced Notes, Opportunity Team, Pipeline Inspection), Pipeline Management enablement, and the autonomous-mode setting.
69
+ - **Step 2 — Provisioning the agent**: agent user + PSG assignment, agent architecture verification, and Agent Access.
70
+ - **Step 3 — Setting up & verifying the field prompt**: create stage descriptions first if `StageName` is selected (its grounding), deploy/activate the selected fields' prompt templates, then the interactive tune-loop — seed a note, generate, relay "Suggested / Reasoning" to the user (including the default for uncustomized `StageName`/`NextStep`), and loop until they approve each field.
71
+
72
+ **Call 2 — Building & activating the flow** *(goes live)* — `--from-phase flow`
73
+
74
+ - **Step 4 — Building & activating the flow**: build the schedule-triggered flow with the approved fields only, then activate it.
75
+ - **Step 5 — Finishing & verifying**: user permissions and final verification.
@@ -0,0 +1,155 @@
1
+ # Data Sources Decision Table
2
+
3
+ Pipeline Management uses data sources to generate field update suggestions. The quality and relevance of suggestions directly depends on which data sources are enabled and have recent activity.
4
+
5
+ ---
6
+
7
+ ## Data Source Matrix
8
+
9
+ | Data Source | What It Provides | Required Setting | Automation Level |
10
+ |-------------|------------------|------------------|-----------------|
11
+ | **Notes** (ContentNote) | Meeting notes, deal notes attached to opportunities | `EnhancedNotesSettings.enableEnhancedNotes` | ✅ SOAP API |
12
+ | **Enhanced Email** | Email body text indexing for deeper analysis | `EmailAdministrationSettings.enableEnhancedEmailEnabled` | ✅ SOAP API |
13
+ | **Einstein Activity Capture** (EAC) | Auto-captured emails + calendar events | Separate product provisioning | ❌ UI setup required |
14
+ | **Einstein Conversation Insights** (ECI) | Voice/video call transcripts | Separate product provisioning | ❌ UI setup required |
15
+
16
+ ---
17
+
18
+ ## Decision Flow
19
+
20
+ ```text
21
+ Does the org have Notes (ContentNote) with recent activity?
22
+ ├── Yes → Enable Enhanced Notes ✅ (baseline data source)
23
+ └── No → Create sample notes on open opportunities for testing
24
+
25
+ Does the org use email-to-opportunity logging?
26
+ ├── Yes → Enable Enhanced Email ✅ (enables email body indexing)
27
+ │ → Check if Einstein Activity Capture is provisioned
28
+ │ ├── Yes → Verify EAC is capturing emails (Setup → EAC Configuration)
29
+ │ └── No → Email logging via manual BCC or Salesforce Inbox
30
+ └── No → Skip email data source
31
+
32
+ Does the org use call recording/transcription?
33
+ ├── Yes → Check if Einstein Conversation Insights is provisioned
34
+ │ ├── Yes → Verify transcripts exist: SELECT COUNT() FROM VoiceCall
35
+ │ └── No → Cannot enable without ECI license
36
+ └── No → Skip call transcript data source
37
+ ```
38
+
39
+ ---
40
+
41
+ ## Minimum Viable Data Sources
42
+
43
+ For Pipeline Management to produce useful suggestions, at minimum:
44
+
45
+ 1. **Notes** — must be enabled (lowest barrier)
46
+ 2. **Recent opportunity activity** — at least some open opportunities must have activity in the last 7 days
47
+
48
+ Without any data sources with recent content, the flow will run daily but produce no suggestions.
49
+
50
+ ---
51
+
52
+ ## Verifying Data Source Activity
53
+
54
+ ```bash
55
+ ORG="pipeline-mgmt-org"
56
+
57
+ echo "=== Notes (primary data source) ==="
58
+ sf data query -q "SELECT COUNT() FROM ContentNote WHERE CreatedDate = LAST_N_DAYS:30" --target-org $ORG 2>/dev/null
59
+
60
+ echo "=== Emails (if Enhanced Email enabled) ==="
61
+ sf data query -q "SELECT COUNT() FROM EmailMessage WHERE CreatedDate = LAST_N_DAYS:30 AND RelatedToId != null" --target-org $ORG 2>/dev/null
62
+
63
+ echo "=== Recent opportunity activity ==="
64
+ sf data query -q "SELECT COUNT() FROM Opportunity WHERE LastActivityDate = LAST_N_DAYS:7 AND IsClosed = false" --target-org $ORG 2>/dev/null
65
+
66
+ echo "=== Voice calls (if ECI enabled) ==="
67
+ sf data query -q "SELECT COUNT() FROM VoiceCall WHERE CreatedDate = LAST_N_DAYS:30" --target-org $ORG 2>/dev/null
68
+ ```
69
+
70
+ **Expected**: Total > 0 for at least Notes and recent opportunity activity.
71
+
72
+ ---
73
+
74
+ ## Enabling Data Sources via API
75
+
76
+ ### Notes (SOAP API)
77
+
78
+ ```bash
79
+ # See references/soap-api-enablement.md Section 3
80
+ curl -s "${INSTANCE_URL}/services/Soap/m/62.0" \
81
+ -H "Content-Type: text/xml; charset=UTF-8" \
82
+ -H "SOAPAction: update" \
83
+ -d "<?xml version='1.0' encoding='utf-8'?>
84
+ <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:met='http://soap.sforce.com/2006/04/metadata'>
85
+ <soapenv:Header><met:SessionHeader><met:sessionId>${ACCESS_TOKEN}</met:sessionId></met:SessionHeader></soapenv:Header>
86
+ <soapenv:Body><met:updateMetadata>
87
+ <met:metadata xsi:type='met:EnhancedNotesSettings' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
88
+ <met:fullName>EnhancedNotes</met:fullName>
89
+ <met:enableEnhancedNotes>true</met:enableEnhancedNotes>
90
+ </met:metadata>
91
+ </met:updateMetadata></soapenv:Body>
92
+ </soapenv:Envelope>" | xmllint --format - 2>/dev/null | grep -E "(success|message)" | head -5
93
+ ```
94
+
95
+ ### Enhanced Email (SOAP API)
96
+
97
+ ```bash
98
+ # See references/soap-api-enablement.md Section 4
99
+ curl -s "${INSTANCE_URL}/services/Soap/m/62.0" \
100
+ -H "Content-Type: text/xml; charset=UTF-8" \
101
+ -H "SOAPAction: update" \
102
+ -d "<?xml version='1.0' encoding='utf-8'?>
103
+ <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:met='http://soap.sforce.com/2006/04/metadata'>
104
+ <soapenv:Header><met:SessionHeader><met:sessionId>${ACCESS_TOKEN}</met:sessionId></met:SessionHeader></soapenv:Header>
105
+ <soapenv:Body><met:updateMetadata>
106
+ <met:metadata xsi:type='met:EmailAdministrationSettings' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
107
+ <met:fullName>EmailAdministration</met:fullName>
108
+ <met:enableEnhancedEmailEnabled>true</met:enableEnhancedEmailEnabled>
109
+ </met:metadata>
110
+ </met:updateMetadata></soapenv:Body>
111
+ </soapenv:Envelope>" | xmllint --format - 2>/dev/null | grep -E "(success|message)" | head -5
112
+ ```
113
+
114
+ ### Einstein Activity Capture (UI-Only)
115
+
116
+ EAC requires separate product provisioning and cannot be fully automated:
117
+
118
+ 1. Setup → Einstein Activity Capture → Settings
119
+ 2. Enable for target users or profiles
120
+ 3. Configure sync settings (which emails/events to capture)
121
+ 4. Wait 24-48 hours for initial sync
122
+
123
+ ### Einstein Conversation Insights (UI-Only)
124
+
125
+ ECI requires a separate license and provisioning:
126
+
127
+ 1. Setup → Einstein Conversation Insights → Settings
128
+ 2. Connect recording provider (Zoom, Teams, etc.)
129
+ 3. Enable for target users
130
+ 4. Wait for transcripts to populate
131
+
132
+ ---
133
+
134
+ ## Data Source Impact on Suggestions
135
+
136
+ | Data Source | Suggestion Quality Impact |
137
+ |-------------|--------------------------|
138
+ | Notes only | Basic — relies on manually written notes |
139
+ | Notes + Email | Better — captures communication context automatically |
140
+ | Notes + Email + EAC | Good — full email + calendar activity captured |
141
+ | Notes + Email + EAC + ECI | Best — includes call transcript insights |
142
+
143
+ **Recommendation**: Enable Notes + Enhanced Email as the baseline (both automatable). Add EAC and ECI if the org has those licenses.
144
+
145
+ ---
146
+
147
+ ## Troubleshooting
148
+
149
+ | Issue | Cause | Fix |
150
+ |-------|-------|-----|
151
+ | No suggestions generated despite active flow | No recent data in any source | Create notes on open opportunities, wait 24h |
152
+ | Suggestions low quality | Only notes enabled, notes are sparse | Enable Enhanced Email, add more detailed notes |
153
+ | "VoiceCall not supported" error | ECI not provisioned | Skip ECI-related queries if not licensed |
154
+ | Emails not appearing in suggestions | Enhanced Email not enabled | Enable via SOAP API (see above) |
155
+ | EAC enabled but no emails captured | Sync delay or configuration issue | Check EAC settings, wait 24-48h |
@@ -0,0 +1,120 @@
1
+ # Field Completion Prompt Template Guide
2
+
3
+ This guide is about the **two field-specific lines** you supply when adding a new Opportunity field-completion suggestion. The template structure itself is fixed and owned by `assets/field-completion-template.genAiPromptTemplate-meta.xml`; `scripts/add-field-suggestion.sh` fills it in, deploys, activates, and wires the flow. See `references/field-completion-prompts.md` for the full end-to-end mechanics.
4
+
5
+ You do **not** author the whole prompt or use Prompt Builder. You only decide two things:
6
+
7
+ - `--goal` — one sentence naming what the model should think about for this field.
8
+ - `--instruction` — one line of field-specific extraction guidance.
9
+
10
+ Everything else in the prompt (data-source block, JSON output rules, character self-check, source-ID extraction rules) is the OOTB Pipeline Management body, reused verbatim. Getting the two lines right is the whole job.
11
+
12
+ ---
13
+
14
+ ## Where the two lines land
15
+
16
+ Inside the fixed template body, the script substitutes:
17
+
18
+ ```text
19
+ You must think about @@FIELD_GOAL@@
20
+ ...extract information in order to provide the suggested new value for the "@@FIELDLABEL@@" field... @@FIELD_INSTRUCTION@@
21
+ ```
22
+
23
+ So `--goal` completes "You must think about …" and `--instruction` is appended after the standard extraction sentence. Write them to read naturally in those slots.
24
+
25
+ The template already enforces: `SuggestedNewValue` ≤ the field's own length, `Reasoning` ≤ 250 chars, `Snippet` ≤ 100 chars, `DueDate` = `"30 days"`, and a `Sources` array of `{source, snippet}` objects (never a flat string array). Do **not** restate or contradict those caps in your two lines — the field length cap is set automatically from the field's `length`.
26
+
27
+ ---
28
+
29
+ ## Worked examples
30
+
31
+ Each example shows only the two values you pass to the script; the field must be a text field (`type=string`, length ≤ 255).
32
+
33
+ ### Risk (a `Risk__c` custom field, mirroring the OOTB NextStep/Stage prompt shape)
34
+
35
+ ```bash
36
+ --goal "what puts this opportunity at risk of slipping, stalling, or being lost, so the rep can proactively address it"
37
+ --instruction "If there is any mention of budget concerns, competition, decision-maker or stakeholder changes, timeline slips, unresolved objections, or loss of engagement, you must strictly include that in your suggested risk, reasoning, and snippets."
38
+ ```
39
+
40
+ ### Next Strategic Initiative (`Next_Strategic_Initiative__c`, Text 255)
41
+
42
+ ```bash
43
+ --goal "the customer's strategic business goal or initiative that this opportunity supports"
44
+ --instruction "Focus on business outcomes in the customer's own words (look for \"our goal is\", \"we're trying to\", \"strategic priority\"); if multiple goals appear, pick the one most frequently or most recently emphasized."
45
+ ```
46
+
47
+ ### Primary Competitor (`Primary_Competitor__c`, Text 255)
48
+
49
+ ```bash
50
+ --goal "which competitors the prospect is evaluating and how they compare"
51
+ --instruction "Extract explicit competitor names and the specific concern or comparison raised; if several are mentioned, choose the one discussed most or first."
52
+ ```
53
+
54
+ ---
55
+
56
+ ## Writing good goal/instruction lines
57
+
58
+ ### ✅ Good
59
+
60
+ - **Specific about what to extract** — names the signals to look for.
61
+ - **Grounded** — tells the model to use only what's in the data sources.
62
+ - **Customer-centric** — business outcomes, not product features.
63
+ - **Handles absence** — the fixed body already returns empty values when no data exists; your instruction should reinforce, not fight, that.
64
+
65
+ ### ❌ Avoid
66
+
67
+ | Anti-pattern | Example | Why it fails |
68
+ |---|---|---|
69
+ | Too vague | "Update this field based on the opportunity." | No guidance on what to extract. |
70
+ | Assumes data exists | "Populate with the customer's Q3 revenue goal and sponsor's name." | Forces fabrication when the data is absent. |
71
+ | Product-centric | "List which features the customer wants." | Ignores the customer's business context. |
72
+ | Restating caps wrongly | "SuggestedNewValue must be 500 characters." | The template already caps at the field length; a conflicting number confuses the model. |
73
+
74
+ ---
75
+
76
+ ## Verifying a new field's output
77
+
78
+ Use `--verify-with-note` (seeds a ContentNote, then calls the synchronous `/generations` endpoint) or call it manually:
79
+
80
+ ```bash
81
+ sf api request rest "/services/data/v64.0/einstein/prompt-templates/<TemplateName>/generations" \
82
+ --method POST --target-org "$ORG" \
83
+ --body '{"isPreview":false,"inputParams":{"valueMap":{"Input:Opportunity":{"value":{"id":"<oppId>"}}}},"additionalConfig":{"numGenerations":1,"temperature":0,"applicationName":"PromptTemplateGenerationsInvocable"}}'
84
+ ```
85
+
86
+ A correct response looks like this (note the object-form `Sources` and the literal `"30 days"` DueDate — verified live):
87
+
88
+ ```json
89
+ {
90
+ "FieldName": "Deal_Momentum__c",
91
+ "SuggestedNewValue": "Low momentum due to budget freeze, no executive sponsor, and competitor evaluation.",
92
+ "OriginalValue": "",
93
+ "Reasoning": "The June 20 call with Sarah Chen flagged a Q3 budget freeze and departure of the sponsor; a note records active evaluation of competitor Onyx.",
94
+ "DueDate": "30 days",
95
+ "Sources": [
96
+ { "source": "069SB000008L2yHYAS", "snippet": "Sarah Chen: budget is frozen until the Q3 review." }
97
+ ]
98
+ }
99
+ ```
100
+
101
+ The real (async) suggestions land as `AiGenActionItem` records — query by `ParentId` (Opportunity Id) and `Subject` (field API name), `Type = 'FIELD_UPDATE'`. There is no `FieldCompletion` object.
102
+
103
+ ---
104
+
105
+ ## Common issues
106
+
107
+ | Issue | Cause | Fix |
108
+ |---|---|---|
109
+ | Field always returns empty | Instruction too strict, or opportunity has no recent notes/emails/calls | Broaden the instruction; seed a note (`--verify-with-note`) or use an active opportunity |
110
+ | Model fabricates data | Goal/instruction implies data that isn't there | Reword to "if present"; the fixed body already forbids ungrounded output |
111
+ | Output exceeds field length | Field length ≤ your content need | Pick a field with adequate length; the cap is the field's own `length` |
112
+ | Template never activates | Version round-trip skipped or identifier hand-authored | Let the script own activation — never guess `<activeVersionIdentifier>` |
113
+
114
+ ---
115
+
116
+ ## Further reading
117
+
118
+ - `references/field-completion-prompts.md` — full deploy/activate/wire/verify mechanics and the three requirements for a field to produce suggestions.
119
+ - `references/data-sources.md` — enabling Einstein Conversation Insights, Activity Capture, and Enhanced Email so `GetOppGroundingData` has content.
120
+ - `references/flow-clone-from-template.md` — how `Process_Field_Update_Suggestions` invokes `getOrExecFieldUpdtSuggestion`.