@salesforce/afv-skills 1.1.0 → 1.2.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 (103) hide show
  1. package/package.json +4 -4
  2. package/skills/agentforce-development/SKILL.md +427 -0
  3. package/skills/agentforce-development/assets/README-legacy.md +89 -0
  4. package/skills/agentforce-development/assets/agent-spec-template.md +90 -0
  5. package/skills/agentforce-development/assets/agents/README.md +45 -0
  6. package/skills/agentforce-development/assets/agents/hello-world.agent +60 -0
  7. package/skills/agentforce-development/assets/agents/multi-topic.agent +105 -0
  8. package/skills/agentforce-development/assets/agents/production-faq.agent +101 -0
  9. package/skills/agentforce-development/assets/agents/production-faq.bundle-meta.xml +4 -0
  10. package/skills/agentforce-development/assets/agents/simple-qa.agent +72 -0
  11. package/skills/agentforce-development/assets/apex/models-api-queueable.cls +225 -0
  12. package/skills/agentforce-development/assets/bundle-meta.xml +23 -0
  13. package/skills/agentforce-development/assets/components/apex-action.agent +52 -0
  14. package/skills/agentforce-development/assets/components/error-handling.agent +58 -0
  15. package/skills/agentforce-development/assets/components/escalation-setup.agent +169 -0
  16. package/skills/agentforce-development/assets/components/flow-action.agent +66 -0
  17. package/skills/agentforce-development/assets/components/n-ary-conditions.agent +110 -0
  18. package/skills/agentforce-development/assets/components/topic-with-actions.agent +40 -0
  19. package/skills/agentforce-development/assets/deterministic-routing.agent +166 -0
  20. package/skills/agentforce-development/assets/escalation-pattern.agent +209 -0
  21. package/skills/agentforce-development/assets/flow-action-lookup.agent +115 -0
  22. package/skills/agentforce-development/assets/hub-and-spoke.agent +104 -0
  23. package/skills/agentforce-development/assets/invocable-apex-template.cls +187 -0
  24. package/skills/agentforce-development/assets/local-info-agent-annotated.agent +355 -0
  25. package/skills/agentforce-development/assets/metadata/basic-prompt-template.promptTemplate-meta.xml +109 -0
  26. package/skills/agentforce-development/assets/metadata/genai-function-apex.xml +92 -0
  27. package/skills/agentforce-development/assets/metadata/genai-function-flow.xml +57 -0
  28. package/skills/agentforce-development/assets/metadata/genai-plugin.xml +72 -0
  29. package/skills/agentforce-development/assets/metadata/http-callout-flow.flow-meta.xml +348 -0
  30. package/skills/agentforce-development/assets/metadata/record-grounded-prompt.promptTemplate-meta.xml +136 -0
  31. package/skills/agentforce-development/assets/minimal-starter.agent +42 -0
  32. package/skills/agentforce-development/assets/patterns/README.md +254 -0
  33. package/skills/agentforce-development/assets/patterns/action-callbacks.agent +178 -0
  34. package/skills/agentforce-development/assets/patterns/advanced-input-bindings.agent +141 -0
  35. package/skills/agentforce-development/assets/patterns/bidirectional-routing.agent +156 -0
  36. package/skills/agentforce-development/assets/patterns/critical-input-collection.agent +244 -0
  37. package/skills/agentforce-development/assets/patterns/delegation-routing.agent +89 -0
  38. package/skills/agentforce-development/assets/patterns/lifecycle-events.agent +127 -0
  39. package/skills/agentforce-development/assets/patterns/llm-controlled-actions.agent +184 -0
  40. package/skills/agentforce-development/assets/patterns/multi-step-workflow.agent +282 -0
  41. package/skills/agentforce-development/assets/patterns/open-gate-routing.agent +286 -0
  42. package/skills/agentforce-development/assets/patterns/procedural-instructions.agent +273 -0
  43. package/skills/agentforce-development/assets/patterns/prompt-template-action.agent +188 -0
  44. package/skills/agentforce-development/assets/patterns/system-instruction-overrides.agent +293 -0
  45. package/skills/agentforce-development/assets/prompt-rag-search.agent +131 -0
  46. package/skills/agentforce-development/assets/template-multi-topic.agent +160 -0
  47. package/skills/agentforce-development/assets/template-single-topic.agent +81 -0
  48. package/skills/agentforce-development/assets/verification-gate.agent +208 -0
  49. package/skills/agentforce-development/references/action-prompt-templates.md +164 -0
  50. package/skills/agentforce-development/references/actions-reference.md +592 -0
  51. package/skills/agentforce-development/references/agent-access-guide.md +72 -0
  52. package/skills/agentforce-development/references/agent-design-and-spec-creation.md +1010 -0
  53. package/skills/agentforce-development/references/agent-metadata-and-lifecycle.md +575 -0
  54. package/skills/agentforce-development/references/agent-script-core-language.md +1218 -0
  55. package/skills/agentforce-development/references/agent-topic-map-diagrams.md +323 -0
  56. package/skills/agentforce-development/references/agent-user-setup.md +526 -0
  57. package/skills/agentforce-development/references/agent-validation-and-debugging.md +803 -0
  58. package/skills/agentforce-development/references/known-issues.md +353 -0
  59. package/skills/agentforce-development/references/minimal-examples.md +67 -0
  60. package/skills/agentforce-development/references/production-gotchas.md +279 -0
  61. package/skills/agentforce-development/references/salesforce-cli-for-agents.md +393 -0
  62. package/skills/agentforce-development/references/version-history.md +23 -0
  63. package/skills/generate-permission-set/SKILL.md +174 -0
  64. package/skills/salesforce-custom-application/SKILL.md +1 -2
  65. package/skills/salesforce-custom-field/SKILL.md +0 -4
  66. package/skills/salesforce-custom-tab/SKILL.md +84 -8
  67. package/skills/salesforce-experience-lwr-site/SKILL.md +196 -0
  68. package/skills/salesforce-experience-lwr-site/docs/bootstrap-template-byo-lwr.md +224 -0
  69. package/skills/salesforce-experience-lwr-site/docs/configure-content-brandingSet.md +131 -0
  70. package/skills/salesforce-experience-lwr-site/docs/configure-content-route.md +232 -0
  71. package/skills/salesforce-experience-lwr-site/docs/configure-content-themeLayout.md +141 -0
  72. package/skills/salesforce-experience-lwr-site/docs/configure-content-view.md +233 -0
  73. package/skills/salesforce-experience-lwr-site/docs/configure-guest-sharing-rules.md +42 -0
  74. package/skills/salesforce-experience-lwr-site/docs/handle-component-and-region-ids.md +27 -0
  75. package/skills/salesforce-experience-lwr-site/docs/handle-ui-components.md +215 -0
  76. package/skills/salesforce-flow/SKILL.md +2 -2
  77. package/skills/salesforce-fragment/SKILL.md +85 -10
  78. package/skills/salesforce-lightning-app-build/SKILL.md +102 -10
  79. package/skills/apex-class/SKILL.md +0 -253
  80. package/skills/apex-class/examples/AccountDeduplicationBatch.cls +0 -148
  81. package/skills/apex-class/examples/AccountSelector.cls +0 -193
  82. package/skills/apex-class/examples/AccountService.cls +0 -201
  83. package/skills/apex-class/templates/abstract.cls +0 -128
  84. package/skills/apex-class/templates/batch.cls +0 -125
  85. package/skills/apex-class/templates/domain.cls +0 -102
  86. package/skills/apex-class/templates/dto.cls +0 -108
  87. package/skills/apex-class/templates/exception.cls +0 -51
  88. package/skills/apex-class/templates/interface.cls +0 -25
  89. package/skills/apex-class/templates/queueable.cls +0 -92
  90. package/skills/apex-class/templates/schedulable.cls +0 -75
  91. package/skills/apex-class/templates/selector.cls +0 -92
  92. package/skills/apex-class/templates/service.cls +0 -69
  93. package/skills/apex-class/templates/utility.cls +0 -97
  94. package/skills/apex-test-class/SKILL.md +0 -101
  95. package/skills/apex-test-class/references/assertion-patterns.md +0 -209
  96. package/skills/apex-test-class/references/async-testing.md +0 -276
  97. package/skills/apex-test-class/references/mocking-patterns.md +0 -219
  98. package/skills/apex-test-class/references/test-data-factory.md +0 -176
  99. package/skills/deployment-readiness-check/SKILL.md +0 -257
  100. package/skills/deployment-readiness-check/assets/deployment_checklist.md +0 -286
  101. package/skills/deployment-readiness-check/references/rollback_procedures.md +0 -308
  102. package/skills/deployment-readiness-check/scripts/check_metadata.sh +0 -207
  103. package/skills/salesforce-experience-site/SKILL.md +0 -178
@@ -0,0 +1,592 @@
1
+ # Actions Reference
2
+
3
+ Complete guide to Agent Actions in Agentforce: Flow, Apex, API actions, and escalation routing.
4
+
5
+ ---
6
+
7
+ ## Action Properties Reference
8
+
9
+ All actions in Agent Script support these properties:
10
+
11
+ ### Action Definition Properties
12
+
13
+ | Property | Type | Required | Description |
14
+ |----------|------|----------|-------------|
15
+ | `target` | String | Yes | Executable target (see Action Target Types below) |
16
+ | `description` | String | Yes | Explains behavior for LLM decision-making |
17
+ | `label` | String | No | Display name in UI; auto-generated from action name if omitted |
18
+ | `inputs` | Object | No | Input parameters and requirements |
19
+ | `outputs` | Object | No | Return parameters |
20
+ | `available_when` | Expression | No | Conditional availability for the LLM |
21
+ | `require_user_confirmation` | Boolean | No | Ask user to confirm before execution; defaults to `False` |
22
+ | `include_in_progress_indicator` | Boolean | No | Show progress indicator during execution; defaults to `False` |
23
+ | `progress_indicator_message` | String | No | Custom message shown during execution (e.g., "Processing your request...") |
24
+
25
+ > **Note**: `label`, `require_user_confirmation`, `include_in_progress_indicator`, and `progress_indicator_message` are valid on action definitions with `target:` but NOT on `@utils.transition` utility actions.
26
+
27
+ ### Input Properties
28
+
29
+ | Property | Type | Description |
30
+ |----------|------|-------------|
31
+ | `description` | String | Explains the input parameter to LLM; auto-generated from field name if omitted |
32
+ | `label` | String | Display name in UI; auto-generated from field name if omitted |
33
+ | `is_required` | Boolean | Marks input as mandatory for the LLM; defaults to `False` |
34
+ | `is_user_input` | Boolean | LLM extracts value from conversation context; defaults to `False` |
35
+ | `complex_data_type_name` | String | Lightning data type mapping (required for complex types) |
36
+
37
+ ### Output Properties
38
+
39
+ | Property | Type | Description |
40
+ |----------|------|-------------|
41
+ | `description` | String | Explains the output parameter to LLM; auto-generated from field name if omitted |
42
+ | `label` | String | Display name in UI; auto-generated from field name if omitted |
43
+ | `filter_from_agent` | Boolean | `True` = exclude output from agent context; defaults to `False` |
44
+ | `is_used_by_planner` | Boolean | `True` = LLM can reason about this value for routing decisions; defaults to `False` |
45
+ | `complex_data_type_name` | String | Lightning data type mapping (required for complex types) |
46
+
47
+ ### Example with All Properties
48
+
49
+ ```agentscript
50
+ actions:
51
+ process_payment:
52
+ description: "Processes payment for the order"
53
+ require_user_confirmation: True # Ask user before executing
54
+ include_in_progress_indicator: True
55
+ inputs:
56
+ amount: number
57
+ description: "Payment amount"
58
+ card_token: string
59
+ description: "Tokenized card number"
60
+ outputs:
61
+ transaction_id: string
62
+ description: "Transaction reference"
63
+ card_last_four: string
64
+ description: "Last 4 digits of card"
65
+ filter_from_agent: True # Hide from LLM context
66
+ target: "flow://Process_Payment"
67
+ available_when: @variables.cart_total > 0
68
+ ```
69
+
70
+ ---
71
+
72
+ ## Action Target Types (Complete Reference)
73
+
74
+ AgentScript supports the following action types. Use the correct protocol for your integration.
75
+
76
+ | Short Name | Long Name | Description | Use Case |
77
+ |------------|-----------|-------------|----------|
78
+ | `apex` | `apex` | Apex Class | Custom business logic; requires `@InvocableMethod` |
79
+ | `prompt` | `generatePromptResponse` | Prompt Template | AI-generated responses |
80
+ | `flow` | `flow` | Salesforce Flow | Custom business logic; Must be Autolaunched |
81
+ | `standardInvocableAction` | `standardInvocableAction` | Built-in Salesforce actions | Send email, create task, etc. |
82
+ | `externalService` | `externalService` | External API via OpenAPI schema | External system calls |
83
+ | `quickAction` | `quickAction` | Object-specific quick actions | Log call, create related record |
84
+ | `api` | `api` | REST API calls | Direct API invocation |
85
+ | `apexRest` | `apexRest` | Custom REST endpoints | Custom @RestResource classes |
86
+ | `serviceCatalog` | `createCatalogItemRequest` | Service Catalog | Service catalog requests |
87
+ | `integrationProcedureAction` | `executeIntegrationProcedure` | OmniStudio Integration | Industry Cloud procedures |
88
+ | `expressionSet` | `runExpressionSet` | Expression calculations | Decision matrix, calculations |
89
+ | `cdpMlPrediction` | `cdpMlPrediction` | CDP ML predictions | Data Cloud predictions |
90
+ | `externalConnector` | `externalConnector` | External system connector | Pre-built connectors |
91
+ | `slack` | `slack` | Slack integration | Slack messaging |
92
+ | `namedQuery` | `namedQuery` | Predefined queries | Saved SOQL queries |
93
+ | `auraEnabled` | `auraEnabled` | Lightning component methods | @AuraEnabled Apex methods |
94
+ | `mcpTool` | `mcpTool` | Model Context Protocol | MCP tool integrations |
95
+ | `retriever` | `retriever` | Knowledge retrieval | RAG/knowledge base queries |
96
+
97
+ **Target Format**: `<type>://<DeveloperName>` (e.g., `apex://GetAccountInfo`, `prompt://Send_Email`)
98
+
99
+ **Common Examples:**
100
+ ```agentscript
101
+ # Apex action
102
+ target: "apex://CustomerServiceController"
103
+
104
+ # Flow action
105
+ target: "flow://Get_Customer_Orders"
106
+
107
+ # Prompt template
108
+ target: "generatePromptResponse://Email_Draft_Template"
109
+
110
+ # Standard invocable action (built-in Salesforce)
111
+ target: "standardInvocableAction://sendEmail"
112
+
113
+ # External service (API call)
114
+ target: "externalService://Stripe_Payment_API"
115
+ ```
116
+
117
+ ---
118
+
119
+ ## Action Invocation Methods
120
+
121
+ Agent Script provides two ways to invoke actions:
122
+
123
+ - **Actions Block** (`actions:` in `reasoning:`) — LLM chooses which to execute
124
+ - **Deterministic** (`run @actions.name`) — always executes when code path is reached
125
+
126
+ ### Invoking Actions with `actions` Blocks
127
+
128
+ The LLM automatically selects appropriate actions from those defined in the `reasoning.actions` block:
129
+
130
+ ```agentscript
131
+ topic order_management:
132
+ description: "Handles order inquiries"
133
+
134
+ reasoning:
135
+ instructions: ->
136
+ | Help the customer with their order.
137
+ | When they ask about an order, look it up.
138
+ actions:
139
+ # LLM automatically selects this when appropriate
140
+ lookup: @actions.get_order
141
+ with order_id=...
142
+ set @variables.order_status = @outputs.status
143
+
144
+ actions:
145
+ get_order:
146
+ description: "Retrieves order information"
147
+ inputs:
148
+ order_id: string
149
+ description: "The order ID"
150
+ outputs:
151
+ status: string
152
+ description: "Order status"
153
+ target: "flow://Get_Order_Details"
154
+ ```
155
+
156
+ You can also reference action definitions inside `instructions:` using `{!@actions.name}` interpolation. This gives the LLM richer context about available actions.
157
+
158
+ ```agentscript
159
+ reasoning:
160
+ instructions: ->
161
+ | To look up an order, use {!@actions.get_order}.
162
+ | To check shipping status, use {!@actions.track_shipment}.
163
+ ```
164
+
165
+ > See [action-patterns.md](action-patterns.md#2-instruction-action-references) for detailed usage patterns and examples.
166
+
167
+ ### Invoking Actions Deterministically with `run`
168
+
169
+ The `run` keyword is only supported in `reasoning.actions:` post-action blocks and `instructions: ->` blocks.
170
+
171
+ ```agentscript
172
+ # ❌ DOES NOT WORK — run in before_reasoning (no LLM context)
173
+ before_reasoning:
174
+ run @actions.log_turn # May not execute as expected
175
+
176
+ # ✅ WORKS — run in reasoning.actions post-action block
177
+ create: @actions.create_order
178
+ with customer_id = @variables.customer_id
179
+ run @actions.send_confirmation
180
+ set @variables.order_id = @outputs.id
181
+
182
+ # ✅ WORKS — run in instructions: -> block
183
+ reasoning:
184
+ instructions: ->
185
+ run @actions.load_customer
186
+ with id = @variables.customer_id
187
+ set @variables.name = @outputs.name
188
+ ```
189
+
190
+ ---
191
+
192
+ ## Action Type 1: Flow Actions
193
+
194
+ ### When to Use
195
+
196
+ - Standard Salesforce data operations (CRUD)
197
+ - Business logic that can be expressed in Flow
198
+ - Screen flows for guided user experiences
199
+ - Approval processes
200
+
201
+ ### Implementation
202
+
203
+ ```yaml
204
+ actions:
205
+ create_case:
206
+ description: "Creates a new support case for the customer"
207
+ inputs:
208
+ subject:
209
+ type: string
210
+ description: "Case subject line"
211
+ description:
212
+ type: string
213
+ description: "Detailed case description"
214
+ priority:
215
+ type: string
216
+ description: "Case priority (Low, Medium, High, Urgent)"
217
+ outputs:
218
+ caseNumber:
219
+ type: string
220
+ description: "Created case number"
221
+ caseId:
222
+ type: string
223
+ description: "Case record ID"
224
+ target: "flow://Create_Support_Case"
225
+ ```
226
+
227
+ ### Flow Requirements
228
+
229
+ For an action to work with agents, the Flow must:
230
+
231
+ 1. **Be Autolaunched** — `processType: AutoLaunchedFlow`
232
+ 2. **Have Input Variables** — Marked as `isInput: true`
233
+ 3. **Have Output Variables** — Marked as `isOutput: true`
234
+ 4. **Be Active** — `status: Active`
235
+
236
+ **Flow Variable Example:**
237
+ ```xml
238
+ <variables>
239
+ <name>subject</name>
240
+ <dataType>String</dataType>
241
+ <isCollection>false</isCollection>
242
+ <isInput>true</isInput>
243
+ <isOutput>false</isOutput>
244
+ </variables>
245
+ ```
246
+
247
+ ### Best Practices
248
+
249
+ | Practice | Description |
250
+ |----------|-------------|
251
+ | Descriptive names | Use clear Flow API names that describe the action |
252
+ | Error handling | Include fault paths in your Flow |
253
+ | Bulkification | Design Flows to handle multiple records |
254
+ | Governor limits | Avoid SOQL/DML in loops |
255
+
256
+ ---
257
+
258
+ ## Action Type 2: Apex Actions
259
+
260
+ ### When to Use
261
+
262
+ - Complex calculations or algorithms
263
+ - Custom integrations requiring Apex
264
+ - Operations not possible in Flow
265
+ - Bulk data processing
266
+ - When you need full control over execution
267
+
268
+ #### Step 1: Create Apex Class with @InvocableMethod
269
+
270
+ > ⚠️ **An Apex class can only have ONE `@InvocableMethod`.** If you need multiple actions, create separate classes — one per action.
271
+
272
+ ```apex
273
+ public with sharing class CalculateDiscountAction {
274
+
275
+ // ─── REQUEST WRAPPER ──────────────────────────────────────────
276
+ // Each @InvocableVariable field name becomes an action input
277
+ // name in the .agent file. Must match character-for-character.
278
+
279
+ public class DiscountRequest {
280
+ @InvocableVariable(
281
+ label='Order Amount'
282
+ description='Total order amount before discount'
283
+ required=true
284
+ )
285
+ public Decimal orderAmount;
286
+
287
+ @InvocableVariable(
288
+ label='Customer Tier'
289
+ description='Customer membership tier (Bronze, Silver, Gold, Platinum)'
290
+ required=true
291
+ )
292
+ public String customerTier;
293
+ }
294
+
295
+ // ─── RESULT WRAPPER ───────────────────────────────────────────
296
+ // Each @InvocableVariable field name becomes an action output
297
+ // name in the .agent file. Must match character-for-character.
298
+
299
+ public class DiscountResult {
300
+ @InvocableVariable(
301
+ label='Discount Percentage'
302
+ description='Applied discount percentage'
303
+ )
304
+ public Decimal discountPercentage;
305
+
306
+ @InvocableVariable(
307
+ label='Final Amount'
308
+ description='Final order amount after discount'
309
+ )
310
+ public Decimal finalAmount;
311
+ }
312
+
313
+ @InvocableMethod(
314
+ label='Calculate Discount'
315
+ description='Calculates discount based on order amount and customer tier'
316
+ )
317
+ public static List<DiscountResult> calculateDiscount(List<DiscountRequest> requests) {
318
+ List<DiscountResult> results = new List<DiscountResult>();
319
+ for (DiscountRequest req : requests) {
320
+ DiscountResult result = new DiscountResult();
321
+ result.discountPercentage = getTierDiscount(req.customerTier);
322
+ result.finalAmount = req.orderAmount * (1 - result.discountPercentage / 100);
323
+ results.add(result);
324
+ }
325
+ return results;
326
+ }
327
+
328
+ private static Decimal getTierDiscount(String tier) {
329
+ Map<String, Decimal> tierDiscounts = new Map<String, Decimal>{
330
+ 'Bronze' => 5, 'Silver' => 10, 'Gold' => 15, 'Platinum' => 20
331
+ };
332
+ return tierDiscounts.containsKey(tier) ? tierDiscounts.get(tier) : 0;
333
+ }
334
+ }
335
+ ```
336
+
337
+ #### Step 2: Reference DIRECTLY in Agent Script via `apex://`
338
+
339
+ ```yaml
340
+ topic discount_calculator:
341
+ description: "Calculates discount for customer order"
342
+
343
+ # Level 1: Action DEFINITION with target
344
+ actions:
345
+ calculate_discount:
346
+ description: "Calculates discount based on order amount and customer tier"
347
+ inputs:
348
+ orderAmount: number
349
+ description: "The total order amount before discount"
350
+ customerTier: string
351
+ description: "Customer membership tier"
352
+ outputs:
353
+ discountPercentage: number
354
+ description: "Applied discount percentage"
355
+ finalAmount: number
356
+ description: "Final order amount after discount"
357
+ target: "apex://CalculateDiscountAction"
358
+
359
+ reasoning:
360
+ instructions: |
361
+ Help the customer calculate their discount.
362
+ # Level 2: Action INVOCATION referencing the Level 1 definition
363
+ actions:
364
+ calc: @actions.calculate_discount
365
+ with orderAmount=...
366
+ with customerTier=@variables.tier
367
+ set @variables.final_amount = @outputs.finalAmount
368
+ ```
369
+
370
+ #### I/O Name Matching Rules
371
+
372
+ Action `inputs:` and `outputs:` names in Agent Script must **exactly match** the `@InvocableVariable` field names in the Apex class:
373
+
374
+ ```agentscript
375
+ # Given this Apex field:
376
+ # @InvocableVariable
377
+ # public Decimal orderAmount;
378
+
379
+ # ❌ WRONG — snake_case doesn't match camelCase field name
380
+ inputs:
381
+ order_amount: number
382
+
383
+ # ❌ WRONG — different name entirely
384
+ inputs:
385
+ amount: number
386
+
387
+ # ✅ CORRECT — exact match to Apex field name
388
+ inputs:
389
+ orderAmount: number
390
+ ```
391
+
392
+ > **Partial Output Pattern**: You can declare a **subset** of the target's outputs in your action definition — you don't need to map every output parameter. This is useful when you only need one field from a multi-output action.
393
+
394
+ #### Bare @InvocableMethod Pattern (NOT Compatible)
395
+
396
+ Apex classes using bare `List<String>` parameters without `@InvocableVariable` wrapper classes are **incompatible** with Agent Script. The framework cannot discover bindable parameter names without `@InvocableVariable` annotations.
397
+
398
+ ```apex
399
+ // ❌ WRONG — bare parameters, no wrappers (Agent Script cannot bind inputs/outputs)
400
+ public class BareAction {
401
+ @InvocableMethod(label='Bare Action')
402
+ public static List<String> execute(List<String> inputs) {
403
+ return inputs;
404
+ }
405
+ }
406
+
407
+ // ✅ CORRECT — wrapper classes with @InvocableVariable
408
+ public class WrappedAction {
409
+ public class Request {
410
+ @InvocableVariable(
411
+ label='Input Text'
412
+ description='Text to process'
413
+ required=true
414
+ )
415
+ public String inputText;
416
+ }
417
+ public class Response {
418
+ @InvocableVariable(
419
+ label='Output Text'
420
+ description='Processed result'
421
+ )
422
+ public String outputText;
423
+ }
424
+ @InvocableMethod(label='Wrapped Action')
425
+ public static List<Response> execute(List<Request> requests) { ... }
426
+ }
427
+ ```
428
+
429
+ > ⚠️ **Namespace Warning (Unresolved)**: In namespaced packages, `apex://ClassName` may fail at publish time with "invocable action does not exist," even when the Apex class is confirmed deployed via SOQL. It is unclear whether namespace prefix syntax is required (e.g., `apex://ns__ClassName`). If you encounter this in a namespaced org, try: (1) `apex://ns__ClassName` format, (2) wrapping the Apex in a Flow and using `flow://` instead. See [known-issues.md](known-issues.md#issue-2-sf-agent-publish-fails-with-namespace-prefix-on-apex-targets) for tracking.
430
+
431
+ ---
432
+
433
+ ## Action Type 3: API Actions (External System Integration)
434
+
435
+ ### Architecture
436
+
437
+ ```
438
+ ┌─────────────────────────────────────────────────────────────┐
439
+ │ API ACTION ARCHITECTURE │
440
+ ├─────────────────────────────────────────────────────────────┤
441
+ │ Agent Script │
442
+ │ │ │
443
+ │ ▼ │
444
+ │ flow://HTTP_Callout_Flow │
445
+ │ │ │
446
+ │ ▼ │
447
+ │ HTTP Callout Action (in Flow) │
448
+ │ │ │
449
+ │ ▼ │
450
+ │ Named Credential (Authentication) │
451
+ │ │ │
452
+ │ ▼ │
453
+ │ External API │
454
+ └─────────────────────────────────────────────────────────────┘
455
+ ```
456
+
457
+ ### Implementation Steps
458
+
459
+ 1. **Create Named Credential** (via sf-integration skill)
460
+ 2. **Create HTTP Callout Flow** wrapping the external call
461
+ 3. **Reference Flow in Agent Script** with `flow://` target
462
+
463
+ ### Security Considerations
464
+
465
+ | Consideration | Implementation |
466
+ |---------------|----------------|
467
+ | Authentication | Always use Named Credentials (never hardcode secrets) |
468
+ | Permissions | Use Permission Sets to grant Named Principal access |
469
+ | Error handling | Implement fault paths in Flow |
470
+ | Logging | Log callout details for debugging |
471
+ | Timeouts | Set appropriate timeout values |
472
+
473
+ ---
474
+
475
+ ## Connection Block (Escalation Routing)
476
+
477
+ The `connection` block enables escalation to human agents via Omni-Channel. Always use `connection messaging:` (singular).
478
+
479
+ ### Basic Syntax
480
+
481
+ ```agentscript
482
+ # ❌ WRONG — plural wrapper block (invalid syntax)
483
+ connections:
484
+ messaging:
485
+ escalation_message: "Transferring you to a human agent..."
486
+ outbound_route_type: "OmniChannelFlow"
487
+ outbound_route_name: "flow://Support_Queue_Flow"
488
+
489
+ # ✅ CORRECT — singular with channel type
490
+ connection messaging:
491
+ outbound_route_type: "OmniChannelFlow"
492
+ outbound_route_name: "flow://Support_Queue_Flow"
493
+ escalation_message: "Transferring you to a human agent..."
494
+ adaptive_response_allowed: True
495
+ ```
496
+
497
+ ### Multiple Channels
498
+
499
+ Each channel gets its own top-level `connection <channel>:` block:
500
+
501
+ ```agentscript
502
+ connection messaging:
503
+ escalation_message: "Transferring to messaging agent..."
504
+ outbound_route_type: "OmniChannelFlow"
505
+ outbound_route_name: "flow://Agent_Support_Flow"
506
+ adaptive_response_allowed: True
507
+ ```
508
+
509
+ ### Connection Block Properties
510
+
511
+ | Property | Type | Required | Description |
512
+ |----------|------|----------|-------------|
513
+ | `outbound_route_type` | String | Yes | `"OmniChannelFlow"` is the only validated value. |
514
+ | `outbound_route_name` | String | Yes | API name of Omni-Channel Flow (must exist in org) |
515
+ | `escalation_message` | String | Yes | Message shown to user during transfer |
516
+ | `adaptive_response_allowed` | Boolean | No | Allow agent to adapt responses during escalation (default: False) |
517
+
518
+ ### Supported Channels
519
+
520
+ | Channel | Description | Use Case |
521
+ |---------|-------------|----------|
522
+ | `messaging` | Chat/messaging channels | Enhanced Chat, Web Chat, In-App |
523
+ | `telephony` | Voice/phone channels | Service Cloud Voice, phone support |
524
+
525
+ **CRITICAL**: Values like `"queue"`, `"skill"`, `"agent"` for `outbound_route_type` cause validation errors!
526
+
527
+ ### Escalation Action
528
+
529
+ ```agentscript
530
+ actions:
531
+ transfer_to_human: @utils.escalate
532
+ description: "Transfer to human agent"
533
+ ```
534
+
535
+ ### Prerequisites for Escalation
536
+
537
+ 1. Omni-Channel configured in Salesforce
538
+ 2. Omni-Channel Flow created and deployed
539
+ 3. Connection block in agent script
540
+ 4. Messaging channel active (Enhanced Chat, etc.)
541
+
542
+ ---
543
+
544
+ ## Cross-Skill Integration
545
+
546
+ ### Orchestration Order for API Actions
547
+
548
+ When building agents with external API integrations, follow this order:
549
+
550
+ ```
551
+ ┌──────────────────────────────────────────────────────────────┐
552
+ │ INTEGRATION + AGENTFORCE ORCHESTRATION ORDER │
553
+ ├──────────────────────────────────────────────────────────────┤
554
+ │ 1. sf-connected-apps → Connected App (if OAuth needed) │
555
+ │ 2. sf-integration → Named Credential + External Service │
556
+ │ 3. sf-apex → @InvocableMethod (if custom logic) │
557
+ │ 4. sf-flow → Flow wrapper (HTTP Callout / Apex) │
558
+ │ 5. sf-deploy → Deploy all metadata to org │
559
+ │ 6. sf-ai-agentscript → Agent with flow:// target │
560
+ │ 7. sf-deploy → Publish (sf agent publish │
561
+ │ authoring-bundle) │
562
+ └──────────────────────────────────────────────────────────────┘
563
+ ```
564
+
565
+ ---
566
+
567
+ ## Troubleshooting
568
+
569
+ | Issue | Cause | Solution |
570
+ |-------|-------|----------|
571
+ | `Tool target 'X' is not an action definition` | Action not defined in topic `actions:` block, or target doesn't exist in org | Define action with `target:` in topic-level `actions:` block; ensure Apex class/Flow is deployed |
572
+ | `invalid input 'X'` or `invalid output 'X'` | I/O name doesn't match `@InvocableVariable` field name in Apex | Use exact field names from the Apex wrapper class (case-sensitive) |
573
+ | `Internal Error` with inputs-only action | Action has `inputs:` but no `outputs:` block | Add `outputs:` block — the server-side compiler requires it (see known-issues.md Issue 15) |
574
+ | `Internal Error` with bare @InvocableMethod | Apex uses `List<String>` without `@InvocableVariable` wrappers | Refactor Apex to use wrapper classes with `@InvocableVariable` annotations |
575
+ | `apex://` target not found | Apex class not deployed or missing `@InvocableMethod` | Deploy class first, ensure it has `@InvocableMethod` annotation |
576
+ | Flow action fails | Flow not active or not Autolaunched | Activate the Flow; ensure it's Autolaunched (not Screen) |
577
+ | API action timeout | External system slow | Increase timeout, add retry logic |
578
+ | Permission denied | Missing Named Principal access | Grant Permission Set |
579
+
580
+ ### Debugging Tips
581
+
582
+ 1. **Check deployment status:** `sf project deploy report`
583
+ 2. **Test Flow independently:** Use Flow debugger in Setup with sample inputs
584
+ 3. **Check agent logs:** Agent Builder → Logs
585
+
586
+ ---
587
+
588
+ ## Related Documentation
589
+
590
+ - [action-patterns.md](action-patterns.md) — Context-aware descriptions, instruction references, binding strategies
591
+ - [action-prompt-templates.md](action-prompt-templates.md) — Prompt template invocation (`generatePromptResponse://`)
592
+ - [fsm-architecture.md](fsm-architecture.md) — FSM design and node patterns
@@ -0,0 +1,72 @@
1
+ # Agent Access Permissions & Visibility Troubleshooting
2
+
3
+ How to make a published agent visible to end users in the Lightning Experience Copilot panel.
4
+
5
+ ---
6
+
7
+ ## Agent Access Permissions
8
+
9
+ Employee Agents require explicit access via the `<agentAccesses>` element in Permission Sets. Without this, users won't see the agent in the Lightning Experience Copilot panel.
10
+
11
+ ### Permission Set XML Structure
12
+
13
+ ```xml
14
+ <?xml version="1.0" encoding="UTF-8"?>
15
+ <PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
16
+ <agentAccesses>
17
+ <agentName>Case_Assist</agentName>
18
+ <enabled>true</enabled>
19
+ </agentAccesses>
20
+ <hasActivationRequired>false</hasActivationRequired>
21
+ <label>Case Assist Agent Access</label>
22
+ </PermissionSet>
23
+ ```
24
+
25
+ ### Key Points
26
+
27
+ - `<agentName>` must exactly match the `developer_name` in the agent's config block
28
+ - Multiple `<agentAccesses>` elements can be included for multiple agents
29
+ - `<enabled>true</enabled>` grants access; `false` or omission denies access
30
+
31
+ ### Deploy and Assign
32
+
33
+ Deploy the permission set with `sf project deploy start --json --metadata "PermissionSet:<PermissionSetName>"`. Assign it to a specific user with `sf org assign permset --json --name <PermissionSetName> --on-behalf-of user@example.com`.
34
+
35
+ ---
36
+
37
+ ## Visibility Troubleshooting
38
+
39
+ When an Agentforce Employee Agent is deployed but not visible to users, work through these steps:
40
+
41
+ ### Step 1: Verify Agent Status
42
+
43
+ Confirm the agent is active. Query `BotVersion` to check: `sf data query --json -q "SELECT Status, VersionNumber FROM BotVersion WHERE BotDefinition.DeveloperName = '<developer_name>'"`. At least one version should have `Status = 'Active'`. If none do, activate with `sf agent activate --json --api-name <developer_name>` before continuing.
44
+
45
+ ### Step 2: Check for Agent Access Permission
46
+
47
+ Retrieve permission sets with `sf project retrieve start --json --metadata "PermissionSet:*"`. Search retrieved files for `<agentAccesses>` containing agent's `developer_name`. If none, create a new permission set.
48
+
49
+ ### Step 3: Create Permission Set (if needed)
50
+
51
+ Create a file at `force-app/main/default/permissionsets/MyAgent_Access.permissionset-meta.xml`:
52
+
53
+ ```xml
54
+ <?xml version="1.0" encoding="UTF-8"?>
55
+ <PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
56
+ <agentAccesses>
57
+ <agentName>MyAgent</agentName>
58
+ <enabled>true</enabled>
59
+ </agentAccesses>
60
+ <hasActivationRequired>false</hasActivationRequired>
61
+ <label>MyAgent Access</label>
62
+ </PermissionSet>
63
+ ```
64
+
65
+ ### Common Issues
66
+
67
+ | Symptom | Cause | Solution |
68
+ |---------|-------|----------|
69
+ | No Agentforce icon | CopilotSalesforceUser PS not assigned | Assign CopilotSalesforceUser permission set |
70
+ | Icon visible, agent not in list | Missing agentAccesses | Add `<agentAccesses>` to permission set |
71
+ | Agent visible, errors on open | Agent not fully published | See Step 1: Verify Agent Status |
72
+ | "Agent not found" error | Name mismatch | Ensure `<agentName>` matches `developer_name` exactly |