@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.
- package/package.json +4 -4
- package/skills/agentforce-development/SKILL.md +427 -0
- package/skills/agentforce-development/assets/README-legacy.md +89 -0
- package/skills/agentforce-development/assets/agent-spec-template.md +90 -0
- package/skills/agentforce-development/assets/agents/README.md +45 -0
- package/skills/agentforce-development/assets/agents/hello-world.agent +60 -0
- package/skills/agentforce-development/assets/agents/multi-topic.agent +105 -0
- package/skills/agentforce-development/assets/agents/production-faq.agent +101 -0
- package/skills/agentforce-development/assets/agents/production-faq.bundle-meta.xml +4 -0
- package/skills/agentforce-development/assets/agents/simple-qa.agent +72 -0
- package/skills/agentforce-development/assets/apex/models-api-queueable.cls +225 -0
- package/skills/agentforce-development/assets/bundle-meta.xml +23 -0
- package/skills/agentforce-development/assets/components/apex-action.agent +52 -0
- package/skills/agentforce-development/assets/components/error-handling.agent +58 -0
- package/skills/agentforce-development/assets/components/escalation-setup.agent +169 -0
- package/skills/agentforce-development/assets/components/flow-action.agent +66 -0
- package/skills/agentforce-development/assets/components/n-ary-conditions.agent +110 -0
- package/skills/agentforce-development/assets/components/topic-with-actions.agent +40 -0
- package/skills/agentforce-development/assets/deterministic-routing.agent +166 -0
- package/skills/agentforce-development/assets/escalation-pattern.agent +209 -0
- package/skills/agentforce-development/assets/flow-action-lookup.agent +115 -0
- package/skills/agentforce-development/assets/hub-and-spoke.agent +104 -0
- package/skills/agentforce-development/assets/invocable-apex-template.cls +187 -0
- package/skills/agentforce-development/assets/local-info-agent-annotated.agent +355 -0
- package/skills/agentforce-development/assets/metadata/basic-prompt-template.promptTemplate-meta.xml +109 -0
- package/skills/agentforce-development/assets/metadata/genai-function-apex.xml +92 -0
- package/skills/agentforce-development/assets/metadata/genai-function-flow.xml +57 -0
- package/skills/agentforce-development/assets/metadata/genai-plugin.xml +72 -0
- package/skills/agentforce-development/assets/metadata/http-callout-flow.flow-meta.xml +348 -0
- package/skills/agentforce-development/assets/metadata/record-grounded-prompt.promptTemplate-meta.xml +136 -0
- package/skills/agentforce-development/assets/minimal-starter.agent +42 -0
- package/skills/agentforce-development/assets/patterns/README.md +254 -0
- package/skills/agentforce-development/assets/patterns/action-callbacks.agent +178 -0
- package/skills/agentforce-development/assets/patterns/advanced-input-bindings.agent +141 -0
- package/skills/agentforce-development/assets/patterns/bidirectional-routing.agent +156 -0
- package/skills/agentforce-development/assets/patterns/critical-input-collection.agent +244 -0
- package/skills/agentforce-development/assets/patterns/delegation-routing.agent +89 -0
- package/skills/agentforce-development/assets/patterns/lifecycle-events.agent +127 -0
- package/skills/agentforce-development/assets/patterns/llm-controlled-actions.agent +184 -0
- package/skills/agentforce-development/assets/patterns/multi-step-workflow.agent +282 -0
- package/skills/agentforce-development/assets/patterns/open-gate-routing.agent +286 -0
- package/skills/agentforce-development/assets/patterns/procedural-instructions.agent +273 -0
- package/skills/agentforce-development/assets/patterns/prompt-template-action.agent +188 -0
- package/skills/agentforce-development/assets/patterns/system-instruction-overrides.agent +293 -0
- package/skills/agentforce-development/assets/prompt-rag-search.agent +131 -0
- package/skills/agentforce-development/assets/template-multi-topic.agent +160 -0
- package/skills/agentforce-development/assets/template-single-topic.agent +81 -0
- package/skills/agentforce-development/assets/verification-gate.agent +208 -0
- package/skills/agentforce-development/references/action-prompt-templates.md +164 -0
- package/skills/agentforce-development/references/actions-reference.md +592 -0
- package/skills/agentforce-development/references/agent-access-guide.md +72 -0
- package/skills/agentforce-development/references/agent-design-and-spec-creation.md +1010 -0
- package/skills/agentforce-development/references/agent-metadata-and-lifecycle.md +575 -0
- package/skills/agentforce-development/references/agent-script-core-language.md +1218 -0
- package/skills/agentforce-development/references/agent-topic-map-diagrams.md +323 -0
- package/skills/agentforce-development/references/agent-user-setup.md +526 -0
- package/skills/agentforce-development/references/agent-validation-and-debugging.md +803 -0
- package/skills/agentforce-development/references/known-issues.md +353 -0
- package/skills/agentforce-development/references/minimal-examples.md +67 -0
- package/skills/agentforce-development/references/production-gotchas.md +279 -0
- package/skills/agentforce-development/references/salesforce-cli-for-agents.md +393 -0
- package/skills/agentforce-development/references/version-history.md +23 -0
- package/skills/generate-permission-set/SKILL.md +174 -0
- package/skills/salesforce-custom-application/SKILL.md +1 -2
- package/skills/salesforce-custom-field/SKILL.md +0 -4
- package/skills/salesforce-custom-tab/SKILL.md +84 -8
- package/skills/salesforce-experience-lwr-site/SKILL.md +196 -0
- package/skills/salesforce-experience-lwr-site/docs/bootstrap-template-byo-lwr.md +224 -0
- package/skills/salesforce-experience-lwr-site/docs/configure-content-brandingSet.md +131 -0
- package/skills/salesforce-experience-lwr-site/docs/configure-content-route.md +232 -0
- package/skills/salesforce-experience-lwr-site/docs/configure-content-themeLayout.md +141 -0
- package/skills/salesforce-experience-lwr-site/docs/configure-content-view.md +233 -0
- package/skills/salesforce-experience-lwr-site/docs/configure-guest-sharing-rules.md +42 -0
- package/skills/salesforce-experience-lwr-site/docs/handle-component-and-region-ids.md +27 -0
- package/skills/salesforce-experience-lwr-site/docs/handle-ui-components.md +215 -0
- package/skills/salesforce-flow/SKILL.md +2 -2
- package/skills/salesforce-fragment/SKILL.md +85 -10
- package/skills/salesforce-lightning-app-build/SKILL.md +102 -10
- package/skills/apex-class/SKILL.md +0 -253
- package/skills/apex-class/examples/AccountDeduplicationBatch.cls +0 -148
- package/skills/apex-class/examples/AccountSelector.cls +0 -193
- package/skills/apex-class/examples/AccountService.cls +0 -201
- package/skills/apex-class/templates/abstract.cls +0 -128
- package/skills/apex-class/templates/batch.cls +0 -125
- package/skills/apex-class/templates/domain.cls +0 -102
- package/skills/apex-class/templates/dto.cls +0 -108
- package/skills/apex-class/templates/exception.cls +0 -51
- package/skills/apex-class/templates/interface.cls +0 -25
- package/skills/apex-class/templates/queueable.cls +0 -92
- package/skills/apex-class/templates/schedulable.cls +0 -75
- package/skills/apex-class/templates/selector.cls +0 -92
- package/skills/apex-class/templates/service.cls +0 -69
- package/skills/apex-class/templates/utility.cls +0 -97
- package/skills/apex-test-class/SKILL.md +0 -101
- package/skills/apex-test-class/references/assertion-patterns.md +0 -209
- package/skills/apex-test-class/references/async-testing.md +0 -276
- package/skills/apex-test-class/references/mocking-patterns.md +0 -219
- package/skills/apex-test-class/references/test-data-factory.md +0 -176
- package/skills/deployment-readiness-check/SKILL.md +0 -257
- package/skills/deployment-readiness-check/assets/deployment_checklist.md +0 -286
- package/skills/deployment-readiness-check/references/rollback_procedures.md +0 -308
- package/skills/deployment-readiness-check/scripts/check_metadata.sh +0 -207
- package/skills/salesforce-experience-site/SKILL.md +0 -178
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
# Agent Script Patterns
|
|
2
|
+
|
|
3
|
+
This folder contains reusable patterns for common Agentforce scenarios.
|
|
4
|
+
|
|
5
|
+
## Pattern Decision Tree
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
What do you need?
|
|
9
|
+
│
|
|
10
|
+
├─► Guaranteed post-action processing?
|
|
11
|
+
│ └─► Use: action-callbacks.agent
|
|
12
|
+
│ (run keyword for deterministic callbacks)
|
|
13
|
+
│
|
|
14
|
+
├─► Setup/cleanup for every reasoning turn?
|
|
15
|
+
│ └─► Use: lifecycle-events.agent
|
|
16
|
+
│ (before_reasoning / after_reasoning blocks)
|
|
17
|
+
│
|
|
18
|
+
├─► Navigate to specialist and return with results?
|
|
19
|
+
│ └─► Use: bidirectional-routing.agent
|
|
20
|
+
│ (store return address, specialist transitions back)
|
|
21
|
+
│
|
|
22
|
+
├─► Complex parameter passing to actions?
|
|
23
|
+
│ └─► Use: advanced-input-bindings.agent
|
|
24
|
+
│ (slot filling, variable binding, output chaining)
|
|
25
|
+
│
|
|
26
|
+
├─► Dynamic behavior based on user context?
|
|
27
|
+
│ └─► Use: system-instruction-overrides.agent
|
|
28
|
+
│ (tier-based, time-based, feature flag instructions)
|
|
29
|
+
│
|
|
30
|
+
├─► Authentication gate with deferred routing?
|
|
31
|
+
│ └─► Use: open-gate-routing.agent
|
|
32
|
+
│ (3-variable state machine with LLM bypass)
|
|
33
|
+
│
|
|
34
|
+
└─► None of the above?
|
|
35
|
+
└─► Start with: ../getting-started/hello-world.agent
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Patterns Overview
|
|
39
|
+
|
|
40
|
+
### 1. [action-callbacks.agent](action-callbacks.agent)
|
|
41
|
+
|
|
42
|
+
**Purpose**: Chain actions with guaranteed execution using `run` keyword.
|
|
43
|
+
|
|
44
|
+
**Use when**:
|
|
45
|
+
- Follow-up actions MUST happen after parent action
|
|
46
|
+
- Audit logging required for compliance
|
|
47
|
+
- Order matters (send email AFTER order created)
|
|
48
|
+
|
|
49
|
+
**Key syntax**:
|
|
50
|
+
```agentscript
|
|
51
|
+
process_order: @actions.create_order
|
|
52
|
+
with customer_id=...
|
|
53
|
+
set @variables.order_id = @outputs.order_id
|
|
54
|
+
run @actions.send_confirmation # Always runs after create_order
|
|
55
|
+
with order_id=@variables.order_id
|
|
56
|
+
run @actions.log_activity # Always runs after confirmation
|
|
57
|
+
with event_type="ORDER_CREATED"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
### 2. [lifecycle-events.agent](lifecycle-events.agent)
|
|
63
|
+
|
|
64
|
+
**Purpose**: Run code before/after every reasoning step automatically.
|
|
65
|
+
|
|
66
|
+
**Use when**:
|
|
67
|
+
- Track conversation metrics (turn count, duration)
|
|
68
|
+
- Refresh context before each response
|
|
69
|
+
- Log analytics after each turn
|
|
70
|
+
- Initialize state on first turn
|
|
71
|
+
|
|
72
|
+
**Key syntax**:
|
|
73
|
+
```agentscript
|
|
74
|
+
topic conversation:
|
|
75
|
+
before_reasoning:
|
|
76
|
+
set @variables.turn_count = @variables.turn_count + 1
|
|
77
|
+
run @actions.refresh_context
|
|
78
|
+
|
|
79
|
+
reasoning:
|
|
80
|
+
instructions: ->
|
|
81
|
+
| This is turn {!@variables.turn_count}
|
|
82
|
+
|
|
83
|
+
after_reasoning:
|
|
84
|
+
run @actions.log_analytics
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### 3. [bidirectional-routing.agent](bidirectional-routing.agent)
|
|
90
|
+
|
|
91
|
+
**Purpose**: Navigate to specialist topic and return with results.
|
|
92
|
+
|
|
93
|
+
**Use when**:
|
|
94
|
+
- Complex workflows spanning multiple topics
|
|
95
|
+
- "Consult an expert" pattern
|
|
96
|
+
- Need to bring results back to coordinator
|
|
97
|
+
- Want separation of concerns
|
|
98
|
+
|
|
99
|
+
**Key syntax**:
|
|
100
|
+
```agentscript
|
|
101
|
+
# In main topic
|
|
102
|
+
consult_pricing: @utils.transition to @topic.pricing_specialist
|
|
103
|
+
|
|
104
|
+
# In specialist topic
|
|
105
|
+
before_reasoning:
|
|
106
|
+
set @variables.return_topic = "main_hub"
|
|
107
|
+
|
|
108
|
+
# ... do specialist work ...
|
|
109
|
+
|
|
110
|
+
return_with_results: @utils.transition to @topic.main_hub
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
### 4. [advanced-input-bindings.agent](advanced-input-bindings.agent)
|
|
116
|
+
|
|
117
|
+
**Purpose**: Master all parameter binding techniques for actions.
|
|
118
|
+
|
|
119
|
+
**Use when**:
|
|
120
|
+
- Learning different ways to pass values to actions
|
|
121
|
+
- Complex multi-input action scenarios
|
|
122
|
+
- Chaining outputs between multiple actions
|
|
123
|
+
- Mixing LLM slot filling with stored state
|
|
124
|
+
|
|
125
|
+
**Key syntax**:
|
|
126
|
+
```agentscript
|
|
127
|
+
reasoning:
|
|
128
|
+
actions:
|
|
129
|
+
# Slot filling: LLM extracts from conversation
|
|
130
|
+
lookup: @actions.get_order
|
|
131
|
+
with order_id=...
|
|
132
|
+
|
|
133
|
+
# Variable binding: Use stored state
|
|
134
|
+
bound: @actions.get_order
|
|
135
|
+
with order_id=@variables.current_order_id
|
|
136
|
+
|
|
137
|
+
# Output chaining: Use previous action's result
|
|
138
|
+
process: @actions.create_order
|
|
139
|
+
with items=...
|
|
140
|
+
set @variables.order_id = @outputs.order_id
|
|
141
|
+
run @actions.send_notification
|
|
142
|
+
with order_id=@outputs.order_id # Chained output
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Binding Pattern Quick Reference**:
|
|
146
|
+
| Pattern | Syntax | When to Use |
|
|
147
|
+
|---------|--------|-------------|
|
|
148
|
+
| Slot Filling | `with x=...` | LLM extracts from conversation |
|
|
149
|
+
| Fixed Value | `with x="value"` | Always use a constant |
|
|
150
|
+
| Variable | `with x=@variables.y` | Use stored state |
|
|
151
|
+
| Output | `with x=@outputs.y` | Chain from previous action |
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
### 5. [system-instruction-overrides.agent](system-instruction-overrides.agent)
|
|
156
|
+
|
|
157
|
+
**Purpose**: Dynamic agent behavior based on context (user tier, time, features).
|
|
158
|
+
|
|
159
|
+
**Use when**:
|
|
160
|
+
- Different behavior for different user segments (VIP vs standard)
|
|
161
|
+
- Time-based changes (business hours vs after hours)
|
|
162
|
+
- Feature flags controlling agent personality
|
|
163
|
+
- A/B testing different conversation styles
|
|
164
|
+
|
|
165
|
+
**Key syntax**:
|
|
166
|
+
```agentscript
|
|
167
|
+
# System block: Static base instructions
|
|
168
|
+
system:
|
|
169
|
+
instructions: "You are a professional agent. Be helpful and courteous."
|
|
170
|
+
|
|
171
|
+
# Topic reasoning: Dynamic overrides
|
|
172
|
+
reasoning:
|
|
173
|
+
instructions: ->
|
|
174
|
+
if @variables.customer_tier == "vip":
|
|
175
|
+
| PRIORITY CUSTOMER - Provide white-glove service.
|
|
176
|
+
| You have authority to offer 20% discounts.
|
|
177
|
+
|
|
178
|
+
if @variables.business_hours == False:
|
|
179
|
+
| We are outside business hours.
|
|
180
|
+
| Complex issues should be logged for follow-up.
|
|
181
|
+
|
|
182
|
+
| Respond to the customer's inquiry.
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Override Strategy**:
|
|
186
|
+
| Layer | Type | Best For |
|
|
187
|
+
|-------|------|----------|
|
|
188
|
+
| `system:` | Static | Guardrails, base personality |
|
|
189
|
+
| `reasoning:` | Dynamic | Personalization, context-aware behavior |
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
### 6. [open-gate-routing.agent](open-gate-routing.agent)
|
|
194
|
+
|
|
195
|
+
**Purpose**: Auth-gated topic routing with LLM bypass using a 3-variable state machine.
|
|
196
|
+
|
|
197
|
+
**Use when**:
|
|
198
|
+
- Multiple protected topics require authentication before access
|
|
199
|
+
- You want zero-credit LLM bypass while a gate topic holds focus
|
|
200
|
+
- Users should be redirected to auth, then automatically returned to their intended topic
|
|
201
|
+
- You need an EXIT_PROTOCOL to release gate state when users change intent
|
|
202
|
+
|
|
203
|
+
**Key syntax**:
|
|
204
|
+
```agentscript
|
|
205
|
+
# topic_selector bypasses LLM when open_gate is set
|
|
206
|
+
before_reasoning:
|
|
207
|
+
if @variables.open_gate == "protected_workflow":
|
|
208
|
+
transition to @topic.protected_workflow
|
|
209
|
+
if @variables.open_gate == "authentication_gate":
|
|
210
|
+
transition to @topic.authentication_gate
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**Credit**: Hua Xu (Salesforce APAC FDE team) — production pattern from Kogan agent deployment.
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## Pattern Combinations
|
|
218
|
+
|
|
219
|
+
These patterns can be combined:
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
lifecycle-events + action-callbacks
|
|
223
|
+
├── before_reasoning: Initialize context
|
|
224
|
+
├── reasoning: Process with callbacks
|
|
225
|
+
│ └── action with run callbacks
|
|
226
|
+
└── after_reasoning: Log results
|
|
227
|
+
|
|
228
|
+
open-gate-routing + lifecycle-events
|
|
229
|
+
├── before_reasoning: Gate check + context refresh
|
|
230
|
+
├── reasoning: Protected actions (if authenticated)
|
|
231
|
+
└── after_reasoning: Post-auth routing + analytics
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Validation Scoring Impact
|
|
235
|
+
|
|
236
|
+
| Pattern | Scoring Boost | Key Requirements |
|
|
237
|
+
|---------|--------------|------------------|
|
|
238
|
+
| Action Callbacks | +5 pts | No nested run |
|
|
239
|
+
| Lifecycle Events | +5 pts | Proper block placement |
|
|
240
|
+
| Bidirectional | +5 pts | Return transitions |
|
|
241
|
+
| Input Bindings | +5 pts | Proper binding patterns |
|
|
242
|
+
| System Overrides | +5 pts | Static system, dynamic topics |
|
|
243
|
+
| Open Gate | +5 pts | 3-variable coordination |
|
|
244
|
+
|
|
245
|
+
## Anti-Patterns to Avoid
|
|
246
|
+
|
|
247
|
+
| ❌ Don't | ✅ Do Instead |
|
|
248
|
+
|----------|---------------|
|
|
249
|
+
| Nested `run` inside `run` | Sequential `run` at same level |
|
|
250
|
+
| Lifecycle in wrong order | before_reasoning, reasoning, after_reasoning |
|
|
251
|
+
| Forget return transition | Always include return action in specialists |
|
|
252
|
+
| Use lifecycle for one-time setup | Use if @variables.turn_count == 1 |
|
|
253
|
+
| Missing EXIT_PROTOCOL in gate pattern | Always include gate reset topic |
|
|
254
|
+
| Hardcoding gate topic name in open_gate | Use variable-driven routing |
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# Action Callbacks Pattern
|
|
2
|
+
# Use the `run` keyword for deterministic post-action processing
|
|
3
|
+
#
|
|
4
|
+
# ★ When To Use This Pattern:
|
|
5
|
+
# - You need guaranteed follow-up after an action completes
|
|
6
|
+
# - Audit logging or notifications must ALWAYS happen
|
|
7
|
+
# - Chain multiple actions where order matters
|
|
8
|
+
#
|
|
9
|
+
# ★ Key Insight:
|
|
10
|
+
# The `run` keyword executes AFTER the parent action completes.
|
|
11
|
+
# This is deterministic (not LLM-decided) - the callback ALWAYS runs.
|
|
12
|
+
# Use this when you can't afford to skip follow-up steps.
|
|
13
|
+
#
|
|
14
|
+
# ★ Validation Impact:
|
|
15
|
+
# - [5 pts] Actions with proper callback structure
|
|
16
|
+
# - Avoid nested run (only 1 level of nesting allowed)
|
|
17
|
+
#
|
|
18
|
+
# This is a PARTIAL template - integrate into a complete agent file
|
|
19
|
+
|
|
20
|
+
topic order_processing:
|
|
21
|
+
label: "Order Processing"
|
|
22
|
+
description: "Processes orders with guaranteed confirmation and logging"
|
|
23
|
+
|
|
24
|
+
actions:
|
|
25
|
+
create_order:
|
|
26
|
+
description: "Creates a new order in the system"
|
|
27
|
+
inputs:
|
|
28
|
+
customer_id: string
|
|
29
|
+
description: "Customer identifier"
|
|
30
|
+
items: list[string]
|
|
31
|
+
description: "List of item SKUs"
|
|
32
|
+
total: number
|
|
33
|
+
description: "Order total amount"
|
|
34
|
+
outputs:
|
|
35
|
+
order_id: string
|
|
36
|
+
description: "Generated order ID"
|
|
37
|
+
status: string
|
|
38
|
+
description: "Order creation status"
|
|
39
|
+
target: "flow://Create_Order"
|
|
40
|
+
|
|
41
|
+
send_confirmation:
|
|
42
|
+
description: "Sends order confirmation email"
|
|
43
|
+
inputs:
|
|
44
|
+
order_id: string
|
|
45
|
+
description: "Order ID to confirm"
|
|
46
|
+
customer_email: string
|
|
47
|
+
description: "Customer email address"
|
|
48
|
+
outputs:
|
|
49
|
+
sent: boolean
|
|
50
|
+
description: "Whether email was sent"
|
|
51
|
+
target: "flow://Send_Order_Confirmation"
|
|
52
|
+
|
|
53
|
+
log_activity:
|
|
54
|
+
description: "Logs activity for audit trail"
|
|
55
|
+
inputs:
|
|
56
|
+
event_type: string
|
|
57
|
+
description: "Type of event to log"
|
|
58
|
+
details: string
|
|
59
|
+
description: "Event details"
|
|
60
|
+
outputs:
|
|
61
|
+
logged: boolean
|
|
62
|
+
description: "Whether log was recorded"
|
|
63
|
+
target: "apex://AuditService.logEvent"
|
|
64
|
+
|
|
65
|
+
reasoning:
|
|
66
|
+
instructions: ->
|
|
67
|
+
| Help the customer place their order.
|
|
68
|
+
| Ensure confirmation is sent after successful orders.
|
|
69
|
+
| All order activities must be logged for compliance.
|
|
70
|
+
actions:
|
|
71
|
+
# This action uses callbacks to guarantee follow-up
|
|
72
|
+
process_order: @actions.create_order
|
|
73
|
+
with customer_id=@variables.customer_id
|
|
74
|
+
with items=...
|
|
75
|
+
with total=...
|
|
76
|
+
set @variables.order_id = @outputs.order_id
|
|
77
|
+
set @variables.order_status = @outputs.status
|
|
78
|
+
# Callback 1: Always send confirmation after order created
|
|
79
|
+
run @actions.send_confirmation
|
|
80
|
+
with order_id=@variables.order_id
|
|
81
|
+
with customer_email=@variables.customer_email
|
|
82
|
+
# Callback 2: Always log the activity
|
|
83
|
+
run @actions.log_activity
|
|
84
|
+
with event_type="ORDER_CREATED"
|
|
85
|
+
with details=@variables.order_id
|
|
86
|
+
|
|
87
|
+
back_to_menu: @utils.transition to @topic.topic_selector
|
|
88
|
+
|
|
89
|
+
# ★ Anti-Pattern: Nested run (DO NOT DO THIS)
|
|
90
|
+
#
|
|
91
|
+
# process: @actions.first
|
|
92
|
+
# run @actions.second
|
|
93
|
+
# run @actions.third # ❌ INVALID - nested run not allowed
|
|
94
|
+
#
|
|
95
|
+
# ★ Correct Pattern: Sequential callbacks (all at same level)
|
|
96
|
+
#
|
|
97
|
+
# process: @actions.first
|
|
98
|
+
# run @actions.second # ✅ First callback
|
|
99
|
+
# run @actions.third # ✅ Second callback (runs after second)
|
|
100
|
+
|
|
101
|
+
# ═══════════════════════════════════════════════════════════════════════════════
|
|
102
|
+
# ★ Pattern 2: Simple Variable Updates (No Callback Needed)
|
|
103
|
+
# ═══════════════════════════════════════════════════════════════════════════════
|
|
104
|
+
#
|
|
105
|
+
# For simple operations like incrementing counters or storing outputs,
|
|
106
|
+
# use `set` statements directly - NO `run` keyword needed.
|
|
107
|
+
#
|
|
108
|
+
# ⚠️ IMPORTANT: This pattern works in BOTH GenAiPlannerBundle AND AiAuthoringBundle
|
|
109
|
+
# The `run` keyword ONLY works in GenAiPlannerBundle (not AiAuthoringBundle)
|
|
110
|
+
# Use `set` statements for AiAuthoringBundle deployments
|
|
111
|
+
#
|
|
112
|
+
# Example: Create case and track count (works in BOTH bundle types)
|
|
113
|
+
|
|
114
|
+
topic case_management:
|
|
115
|
+
label: "Case Management"
|
|
116
|
+
description: "Creates cases and tracks statistics"
|
|
117
|
+
|
|
118
|
+
actions:
|
|
119
|
+
create_case:
|
|
120
|
+
description: "Creates a new support case"
|
|
121
|
+
inputs:
|
|
122
|
+
inp_CustomerId: string
|
|
123
|
+
description: "Contact ID for the case"
|
|
124
|
+
inp_Subject: string
|
|
125
|
+
description: "Subject line for the case"
|
|
126
|
+
outputs:
|
|
127
|
+
out_CaseNumber: string
|
|
128
|
+
description: "Generated case number"
|
|
129
|
+
out_CaseId: string
|
|
130
|
+
description: "Salesforce ID of the created case"
|
|
131
|
+
target: "flow://Create_Case"
|
|
132
|
+
|
|
133
|
+
reasoning:
|
|
134
|
+
instructions: ->
|
|
135
|
+
| Help the customer create support cases.
|
|
136
|
+
| Track case count for session statistics.
|
|
137
|
+
actions:
|
|
138
|
+
# ✅ Simple pattern - just use `set` for variable updates
|
|
139
|
+
create_support_case: @actions.create_case
|
|
140
|
+
with inp_CustomerId=@variables.ContactId
|
|
141
|
+
with inp_Subject=...
|
|
142
|
+
set @variables.case_number = @outputs.out_CaseNumber
|
|
143
|
+
set @variables.case_id = @outputs.out_CaseId
|
|
144
|
+
set @variables.cases_created = @variables.cases_created + 1 # Direct increment!
|
|
145
|
+
|
|
146
|
+
back_to_menu: @utils.transition to @topic.topic_selector
|
|
147
|
+
|
|
148
|
+
# ═══════════════════════════════════════════════════════════════════════════════
|
|
149
|
+
# ⛔ INVALID KEYWORDS - NEVER USE THESE
|
|
150
|
+
# ═══════════════════════════════════════════════════════════════════════════════
|
|
151
|
+
#
|
|
152
|
+
# The following keywords DO NOT EXIST in Agent Script. Using them causes:
|
|
153
|
+
# SyntaxError: Unexpected '[keyword]'
|
|
154
|
+
#
|
|
155
|
+
# ❌ internal_actions - Does not exist (Claude may invent this for "local helpers")
|
|
156
|
+
# ❌ helper_actions - Does not exist
|
|
157
|
+
# ❌ private_actions - Does not exist
|
|
158
|
+
# ❌ local_actions - Does not exist
|
|
159
|
+
#
|
|
160
|
+
# If you need simple variable operations after an action, use `set` directly:
|
|
161
|
+
#
|
|
162
|
+
# ❌ WRONG (internal_actions does not exist):
|
|
163
|
+
#
|
|
164
|
+
# internal_actions:
|
|
165
|
+
# increment_counter:
|
|
166
|
+
# set @variables.count = @variables.count + 1
|
|
167
|
+
#
|
|
168
|
+
# reasoning:
|
|
169
|
+
# actions:
|
|
170
|
+
# process: @actions.create_case
|
|
171
|
+
# run @actions.increment_counter # ❌ Can't reference internal action
|
|
172
|
+
#
|
|
173
|
+
# ✅ CORRECT (use set directly in the action block):
|
|
174
|
+
#
|
|
175
|
+
# reasoning:
|
|
176
|
+
# actions:
|
|
177
|
+
# process: @actions.create_case
|
|
178
|
+
# set @variables.count = @variables.count + 1 # ✅ Direct set works!
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Advanced Input Bindings Pattern
|
|
2
|
+
# Demonstrates all parameter binding techniques for Agent Script actions
|
|
3
|
+
#
|
|
4
|
+
# ★ When To Use This Pattern:
|
|
5
|
+
# - Learning different ways to pass values to actions
|
|
6
|
+
# - Combining LLM slot filling with variable binding
|
|
7
|
+
# - Chaining outputs between multiple actions
|
|
8
|
+
# - Complex multi-input action scenarios
|
|
9
|
+
#
|
|
10
|
+
# ★ Key Insight:
|
|
11
|
+
# - `...` (ellipsis) = LLM extracts value from conversation (slot filling)
|
|
12
|
+
# - `"value"` = Fixed constant value
|
|
13
|
+
# - `@variables.x` = Value from stored state
|
|
14
|
+
# - `@outputs.x` = Value from previous action's output
|
|
15
|
+
#
|
|
16
|
+
# ★ Common Use Cases:
|
|
17
|
+
# - Order lookup with user-provided order ID
|
|
18
|
+
# - Multi-step workflows with data passing
|
|
19
|
+
# - Conditional parameter binding
|
|
20
|
+
#
|
|
21
|
+
# This is a PARTIAL template - integrate into a complete agent file
|
|
22
|
+
|
|
23
|
+
# Variables for demonstrating different binding patterns
|
|
24
|
+
variables:
|
|
25
|
+
# ... standard linked variables ...
|
|
26
|
+
current_account_id: mutable string = ""
|
|
27
|
+
description: "Currently selected account ID"
|
|
28
|
+
order_id: mutable string = ""
|
|
29
|
+
description: "Order ID being processed"
|
|
30
|
+
amount: mutable number = 0
|
|
31
|
+
description: "Transaction amount"
|
|
32
|
+
status: mutable string = ""
|
|
33
|
+
description: "Current operation status"
|
|
34
|
+
|
|
35
|
+
topic order_processing:
|
|
36
|
+
label: "Order Processing"
|
|
37
|
+
description: "Demonstrates advanced input binding patterns"
|
|
38
|
+
|
|
39
|
+
actions:
|
|
40
|
+
# Action with multiple input types
|
|
41
|
+
process_order:
|
|
42
|
+
description: "Process an order with various input methods"
|
|
43
|
+
inputs:
|
|
44
|
+
order_id: string
|
|
45
|
+
description: "The order ID to process"
|
|
46
|
+
amount: number
|
|
47
|
+
description: "Transaction amount in USD"
|
|
48
|
+
account_id: string
|
|
49
|
+
description: "Customer account ID"
|
|
50
|
+
outputs:
|
|
51
|
+
confirmation_number: string
|
|
52
|
+
description: "Order confirmation number"
|
|
53
|
+
processed_amount: number
|
|
54
|
+
description: "Final processed amount"
|
|
55
|
+
target: "flow://Process_Order"
|
|
56
|
+
|
|
57
|
+
get_account:
|
|
58
|
+
description: "Look up account details"
|
|
59
|
+
inputs:
|
|
60
|
+
account_id: string
|
|
61
|
+
description: "Account ID to look up"
|
|
62
|
+
outputs:
|
|
63
|
+
account_name: string
|
|
64
|
+
description: "Account name"
|
|
65
|
+
credit_limit: number
|
|
66
|
+
description: "Available credit"
|
|
67
|
+
target: "flow://Get_Account_Details"
|
|
68
|
+
|
|
69
|
+
send_notification:
|
|
70
|
+
description: "Send order notification"
|
|
71
|
+
inputs:
|
|
72
|
+
confirmation_number: string
|
|
73
|
+
description: "Order confirmation to include"
|
|
74
|
+
recipient_account: string
|
|
75
|
+
description: "Account to notify"
|
|
76
|
+
outputs:
|
|
77
|
+
sent: boolean
|
|
78
|
+
description: "Whether notification was sent"
|
|
79
|
+
target: "flow://Send_Order_Notification"
|
|
80
|
+
|
|
81
|
+
reasoning:
|
|
82
|
+
instructions: ->
|
|
83
|
+
| Help the customer process their order.
|
|
84
|
+
|
|
|
85
|
+
| INPUT BINDING EXAMPLES:
|
|
86
|
+
| 1. Slot filling (...) - LLM extracts from conversation
|
|
87
|
+
| 2. Fixed values - Always use a constant
|
|
88
|
+
| 3. Variable binding - Use stored state
|
|
89
|
+
| 4. Output chaining - Use results from previous action
|
|
90
|
+
|
|
|
91
|
+
| Ask for order details and process appropriately.
|
|
92
|
+
|
|
93
|
+
actions:
|
|
94
|
+
# ★ PATTERN 1: Slot Filling (LLM extracts from conversation)
|
|
95
|
+
# User says "Process order ORD-12345" -> LLM fills order_id="ORD-12345"
|
|
96
|
+
slot_fill_lookup: @actions.process_order
|
|
97
|
+
with order_id=...
|
|
98
|
+
with amount=...
|
|
99
|
+
with account_id=...
|
|
100
|
+
set @variables.order_id = @outputs.confirmation_number
|
|
101
|
+
|
|
102
|
+
# ★ PATTERN 2: Fixed Value (constant)
|
|
103
|
+
# Always uses the same account for default lookups
|
|
104
|
+
fixed_account: @actions.get_account
|
|
105
|
+
with account_id="001DEFAULT000001"
|
|
106
|
+
set @variables.status = @outputs.account_name
|
|
107
|
+
|
|
108
|
+
# ★ PATTERN 3: Variable Binding (from stored state)
|
|
109
|
+
# Uses the account ID saved earlier in the conversation
|
|
110
|
+
variable_binding: @actions.get_account
|
|
111
|
+
with account_id=@variables.current_account_id
|
|
112
|
+
set @variables.status = @outputs.account_name
|
|
113
|
+
|
|
114
|
+
# ★ PATTERN 4: Output Chaining (from previous action)
|
|
115
|
+
# Uses confirmation_number from process_order to send notification
|
|
116
|
+
chained_output: @actions.process_order
|
|
117
|
+
with order_id=...
|
|
118
|
+
with amount=@variables.amount
|
|
119
|
+
with account_id=@variables.current_account_id
|
|
120
|
+
set @variables.order_id = @outputs.confirmation_number
|
|
121
|
+
run @actions.send_notification
|
|
122
|
+
with confirmation_number=@outputs.confirmation_number
|
|
123
|
+
with recipient_account=@variables.current_account_id
|
|
124
|
+
|
|
125
|
+
# ★ PATTERN 5: Mixed Binding (combining patterns)
|
|
126
|
+
# Some inputs from LLM, some from variables, some fixed
|
|
127
|
+
mixed_binding: @actions.process_order
|
|
128
|
+
with order_id=... # LLM slot fills
|
|
129
|
+
with amount=@variables.amount # From variable
|
|
130
|
+
with account_id="001INTERNAL00001" # Fixed value
|
|
131
|
+
|
|
132
|
+
# ★ Insight: Binding Pattern Decision Tree
|
|
133
|
+
#
|
|
134
|
+
# Need the LLM to extract from conversation? -> Use `...`
|
|
135
|
+
# Value is always the same constant? -> Use "value"
|
|
136
|
+
# Value was captured in a previous step? -> Use @variables.x
|
|
137
|
+
# Value comes from another action's output? -> Use @outputs.x (in callback)
|
|
138
|
+
#
|
|
139
|
+
# ★ Common Mistake: Using @outputs.x outside of a `run` callback
|
|
140
|
+
# @outputs.x is only available inside the action's callback chain
|
|
141
|
+
# Store important outputs in @variables for use elsewhere
|