@salesforce/afv-skills 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -5
- package/skills/accessing-webapp-data/SKILL.md +178 -0
- package/skills/agentforce-development/SKILL.md +427 -0
- package/skills/agentforce-development/assets/README-legacy.md +89 -0
- package/skills/agentforce-development/assets/agent-spec-template.md +90 -0
- package/skills/agentforce-development/assets/agents/README.md +45 -0
- package/skills/agentforce-development/assets/agents/hello-world.agent +60 -0
- package/skills/agentforce-development/assets/agents/multi-topic.agent +105 -0
- package/skills/agentforce-development/assets/agents/production-faq.agent +101 -0
- package/skills/agentforce-development/assets/agents/production-faq.bundle-meta.xml +4 -0
- package/skills/agentforce-development/assets/agents/simple-qa.agent +72 -0
- package/skills/agentforce-development/assets/apex/models-api-queueable.cls +225 -0
- package/skills/agentforce-development/assets/bundle-meta.xml +23 -0
- package/skills/agentforce-development/assets/components/apex-action.agent +52 -0
- package/skills/agentforce-development/assets/components/error-handling.agent +58 -0
- package/skills/agentforce-development/assets/components/escalation-setup.agent +169 -0
- package/skills/agentforce-development/assets/components/flow-action.agent +66 -0
- package/skills/agentforce-development/assets/components/n-ary-conditions.agent +110 -0
- package/skills/agentforce-development/assets/components/topic-with-actions.agent +40 -0
- package/skills/agentforce-development/assets/deterministic-routing.agent +166 -0
- package/skills/agentforce-development/assets/escalation-pattern.agent +209 -0
- package/skills/agentforce-development/assets/flow-action-lookup.agent +115 -0
- package/skills/agentforce-development/assets/hub-and-spoke.agent +104 -0
- package/skills/agentforce-development/assets/invocable-apex-template.cls +187 -0
- package/skills/agentforce-development/assets/local-info-agent-annotated.agent +355 -0
- package/skills/agentforce-development/assets/metadata/basic-prompt-template.promptTemplate-meta.xml +109 -0
- package/skills/agentforce-development/assets/metadata/genai-function-apex.xml +92 -0
- package/skills/agentforce-development/assets/metadata/genai-function-flow.xml +57 -0
- package/skills/agentforce-development/assets/metadata/genai-plugin.xml +72 -0
- package/skills/agentforce-development/assets/metadata/http-callout-flow.flow-meta.xml +348 -0
- package/skills/agentforce-development/assets/metadata/record-grounded-prompt.promptTemplate-meta.xml +136 -0
- package/skills/agentforce-development/assets/minimal-starter.agent +42 -0
- package/skills/agentforce-development/assets/patterns/README.md +254 -0
- package/skills/agentforce-development/assets/patterns/action-callbacks.agent +178 -0
- package/skills/agentforce-development/assets/patterns/advanced-input-bindings.agent +141 -0
- package/skills/agentforce-development/assets/patterns/bidirectional-routing.agent +156 -0
- package/skills/agentforce-development/assets/patterns/critical-input-collection.agent +244 -0
- package/skills/agentforce-development/assets/patterns/delegation-routing.agent +89 -0
- package/skills/agentforce-development/assets/patterns/lifecycle-events.agent +127 -0
- package/skills/agentforce-development/assets/patterns/llm-controlled-actions.agent +184 -0
- package/skills/agentforce-development/assets/patterns/multi-step-workflow.agent +282 -0
- package/skills/agentforce-development/assets/patterns/open-gate-routing.agent +286 -0
- package/skills/agentforce-development/assets/patterns/procedural-instructions.agent +273 -0
- package/skills/agentforce-development/assets/patterns/prompt-template-action.agent +188 -0
- package/skills/agentforce-development/assets/patterns/system-instruction-overrides.agent +293 -0
- package/skills/agentforce-development/assets/prompt-rag-search.agent +131 -0
- package/skills/agentforce-development/assets/template-multi-topic.agent +160 -0
- package/skills/agentforce-development/assets/template-single-topic.agent +81 -0
- package/skills/agentforce-development/assets/verification-gate.agent +208 -0
- package/skills/agentforce-development/references/action-prompt-templates.md +164 -0
- package/skills/agentforce-development/references/actions-reference.md +592 -0
- package/skills/agentforce-development/references/agent-access-guide.md +72 -0
- package/skills/agentforce-development/references/agent-design-and-spec-creation.md +1010 -0
- package/skills/agentforce-development/references/agent-metadata-and-lifecycle.md +575 -0
- package/skills/agentforce-development/references/agent-script-core-language.md +1218 -0
- package/skills/agentforce-development/references/agent-topic-map-diagrams.md +323 -0
- package/skills/agentforce-development/references/agent-user-setup.md +526 -0
- package/skills/agentforce-development/references/agent-validation-and-debugging.md +803 -0
- package/skills/agentforce-development/references/known-issues.md +353 -0
- package/skills/agentforce-development/references/minimal-examples.md +67 -0
- package/skills/agentforce-development/references/production-gotchas.md +279 -0
- package/skills/agentforce-development/references/salesforce-cli-for-agents.md +393 -0
- package/skills/agentforce-development/references/version-history.md +23 -0
- package/skills/building-webapp-data-visualization/SKILL.md +72 -0
- package/skills/building-webapp-data-visualization/implementation/bar-line-chart.md +316 -0
- package/skills/building-webapp-data-visualization/implementation/dashboard-layout.md +189 -0
- package/skills/building-webapp-data-visualization/implementation/donut-chart.md +181 -0
- package/skills/building-webapp-data-visualization/implementation/stat-card.md +150 -0
- package/skills/building-webapp-react-components/SKILL.md +96 -0
- package/skills/building-webapp-react-components/implementation/component.md +78 -0
- package/skills/building-webapp-react-components/implementation/header-footer.md +132 -0
- package/skills/building-webapp-react-components/implementation/page.md +93 -0
- package/skills/configuring-webapp-csp-trusted-sites/SKILL.md +90 -0
- package/skills/configuring-webapp-csp-trusted-sites/implementation/metadata-format.md +281 -0
- package/skills/configuring-webapp-metadata/SKILL.md +158 -0
- package/skills/creating-webapp/SKILL.md +141 -0
- package/skills/deploying-webapp-to-salesforce/SKILL.md +229 -0
- package/skills/exploring-webapp-graphql-schema/SKILL.md +149 -0
- package/skills/fetching-webapp-rest-api/SKILL.md +167 -0
- package/skills/{salesforce-custom-application → generating-custom-application}/SKILL.md +2 -4
- package/skills/{salesforce-custom-field → generating-custom-field}/SKILL.md +1 -5
- package/skills/{salesforce-custom-lightning-type → generating-custom-lightning-type}/SKILL.md +36 -2
- package/skills/{salesforce-custom-object → generating-custom-object}/SKILL.md +1 -1
- package/skills/generating-custom-tab/SKILL.md +154 -0
- package/skills/generating-experience-lwr-site/SKILL.md +196 -0
- package/skills/generating-experience-lwr-site/docs/bootstrap-template-byo-lwr.md +224 -0
- package/skills/generating-experience-lwr-site/docs/configure-content-brandingSet.md +131 -0
- package/skills/generating-experience-lwr-site/docs/configure-content-route.md +232 -0
- package/skills/generating-experience-lwr-site/docs/configure-content-themeLayout.md +141 -0
- package/skills/generating-experience-lwr-site/docs/configure-content-view.md +233 -0
- package/skills/generating-experience-lwr-site/docs/configure-guest-sharing-rules.md +42 -0
- package/skills/generating-experience-lwr-site/docs/handle-component-and-region-ids.md +27 -0
- package/skills/generating-experience-lwr-site/docs/handle-ui-components.md +215 -0
- package/skills/generating-experience-react-site/SKILL.md +67 -0
- package/skills/generating-experience-react-site/docs/configure-metadata-custom-site.md +41 -0
- package/skills/generating-experience-react-site/docs/configure-metadata-digital-experience-bundle.md +17 -0
- package/skills/generating-experience-react-site/docs/configure-metadata-digital-experience-config.md +21 -0
- package/skills/generating-experience-react-site/docs/configure-metadata-digital-experience.md +38 -0
- package/skills/generating-experience-react-site/docs/configure-metadata-network.md +72 -0
- package/skills/{salesforce-flexipage → generating-flexipage}/SKILL.md +86 -9
- package/skills/{salesforce-flow → generating-flow}/SKILL.md +3 -3
- package/skills/generating-fragment/SKILL.md +117 -0
- package/skills/generating-lightning-app/SKILL.md +423 -0
- package/skills/{salesforce-list-view → generating-list-view}/SKILL.md +1 -1
- package/skills/generating-permission-set/SKILL.md +174 -0
- package/skills/{salesforce-validation-rule → generating-validation-rule}/SKILL.md +1 -1
- package/skills/generating-webapp-graphql-mutation-query/SKILL.md +258 -0
- package/skills/generating-webapp-graphql-read-query/SKILL.md +253 -0
- package/skills/implementing-webapp-file-upload/SKILL.md +396 -0
- package/skills/installing-webapp-features/SKILL.md +210 -0
- package/skills/managing-webapp-agentforce-conversation-client/SKILL.md +186 -0
- package/skills/managing-webapp-agentforce-conversation-client/references/constraints.md +134 -0
- package/skills/managing-webapp-agentforce-conversation-client/references/examples.md +132 -0
- package/skills/managing-webapp-agentforce-conversation-client/references/style-tokens.md +101 -0
- package/skills/managing-webapp-agentforce-conversation-client/references/troubleshooting.md +57 -0
- package/skills/switching-org/SKILL.md +28 -0
- package/skills/using-webapp-graphql/SKILL.md +324 -0
- package/skills/using-webapp-graphql/shared-schema.graphqls +1150 -0
- package/skills/apex-class/SKILL.md +0 -253
- package/skills/apex-class/examples/AccountDeduplicationBatch.cls +0 -148
- package/skills/apex-class/examples/AccountSelector.cls +0 -193
- package/skills/apex-class/examples/AccountService.cls +0 -201
- package/skills/apex-class/templates/abstract.cls +0 -128
- package/skills/apex-class/templates/batch.cls +0 -125
- package/skills/apex-class/templates/domain.cls +0 -102
- package/skills/apex-class/templates/dto.cls +0 -108
- package/skills/apex-class/templates/exception.cls +0 -51
- package/skills/apex-class/templates/interface.cls +0 -25
- package/skills/apex-class/templates/queueable.cls +0 -92
- package/skills/apex-class/templates/schedulable.cls +0 -75
- package/skills/apex-class/templates/selector.cls +0 -92
- package/skills/apex-class/templates/service.cls +0 -69
- package/skills/apex-class/templates/utility.cls +0 -97
- package/skills/apex-test-class/SKILL.md +0 -101
- package/skills/apex-test-class/references/assertion-patterns.md +0 -209
- package/skills/apex-test-class/references/async-testing.md +0 -276
- package/skills/apex-test-class/references/mocking-patterns.md +0 -219
- package/skills/apex-test-class/references/test-data-factory.md +0 -176
- package/skills/deployment-readiness-check/SKILL.md +0 -257
- package/skills/deployment-readiness-check/assets/deployment_checklist.md +0 -286
- package/skills/deployment-readiness-check/references/rollback_procedures.md +0 -308
- package/skills/deployment-readiness-check/scripts/check_metadata.sh +0 -207
- package/skills/salesforce-custom-tab/SKILL.md +0 -78
- package/skills/salesforce-experience-site/SKILL.md +0 -178
- package/skills/salesforce-fragment/SKILL.md +0 -42
- package/skills/salesforce-lightning-app-build/SKILL.md +0 -254
- package/skills/salesforce-web-app-creating-records/SKILL.md +0 -84
- package/skills/salesforce-web-app-feature/SKILL.md +0 -70
- package/skills/salesforce-web-app-list-and-create-records/SKILL.md +0 -36
- package/skills/salesforce-web-application/SKILL.md +0 -34
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
# Open Gate Routing Pattern
|
|
2
|
+
# 3-variable state machine for auth-gated topic routing with LLM bypass
|
|
3
|
+
#
|
|
4
|
+
# ★ When To Use This Pattern:
|
|
5
|
+
# - Multiple protected topics require authentication before access
|
|
6
|
+
# - You want to bypass the LLM topic selector when a gate topic holds focus
|
|
7
|
+
# - Users should be redirected to auth, then automatically returned to their
|
|
8
|
+
# original intended topic after authentication completes
|
|
9
|
+
# - You need an EXIT_PROTOCOL to reset state when users change intent
|
|
10
|
+
#
|
|
11
|
+
# ★ Key Insight (Zero Credit Bypass):
|
|
12
|
+
# When open_gate is set, before_reasoning in the topic_selector
|
|
13
|
+
# deterministically routes via "transition to" — the LLM never reasons.
|
|
14
|
+
# This saves credits on every turn the gate holds focus.
|
|
15
|
+
#
|
|
16
|
+
# ★ The 3 Variables:
|
|
17
|
+
# open_gate — Which topic currently holds focus ("null" = none)
|
|
18
|
+
# next_topic — Deferred destination after auth completes
|
|
19
|
+
# authenticated — Whether the user has passed authentication
|
|
20
|
+
#
|
|
21
|
+
# ★ EXIT_PROTOCOL:
|
|
22
|
+
# Any topic can reset open_gate to "null" when the user changes intent.
|
|
23
|
+
# This releases the gate lock and returns control to the LLM topic selector.
|
|
24
|
+
#
|
|
25
|
+
# ★ Related Patterns:
|
|
26
|
+
# - Latch Variable (SKILL.md) — simpler 1-variable version, no auth gate
|
|
27
|
+
# - Bidirectional Routing (bidirectional-routing.agent) — specialist consultation, not interception
|
|
28
|
+
# - Verification Gate (fsm-architecture.md) — linear one-time gate, no deferred return
|
|
29
|
+
#
|
|
30
|
+
# ★ Credit: Hua Xu (Salesforce APAC FDE team) — production pattern from Kogan agent deployment
|
|
31
|
+
#
|
|
32
|
+
# This is a PARTIAL template - integrate into a complete agent file
|
|
33
|
+
|
|
34
|
+
variables:
|
|
35
|
+
# ... standard linked variables ...
|
|
36
|
+
open_gate: mutable string = "null"
|
|
37
|
+
description: "Which topic currently holds focus (null = LLM decides)"
|
|
38
|
+
next_topic: mutable string = ""
|
|
39
|
+
description: "Deferred destination after authentication completes"
|
|
40
|
+
authenticated: mutable boolean = False
|
|
41
|
+
description: "Whether the user has passed authentication"
|
|
42
|
+
|
|
43
|
+
# ─────────────────────────────────────────────────────────────────────
|
|
44
|
+
# TOPIC SELECTOR (Entry Point)
|
|
45
|
+
# When open_gate is set, bypasses LLM entirely (zero credit cost)
|
|
46
|
+
# ─────────────────────────────────────────────────────────────────────
|
|
47
|
+
start_agent topic_selector:
|
|
48
|
+
description: "Routes to topics — deterministic bypass when open_gate is set"
|
|
49
|
+
|
|
50
|
+
before_reasoning:
|
|
51
|
+
# ★ GATE CHECK: If a topic holds focus, bypass LLM entirely
|
|
52
|
+
if @variables.open_gate == "protected_workflow":
|
|
53
|
+
transition to @topic.protected_workflow
|
|
54
|
+
if @variables.open_gate == "account_management":
|
|
55
|
+
transition to @topic.account_management
|
|
56
|
+
if @variables.open_gate == "authentication_gate":
|
|
57
|
+
transition to @topic.authentication_gate
|
|
58
|
+
|
|
59
|
+
reasoning:
|
|
60
|
+
instructions: ->
|
|
61
|
+
| You are a customer service agent.
|
|
62
|
+
| Route the customer to the appropriate topic:
|
|
63
|
+
| - Order status, returns, or shipping → protected workflow
|
|
64
|
+
| - Account settings or profile changes → account management
|
|
65
|
+
| - General questions → general inquiry
|
|
66
|
+
actions:
|
|
67
|
+
go_protected: @utils.transition to @topic.protected_workflow
|
|
68
|
+
go_account: @utils.transition to @topic.account_management
|
|
69
|
+
go_general: @utils.transition to @topic.general_inquiry
|
|
70
|
+
|
|
71
|
+
# ─────────────────────────────────────────────────────────────────────
|
|
72
|
+
# PROTECTED WORKFLOW (Requires Authentication)
|
|
73
|
+
# Checks auth state, redirects to auth gate if needed, locks focus if authed
|
|
74
|
+
# ─────────────────────────────────────────────────────────────────────
|
|
75
|
+
topic protected_workflow:
|
|
76
|
+
description: "Handles order status, returns, and shipping (requires authentication)"
|
|
77
|
+
|
|
78
|
+
before_reasoning:
|
|
79
|
+
# ★ AUTH CHECK: Redirect unauthenticated users to auth gate
|
|
80
|
+
if @variables.authenticated == False:
|
|
81
|
+
set @variables.next_topic = "protected_workflow"
|
|
82
|
+
set @variables.open_gate = "authentication_gate"
|
|
83
|
+
transition to @topic.authentication_gate
|
|
84
|
+
|
|
85
|
+
# ★ FOCUS LOCK: Keep gate open so topic selector bypasses LLM
|
|
86
|
+
set @variables.open_gate = "protected_workflow"
|
|
87
|
+
|
|
88
|
+
reasoning:
|
|
89
|
+
instructions: ->
|
|
90
|
+
| The customer is authenticated.
|
|
91
|
+
| Help them with order status, returns, or shipping inquiries.
|
|
92
|
+
|
|
|
93
|
+
| If the customer changes the subject to something unrelated,
|
|
94
|
+
| let them know you will redirect them.
|
|
95
|
+
actions:
|
|
96
|
+
lookup_order: @actions.get_order_status
|
|
97
|
+
with order_id=...
|
|
98
|
+
set @variables.order_result = @outputs.status
|
|
99
|
+
|
|
100
|
+
# ★ EXIT_PROTOCOL: User changed intent — release gate
|
|
101
|
+
exit_to_menu: @utils.transition to @topic.exit_protocol
|
|
102
|
+
|
|
103
|
+
after_reasoning:
|
|
104
|
+
# Logging or cleanup after each turn (optional)
|
|
105
|
+
set @variables.last_topic = "protected_workflow"
|
|
106
|
+
|
|
107
|
+
# ─────────────────────────────────────────────────────────────────────
|
|
108
|
+
# ACCOUNT MANAGEMENT (Second Protected Topic)
|
|
109
|
+
# Demonstrates the pattern scales to N protected topics
|
|
110
|
+
# ─────────────────────────────────────────────────────────────────────
|
|
111
|
+
topic account_management:
|
|
112
|
+
description: "Handles account settings and profile changes (requires authentication)"
|
|
113
|
+
|
|
114
|
+
before_reasoning:
|
|
115
|
+
# ★ AUTH CHECK: Same pattern as protected_workflow
|
|
116
|
+
if @variables.authenticated == False:
|
|
117
|
+
set @variables.next_topic = "account_management"
|
|
118
|
+
set @variables.open_gate = "authentication_gate"
|
|
119
|
+
transition to @topic.authentication_gate
|
|
120
|
+
|
|
121
|
+
# ★ FOCUS LOCK
|
|
122
|
+
set @variables.open_gate = "account_management"
|
|
123
|
+
|
|
124
|
+
reasoning:
|
|
125
|
+
instructions: ->
|
|
126
|
+
| The customer is authenticated.
|
|
127
|
+
| Help them with account settings and profile changes.
|
|
128
|
+
|
|
|
129
|
+
| If the customer changes the subject to something unrelated,
|
|
130
|
+
| let them know you will redirect them.
|
|
131
|
+
actions:
|
|
132
|
+
update_profile: @actions.update_customer_profile
|
|
133
|
+
with field_name=...
|
|
134
|
+
with new_value=...
|
|
135
|
+
set @variables.update_result = @outputs.success
|
|
136
|
+
|
|
137
|
+
# ★ EXIT_PROTOCOL: User changed intent — release gate
|
|
138
|
+
exit_to_menu: @utils.transition to @topic.exit_protocol
|
|
139
|
+
|
|
140
|
+
# ─────────────────────────────────────────────────────────────────────
|
|
141
|
+
# AUTHENTICATION GATE
|
|
142
|
+
# Handles auth flow, then routes back via next_topic
|
|
143
|
+
# ─────────────────────────────────────────────────────────────────────
|
|
144
|
+
topic authentication_gate:
|
|
145
|
+
description: "Verifies customer identity before allowing access to protected topics"
|
|
146
|
+
|
|
147
|
+
before_reasoning:
|
|
148
|
+
# ★ FOCUS LOCK: Hold gate open during auth flow
|
|
149
|
+
set @variables.open_gate = "authentication_gate"
|
|
150
|
+
|
|
151
|
+
reasoning:
|
|
152
|
+
instructions: ->
|
|
153
|
+
if @variables.authenticated == True:
|
|
154
|
+
| You are already authenticated. Redirecting you now.
|
|
155
|
+
|
|
156
|
+
if @variables.authenticated == False:
|
|
157
|
+
| I need to verify your identity before I can help with that.
|
|
158
|
+
| Please provide your email address and verification code.
|
|
159
|
+
actions:
|
|
160
|
+
verify_identity: @actions.verify_customer
|
|
161
|
+
with email=...
|
|
162
|
+
with verification_code=...
|
|
163
|
+
set @variables.authenticated = @outputs.is_verified
|
|
164
|
+
|
|
165
|
+
after_reasoning:
|
|
166
|
+
# ★ POST-AUTH ROUTING: If authenticated, route to deferred destination
|
|
167
|
+
if @variables.authenticated == True:
|
|
168
|
+
if @variables.next_topic == "protected_workflow":
|
|
169
|
+
set @variables.open_gate = "protected_workflow"
|
|
170
|
+
transition to @topic.protected_workflow
|
|
171
|
+
if @variables.next_topic == "account_management":
|
|
172
|
+
set @variables.open_gate = "account_management"
|
|
173
|
+
transition to @topic.account_management
|
|
174
|
+
|
|
175
|
+
# ─────────────────────────────────────────────────────────────────────
|
|
176
|
+
# EXIT PROTOCOL (Resets Gate State)
|
|
177
|
+
# Clears open_gate so LLM topic selector regains control
|
|
178
|
+
# ─────────────────────────────────────────────────────────────────────
|
|
179
|
+
topic exit_protocol:
|
|
180
|
+
description: "Resets gate state and returns to topic selector"
|
|
181
|
+
|
|
182
|
+
before_reasoning:
|
|
183
|
+
# ★ RELEASE GATE: Clear all gate state
|
|
184
|
+
set @variables.open_gate = "null"
|
|
185
|
+
set @variables.next_topic = ""
|
|
186
|
+
transition to @topic.topic_selector
|
|
187
|
+
|
|
188
|
+
reasoning:
|
|
189
|
+
instructions: ->
|
|
190
|
+
| Redirecting you to the main menu.
|
|
191
|
+
|
|
192
|
+
# ─────────────────────────────────────────────────────────────────────
|
|
193
|
+
# GENERAL INQUIRY (Unprotected Topic)
|
|
194
|
+
# Demonstrates that not every topic needs gating
|
|
195
|
+
# ─────────────────────────────────────────────────────────────────────
|
|
196
|
+
topic general_inquiry:
|
|
197
|
+
description: "Handles general questions that do not require authentication"
|
|
198
|
+
|
|
199
|
+
reasoning:
|
|
200
|
+
instructions: ->
|
|
201
|
+
| Help the customer with general questions.
|
|
202
|
+
| No authentication is needed for this topic.
|
|
203
|
+
|
|
|
204
|
+
| If the customer needs help with orders or account settings,
|
|
205
|
+
| let them know they will need to verify their identity first.
|
|
206
|
+
actions:
|
|
207
|
+
go_protected: @utils.transition to @topic.protected_workflow
|
|
208
|
+
go_account: @utils.transition to @topic.account_management
|
|
209
|
+
|
|
210
|
+
# ═════════════════════════════════════════════════════════════════════
|
|
211
|
+
# ARCHITECTURE DIAGRAM
|
|
212
|
+
# ═════════════════════════════════════════════════════════════════════
|
|
213
|
+
#
|
|
214
|
+
# ┌─────────────────────┐
|
|
215
|
+
# │ topic_selector │
|
|
216
|
+
# │ (start_agent) │
|
|
217
|
+
# │ │
|
|
218
|
+
# │ before_reasoning: │
|
|
219
|
+
# │ if open_gate <> null │
|
|
220
|
+
# │ → bypass LLM │
|
|
221
|
+
# └──────────┬──────────┘
|
|
222
|
+
# ┌───────────────────┼───────────────────┐
|
|
223
|
+
# ▼ ▼ ▼
|
|
224
|
+
# ┌──────────────────┐ ┌────────────────┐ ┌─────────────────┐
|
|
225
|
+
# │ protected_workflow│ │account_mgmt │ │ general_inquiry │
|
|
226
|
+
# │ (auth required) │ │(auth required)│ │ (no auth needed) │
|
|
227
|
+
# │ │ │ │ │ │
|
|
228
|
+
# │ before_reasoning:│ │ before_reas.: │ │ (no gate logic) │
|
|
229
|
+
# │ if !auth → gate │ │ if !auth→gate │ │ │
|
|
230
|
+
# │ if auth → lock │ │ if auth→lock │ │ │
|
|
231
|
+
# └────────┬─────────┘ └───────┬───────┘ └─────────────────┘
|
|
232
|
+
# │ │
|
|
233
|
+
# ▼ ▼
|
|
234
|
+
# ┌──────────────────────────────────────┐
|
|
235
|
+
# │ authentication_gate │
|
|
236
|
+
# │ │
|
|
237
|
+
# │ before_reasoning: lock gate │
|
|
238
|
+
# │ reasoning: verify identity │
|
|
239
|
+
# │ after_reasoning: │
|
|
240
|
+
# │ if auth → route via next_topic │
|
|
241
|
+
# └──────────────────────────────────────┘
|
|
242
|
+
#
|
|
243
|
+
# ═════════════════════════════════════════════════════════════════════
|
|
244
|
+
# VARIABLE STATE FLOW WALKTHROUGH
|
|
245
|
+
# ═════════════════════════════════════════════════════════════════════
|
|
246
|
+
#
|
|
247
|
+
# User says: "I want to check my order status"
|
|
248
|
+
#
|
|
249
|
+
# Step 1: topic_selector
|
|
250
|
+
# open_gate = "null" → LLM reasons → routes to protected_workflow
|
|
251
|
+
#
|
|
252
|
+
# Step 2: protected_workflow.before_reasoning
|
|
253
|
+
# authenticated = False → set next_topic = "protected_workflow"
|
|
254
|
+
# → set open_gate = "authentication_gate"
|
|
255
|
+
# → transition to authentication_gate
|
|
256
|
+
#
|
|
257
|
+
# Step 3: authentication_gate.before_reasoning
|
|
258
|
+
# open_gate = "authentication_gate" (lock)
|
|
259
|
+
#
|
|
260
|
+
# Step 4: User provides email + code → verify_customer succeeds
|
|
261
|
+
# authenticated = True
|
|
262
|
+
#
|
|
263
|
+
# Step 5: authentication_gate.after_reasoning
|
|
264
|
+
# authenticated = True, next_topic = "protected_workflow"
|
|
265
|
+
# → set open_gate = "protected_workflow"
|
|
266
|
+
# → transition to protected_workflow
|
|
267
|
+
#
|
|
268
|
+
# Step 6: protected_workflow.before_reasoning
|
|
269
|
+
# authenticated = True → set open_gate = "protected_workflow" (lock)
|
|
270
|
+
# → LLM reasons with full access to protected actions
|
|
271
|
+
#
|
|
272
|
+
# Step 7: User says "actually, never mind"
|
|
273
|
+
# → LLM selects exit_to_menu action
|
|
274
|
+
# → exit_protocol.before_reasoning: open_gate = "null"
|
|
275
|
+
# → transition to topic_selector (LLM regains control)
|
|
276
|
+
#
|
|
277
|
+
# ═════════════════════════════════════════════════════════════════════
|
|
278
|
+
# PATTERN COMPARISON
|
|
279
|
+
# ═════════════════════════════════════════════════════════════════════
|
|
280
|
+
#
|
|
281
|
+
# Pattern | Variables | Auth Gate | Deferred Return | LLM Bypass
|
|
282
|
+
# ─────────────────────┼───────────┼───────────┼─────────────────┼───────────
|
|
283
|
+
# Latch Variable | 1 | No | No | Partial
|
|
284
|
+
# Bidirectional Route | 1-2 | No | Yes (manual) | No
|
|
285
|
+
# Verification Gate | 1 | Yes | No | No
|
|
286
|
+
# Open Gate (this) | 3 | Yes | Yes (automatic) | Full
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# Procedural Instructions Pattern
|
|
2
|
+
# Execute actions inline within instructions block for conditional data loading
|
|
3
|
+
#
|
|
4
|
+
# ★ When To Use This Pattern:
|
|
5
|
+
# - Fetch data only when needed (lazy loading)
|
|
6
|
+
# - Chain data lookups based on conditions
|
|
7
|
+
# - Build up context progressively
|
|
8
|
+
# - Reduce unnecessary API calls
|
|
9
|
+
#
|
|
10
|
+
# ★ Key Insights:
|
|
11
|
+
# - `run @actions.x` can appear INSIDE `instructions: ->` blocks
|
|
12
|
+
# - Actions execute when their containing conditional is true
|
|
13
|
+
# - Different from actions: block which defines what LLM CAN call
|
|
14
|
+
# - This is PROCEDURAL (you control when) vs DECLARATIVE (LLM chooses)
|
|
15
|
+
#
|
|
16
|
+
# ★ Use Case Distinction:
|
|
17
|
+
# - actions: block = "LLM, here are tools you MAY use"
|
|
18
|
+
# - run in instructions = "Do this NOW when condition met"
|
|
19
|
+
#
|
|
20
|
+
# This is a COMPLETE template - customize for your use case
|
|
21
|
+
|
|
22
|
+
system:
|
|
23
|
+
instructions: "You are a customer service agent. Efficiently gather context as needed to help customers. Only fetch data when required for the current task."
|
|
24
|
+
messages:
|
|
25
|
+
welcome: "Hello! How can I help you today?"
|
|
26
|
+
error: "I encountered an issue retrieving your information. Let me try again."
|
|
27
|
+
|
|
28
|
+
config:
|
|
29
|
+
agent_name: "Smart_Service_Agent"
|
|
30
|
+
default_agent_user: "agent@company.salesforce.com"
|
|
31
|
+
agent_label: "Smart Service Agent"
|
|
32
|
+
description: "Agent with procedural data loading"
|
|
33
|
+
|
|
34
|
+
variables:
|
|
35
|
+
# Standard linked variables
|
|
36
|
+
EndUserId: linked string
|
|
37
|
+
source: @MessagingSession.MessagingEndUserId
|
|
38
|
+
description: "Messaging End User ID"
|
|
39
|
+
ContactId: linked string
|
|
40
|
+
source: @MessagingEndUser.ContactId
|
|
41
|
+
description: "Contact ID"
|
|
42
|
+
|
|
43
|
+
# Progressive data loading variables
|
|
44
|
+
customer_loaded: mutable boolean = False
|
|
45
|
+
description: "Whether customer data has been loaded"
|
|
46
|
+
orders_loaded: mutable boolean = False
|
|
47
|
+
description: "Whether order data has been loaded"
|
|
48
|
+
cases_loaded: mutable boolean = False
|
|
49
|
+
description: "Whether case data has been loaded"
|
|
50
|
+
|
|
51
|
+
# Customer data
|
|
52
|
+
customer_name: mutable string = ""
|
|
53
|
+
description: "Customer's full name"
|
|
54
|
+
customer_tier: mutable string = ""
|
|
55
|
+
description: "Customer tier: standard, premium, vip"
|
|
56
|
+
account_id: mutable string = ""
|
|
57
|
+
description: "Associated account ID"
|
|
58
|
+
|
|
59
|
+
# Order data
|
|
60
|
+
recent_order_id: mutable string = ""
|
|
61
|
+
description: "Most recent order ID"
|
|
62
|
+
order_status: mutable string = ""
|
|
63
|
+
description: "Status of the recent order"
|
|
64
|
+
tracking_number: mutable string = ""
|
|
65
|
+
description: "Shipping tracking number"
|
|
66
|
+
|
|
67
|
+
# Case data
|
|
68
|
+
open_case_count: mutable number = 0
|
|
69
|
+
description: "Number of open support cases"
|
|
70
|
+
last_case_subject: mutable string = ""
|
|
71
|
+
description: "Subject of most recent case"
|
|
72
|
+
|
|
73
|
+
language:
|
|
74
|
+
default_locale: "en_US"
|
|
75
|
+
|
|
76
|
+
start_agent topic_selector:
|
|
77
|
+
label: "Topic Selector"
|
|
78
|
+
description: "Routes to topics with procedural data loading"
|
|
79
|
+
|
|
80
|
+
actions:
|
|
81
|
+
# Data loading actions
|
|
82
|
+
load_customer:
|
|
83
|
+
description: "Load customer profile data"
|
|
84
|
+
inputs:
|
|
85
|
+
contact_id: string
|
|
86
|
+
description: "Contact ID to look up"
|
|
87
|
+
is_required: True
|
|
88
|
+
outputs:
|
|
89
|
+
name: string
|
|
90
|
+
description: "Customer name"
|
|
91
|
+
tier: string
|
|
92
|
+
description: "Customer tier"
|
|
93
|
+
account_id: string
|
|
94
|
+
description: "Associated account"
|
|
95
|
+
target: "flow://Get_Customer_Profile"
|
|
96
|
+
|
|
97
|
+
load_orders:
|
|
98
|
+
description: "Load recent order data"
|
|
99
|
+
inputs:
|
|
100
|
+
contact_id: string
|
|
101
|
+
description: "Contact ID"
|
|
102
|
+
is_required: True
|
|
103
|
+
outputs:
|
|
104
|
+
order_id: string
|
|
105
|
+
description: "Most recent order ID"
|
|
106
|
+
status: string
|
|
107
|
+
description: "Order status"
|
|
108
|
+
tracking: string
|
|
109
|
+
description: "Tracking number"
|
|
110
|
+
target: "flow://Get_Recent_Orders"
|
|
111
|
+
|
|
112
|
+
load_cases:
|
|
113
|
+
description: "Load support case data"
|
|
114
|
+
inputs:
|
|
115
|
+
contact_id: string
|
|
116
|
+
description: "Contact ID"
|
|
117
|
+
is_required: True
|
|
118
|
+
outputs:
|
|
119
|
+
open_count: number
|
|
120
|
+
description: "Number of open cases"
|
|
121
|
+
last_subject: string
|
|
122
|
+
description: "Last case subject"
|
|
123
|
+
target: "flow://Get_Open_Cases"
|
|
124
|
+
|
|
125
|
+
reasoning:
|
|
126
|
+
# ★ PROCEDURAL INSTRUCTIONS with inline action execution
|
|
127
|
+
instructions: ->
|
|
128
|
+
# ★ STEP 1: Always load customer data first (if not already loaded)
|
|
129
|
+
# This runs BEFORE any conversation happens
|
|
130
|
+
if @variables.customer_loaded == False:
|
|
131
|
+
run @actions.load_customer
|
|
132
|
+
with contact_id=@variables.ContactId
|
|
133
|
+
set @variables.customer_name = @outputs.name
|
|
134
|
+
set @variables.customer_tier = @outputs.tier
|
|
135
|
+
set @variables.account_id = @outputs.account_id
|
|
136
|
+
set @variables.customer_loaded = True
|
|
137
|
+
|
|
138
|
+
# Now we have customer context
|
|
139
|
+
| Hello {!@variables.customer_name}!
|
|
140
|
+
|
|
|
141
|
+
if @variables.customer_tier == "vip":
|
|
142
|
+
| As a VIP customer, I'm here to provide priority support.
|
|
143
|
+
|
|
|
144
|
+
| How can I help you today?
|
|
145
|
+
| - Order status or tracking
|
|
146
|
+
| - Support cases
|
|
147
|
+
| - Account questions
|
|
148
|
+
|
|
149
|
+
actions:
|
|
150
|
+
go_orders: @utils.transition to @topic.order_status
|
|
151
|
+
go_cases: @utils.transition to @topic.support_cases
|
|
152
|
+
go_account: @utils.transition to @topic.account_help
|
|
153
|
+
|
|
154
|
+
topic order_status:
|
|
155
|
+
label: "Order Status"
|
|
156
|
+
description: "Check order status with lazy loading"
|
|
157
|
+
|
|
158
|
+
actions:
|
|
159
|
+
get_tracking_details:
|
|
160
|
+
description: "Get detailed tracking information"
|
|
161
|
+
inputs:
|
|
162
|
+
order_id: string
|
|
163
|
+
description: "Order ID to look up"
|
|
164
|
+
outputs:
|
|
165
|
+
carrier: string
|
|
166
|
+
description: "Shipping carrier"
|
|
167
|
+
estimated_delivery: string
|
|
168
|
+
description: "Estimated delivery date"
|
|
169
|
+
current_location: string
|
|
170
|
+
description: "Current package location"
|
|
171
|
+
target: "flow://Get_Tracking_Details"
|
|
172
|
+
|
|
173
|
+
reasoning:
|
|
174
|
+
instructions: ->
|
|
175
|
+
# ★ LAZY LOADING: Only fetch orders when user enters this topic
|
|
176
|
+
if @variables.orders_loaded == False:
|
|
177
|
+
run @actions.load_orders
|
|
178
|
+
with contact_id=@variables.ContactId
|
|
179
|
+
set @variables.recent_order_id = @outputs.order_id
|
|
180
|
+
set @variables.order_status = @outputs.status
|
|
181
|
+
set @variables.tracking_number = @outputs.tracking
|
|
182
|
+
set @variables.orders_loaded = True
|
|
183
|
+
|
|
184
|
+
# Now provide order information
|
|
185
|
+
| Here's your most recent order:
|
|
186
|
+
| Order ID: {!@variables.recent_order_id}
|
|
187
|
+
| Status: {!@variables.order_status}
|
|
188
|
+
|
|
|
189
|
+
if @variables.tracking_number != "":
|
|
190
|
+
| Tracking: {!@variables.tracking_number}
|
|
191
|
+
|
|
|
192
|
+
| Would you like more details or help with something else?
|
|
193
|
+
|
|
194
|
+
actions:
|
|
195
|
+
get_details: @actions.get_tracking_details
|
|
196
|
+
with order_id=@variables.recent_order_id
|
|
197
|
+
back: @utils.transition to @topic.topic_selector
|
|
198
|
+
|
|
199
|
+
topic support_cases:
|
|
200
|
+
label: "Support Cases"
|
|
201
|
+
description: "Review support cases with lazy loading"
|
|
202
|
+
|
|
203
|
+
reasoning:
|
|
204
|
+
instructions: ->
|
|
205
|
+
# ★ LAZY LOADING: Only fetch cases when needed
|
|
206
|
+
if @variables.cases_loaded == False:
|
|
207
|
+
run @actions.load_cases
|
|
208
|
+
with contact_id=@variables.ContactId
|
|
209
|
+
set @variables.open_case_count = @outputs.open_count
|
|
210
|
+
set @variables.last_case_subject = @outputs.last_subject
|
|
211
|
+
set @variables.cases_loaded = True
|
|
212
|
+
|
|
213
|
+
# Present case information
|
|
214
|
+
if @variables.open_case_count == 0:
|
|
215
|
+
| You have no open support cases.
|
|
216
|
+
| Is there something I can help you with?
|
|
217
|
+
|
|
218
|
+
if @variables.open_case_count > 0:
|
|
219
|
+
| You have {!@variables.open_case_count} open case(s).
|
|
220
|
+
| Most recent: {!@variables.last_case_subject}
|
|
221
|
+
|
|
|
222
|
+
| Would you like to:
|
|
223
|
+
| - Check the status of a specific case
|
|
224
|
+
| - Create a new support case
|
|
225
|
+
| - Return to the main menu
|
|
226
|
+
|
|
227
|
+
actions:
|
|
228
|
+
back: @utils.transition to @topic.topic_selector
|
|
229
|
+
escalate: @utils.escalate
|
|
230
|
+
description: "Transfer to support specialist"
|
|
231
|
+
|
|
232
|
+
topic account_help:
|
|
233
|
+
label: "Account Help"
|
|
234
|
+
description: "Account questions - customer data already loaded"
|
|
235
|
+
|
|
236
|
+
reasoning:
|
|
237
|
+
instructions: ->
|
|
238
|
+
# ★ DATA ALREADY AVAILABLE - no loading needed
|
|
239
|
+
# Customer data was loaded in topic_selector
|
|
240
|
+
| Account Information:
|
|
241
|
+
| Name: {!@variables.customer_name}
|
|
242
|
+
| Tier: {!@variables.customer_tier}
|
|
243
|
+
| Account ID: {!@variables.account_id}
|
|
244
|
+
|
|
|
245
|
+
| What would you like to know about your account?
|
|
246
|
+
|
|
247
|
+
actions:
|
|
248
|
+
back: @utils.transition to @topic.topic_selector
|
|
249
|
+
|
|
250
|
+
# ★ Insight: Procedural vs Declarative Actions
|
|
251
|
+
#
|
|
252
|
+
# PROCEDURAL (run in instructions):
|
|
253
|
+
# - You control WHEN the action runs
|
|
254
|
+
# - Executes based on conditionals
|
|
255
|
+
# - Good for: data loading, setup, guaranteed actions
|
|
256
|
+
# - Example: "Always load customer before greeting"
|
|
257
|
+
#
|
|
258
|
+
# DECLARATIVE (actions: block):
|
|
259
|
+
# - LLM decides IF and WHEN to call
|
|
260
|
+
# - Based on user request
|
|
261
|
+
# - Good for: optional tools, user-triggered actions
|
|
262
|
+
# - Example: "User can ask for refund if they want"
|
|
263
|
+
#
|
|
264
|
+
# COMBINE BOTH:
|
|
265
|
+
# - Use procedural for setup/loading
|
|
266
|
+
# - Use declarative for user interactions
|
|
267
|
+
# - Result: Efficient, context-aware agents
|
|
268
|
+
|
|
269
|
+
# ★ Performance Benefits:
|
|
270
|
+
# - Fetch only what's needed per topic
|
|
271
|
+
# - Avoid loading all data upfront
|
|
272
|
+
# - Reduce API calls for simple conversations
|
|
273
|
+
# - Better response times
|