@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.
Files changed (150) hide show
  1. package/package.json +6 -5
  2. package/skills/accessing-webapp-data/SKILL.md +178 -0
  3. package/skills/agentforce-development/SKILL.md +427 -0
  4. package/skills/agentforce-development/assets/README-legacy.md +89 -0
  5. package/skills/agentforce-development/assets/agent-spec-template.md +90 -0
  6. package/skills/agentforce-development/assets/agents/README.md +45 -0
  7. package/skills/agentforce-development/assets/agents/hello-world.agent +60 -0
  8. package/skills/agentforce-development/assets/agents/multi-topic.agent +105 -0
  9. package/skills/agentforce-development/assets/agents/production-faq.agent +101 -0
  10. package/skills/agentforce-development/assets/agents/production-faq.bundle-meta.xml +4 -0
  11. package/skills/agentforce-development/assets/agents/simple-qa.agent +72 -0
  12. package/skills/agentforce-development/assets/apex/models-api-queueable.cls +225 -0
  13. package/skills/agentforce-development/assets/bundle-meta.xml +23 -0
  14. package/skills/agentforce-development/assets/components/apex-action.agent +52 -0
  15. package/skills/agentforce-development/assets/components/error-handling.agent +58 -0
  16. package/skills/agentforce-development/assets/components/escalation-setup.agent +169 -0
  17. package/skills/agentforce-development/assets/components/flow-action.agent +66 -0
  18. package/skills/agentforce-development/assets/components/n-ary-conditions.agent +110 -0
  19. package/skills/agentforce-development/assets/components/topic-with-actions.agent +40 -0
  20. package/skills/agentforce-development/assets/deterministic-routing.agent +166 -0
  21. package/skills/agentforce-development/assets/escalation-pattern.agent +209 -0
  22. package/skills/agentforce-development/assets/flow-action-lookup.agent +115 -0
  23. package/skills/agentforce-development/assets/hub-and-spoke.agent +104 -0
  24. package/skills/agentforce-development/assets/invocable-apex-template.cls +187 -0
  25. package/skills/agentforce-development/assets/local-info-agent-annotated.agent +355 -0
  26. package/skills/agentforce-development/assets/metadata/basic-prompt-template.promptTemplate-meta.xml +109 -0
  27. package/skills/agentforce-development/assets/metadata/genai-function-apex.xml +92 -0
  28. package/skills/agentforce-development/assets/metadata/genai-function-flow.xml +57 -0
  29. package/skills/agentforce-development/assets/metadata/genai-plugin.xml +72 -0
  30. package/skills/agentforce-development/assets/metadata/http-callout-flow.flow-meta.xml +348 -0
  31. package/skills/agentforce-development/assets/metadata/record-grounded-prompt.promptTemplate-meta.xml +136 -0
  32. package/skills/agentforce-development/assets/minimal-starter.agent +42 -0
  33. package/skills/agentforce-development/assets/patterns/README.md +254 -0
  34. package/skills/agentforce-development/assets/patterns/action-callbacks.agent +178 -0
  35. package/skills/agentforce-development/assets/patterns/advanced-input-bindings.agent +141 -0
  36. package/skills/agentforce-development/assets/patterns/bidirectional-routing.agent +156 -0
  37. package/skills/agentforce-development/assets/patterns/critical-input-collection.agent +244 -0
  38. package/skills/agentforce-development/assets/patterns/delegation-routing.agent +89 -0
  39. package/skills/agentforce-development/assets/patterns/lifecycle-events.agent +127 -0
  40. package/skills/agentforce-development/assets/patterns/llm-controlled-actions.agent +184 -0
  41. package/skills/agentforce-development/assets/patterns/multi-step-workflow.agent +282 -0
  42. package/skills/agentforce-development/assets/patterns/open-gate-routing.agent +286 -0
  43. package/skills/agentforce-development/assets/patterns/procedural-instructions.agent +273 -0
  44. package/skills/agentforce-development/assets/patterns/prompt-template-action.agent +188 -0
  45. package/skills/agentforce-development/assets/patterns/system-instruction-overrides.agent +293 -0
  46. package/skills/agentforce-development/assets/prompt-rag-search.agent +131 -0
  47. package/skills/agentforce-development/assets/template-multi-topic.agent +160 -0
  48. package/skills/agentforce-development/assets/template-single-topic.agent +81 -0
  49. package/skills/agentforce-development/assets/verification-gate.agent +208 -0
  50. package/skills/agentforce-development/references/action-prompt-templates.md +164 -0
  51. package/skills/agentforce-development/references/actions-reference.md +592 -0
  52. package/skills/agentforce-development/references/agent-access-guide.md +72 -0
  53. package/skills/agentforce-development/references/agent-design-and-spec-creation.md +1010 -0
  54. package/skills/agentforce-development/references/agent-metadata-and-lifecycle.md +575 -0
  55. package/skills/agentforce-development/references/agent-script-core-language.md +1218 -0
  56. package/skills/agentforce-development/references/agent-topic-map-diagrams.md +323 -0
  57. package/skills/agentforce-development/references/agent-user-setup.md +526 -0
  58. package/skills/agentforce-development/references/agent-validation-and-debugging.md +803 -0
  59. package/skills/agentforce-development/references/known-issues.md +353 -0
  60. package/skills/agentforce-development/references/minimal-examples.md +67 -0
  61. package/skills/agentforce-development/references/production-gotchas.md +279 -0
  62. package/skills/agentforce-development/references/salesforce-cli-for-agents.md +393 -0
  63. package/skills/agentforce-development/references/version-history.md +23 -0
  64. package/skills/building-webapp-data-visualization/SKILL.md +72 -0
  65. package/skills/building-webapp-data-visualization/implementation/bar-line-chart.md +316 -0
  66. package/skills/building-webapp-data-visualization/implementation/dashboard-layout.md +189 -0
  67. package/skills/building-webapp-data-visualization/implementation/donut-chart.md +181 -0
  68. package/skills/building-webapp-data-visualization/implementation/stat-card.md +150 -0
  69. package/skills/building-webapp-react-components/SKILL.md +96 -0
  70. package/skills/building-webapp-react-components/implementation/component.md +78 -0
  71. package/skills/building-webapp-react-components/implementation/header-footer.md +132 -0
  72. package/skills/building-webapp-react-components/implementation/page.md +93 -0
  73. package/skills/configuring-webapp-csp-trusted-sites/SKILL.md +90 -0
  74. package/skills/configuring-webapp-csp-trusted-sites/implementation/metadata-format.md +281 -0
  75. package/skills/configuring-webapp-metadata/SKILL.md +158 -0
  76. package/skills/creating-webapp/SKILL.md +141 -0
  77. package/skills/deploying-webapp-to-salesforce/SKILL.md +229 -0
  78. package/skills/exploring-webapp-graphql-schema/SKILL.md +149 -0
  79. package/skills/fetching-webapp-rest-api/SKILL.md +167 -0
  80. package/skills/{salesforce-custom-application → generating-custom-application}/SKILL.md +2 -4
  81. package/skills/{salesforce-custom-field → generating-custom-field}/SKILL.md +1 -5
  82. package/skills/{salesforce-custom-lightning-type → generating-custom-lightning-type}/SKILL.md +36 -2
  83. package/skills/{salesforce-custom-object → generating-custom-object}/SKILL.md +1 -1
  84. package/skills/generating-custom-tab/SKILL.md +154 -0
  85. package/skills/generating-experience-lwr-site/SKILL.md +196 -0
  86. package/skills/generating-experience-lwr-site/docs/bootstrap-template-byo-lwr.md +224 -0
  87. package/skills/generating-experience-lwr-site/docs/configure-content-brandingSet.md +131 -0
  88. package/skills/generating-experience-lwr-site/docs/configure-content-route.md +232 -0
  89. package/skills/generating-experience-lwr-site/docs/configure-content-themeLayout.md +141 -0
  90. package/skills/generating-experience-lwr-site/docs/configure-content-view.md +233 -0
  91. package/skills/generating-experience-lwr-site/docs/configure-guest-sharing-rules.md +42 -0
  92. package/skills/generating-experience-lwr-site/docs/handle-component-and-region-ids.md +27 -0
  93. package/skills/generating-experience-lwr-site/docs/handle-ui-components.md +215 -0
  94. package/skills/generating-experience-react-site/SKILL.md +67 -0
  95. package/skills/generating-experience-react-site/docs/configure-metadata-custom-site.md +41 -0
  96. package/skills/generating-experience-react-site/docs/configure-metadata-digital-experience-bundle.md +17 -0
  97. package/skills/generating-experience-react-site/docs/configure-metadata-digital-experience-config.md +21 -0
  98. package/skills/generating-experience-react-site/docs/configure-metadata-digital-experience.md +38 -0
  99. package/skills/generating-experience-react-site/docs/configure-metadata-network.md +72 -0
  100. package/skills/{salesforce-flexipage → generating-flexipage}/SKILL.md +86 -9
  101. package/skills/{salesforce-flow → generating-flow}/SKILL.md +3 -3
  102. package/skills/generating-fragment/SKILL.md +117 -0
  103. package/skills/generating-lightning-app/SKILL.md +423 -0
  104. package/skills/{salesforce-list-view → generating-list-view}/SKILL.md +1 -1
  105. package/skills/generating-permission-set/SKILL.md +174 -0
  106. package/skills/{salesforce-validation-rule → generating-validation-rule}/SKILL.md +1 -1
  107. package/skills/generating-webapp-graphql-mutation-query/SKILL.md +258 -0
  108. package/skills/generating-webapp-graphql-read-query/SKILL.md +253 -0
  109. package/skills/implementing-webapp-file-upload/SKILL.md +396 -0
  110. package/skills/installing-webapp-features/SKILL.md +210 -0
  111. package/skills/managing-webapp-agentforce-conversation-client/SKILL.md +186 -0
  112. package/skills/managing-webapp-agentforce-conversation-client/references/constraints.md +134 -0
  113. package/skills/managing-webapp-agentforce-conversation-client/references/examples.md +132 -0
  114. package/skills/managing-webapp-agentforce-conversation-client/references/style-tokens.md +101 -0
  115. package/skills/managing-webapp-agentforce-conversation-client/references/troubleshooting.md +57 -0
  116. package/skills/switching-org/SKILL.md +28 -0
  117. package/skills/using-webapp-graphql/SKILL.md +324 -0
  118. package/skills/using-webapp-graphql/shared-schema.graphqls +1150 -0
  119. package/skills/apex-class/SKILL.md +0 -253
  120. package/skills/apex-class/examples/AccountDeduplicationBatch.cls +0 -148
  121. package/skills/apex-class/examples/AccountSelector.cls +0 -193
  122. package/skills/apex-class/examples/AccountService.cls +0 -201
  123. package/skills/apex-class/templates/abstract.cls +0 -128
  124. package/skills/apex-class/templates/batch.cls +0 -125
  125. package/skills/apex-class/templates/domain.cls +0 -102
  126. package/skills/apex-class/templates/dto.cls +0 -108
  127. package/skills/apex-class/templates/exception.cls +0 -51
  128. package/skills/apex-class/templates/interface.cls +0 -25
  129. package/skills/apex-class/templates/queueable.cls +0 -92
  130. package/skills/apex-class/templates/schedulable.cls +0 -75
  131. package/skills/apex-class/templates/selector.cls +0 -92
  132. package/skills/apex-class/templates/service.cls +0 -69
  133. package/skills/apex-class/templates/utility.cls +0 -97
  134. package/skills/apex-test-class/SKILL.md +0 -101
  135. package/skills/apex-test-class/references/assertion-patterns.md +0 -209
  136. package/skills/apex-test-class/references/async-testing.md +0 -276
  137. package/skills/apex-test-class/references/mocking-patterns.md +0 -219
  138. package/skills/apex-test-class/references/test-data-factory.md +0 -176
  139. package/skills/deployment-readiness-check/SKILL.md +0 -257
  140. package/skills/deployment-readiness-check/assets/deployment_checklist.md +0 -286
  141. package/skills/deployment-readiness-check/references/rollback_procedures.md +0 -308
  142. package/skills/deployment-readiness-check/scripts/check_metadata.sh +0 -207
  143. package/skills/salesforce-custom-tab/SKILL.md +0 -78
  144. package/skills/salesforce-experience-site/SKILL.md +0 -178
  145. package/skills/salesforce-fragment/SKILL.md +0 -42
  146. package/skills/salesforce-lightning-app-build/SKILL.md +0 -254
  147. package/skills/salesforce-web-app-creating-records/SKILL.md +0 -84
  148. package/skills/salesforce-web-app-feature/SKILL.md +0 -70
  149. package/skills/salesforce-web-app-list-and-create-records/SKILL.md +0 -36
  150. package/skills/salesforce-web-application/SKILL.md +0 -34
@@ -0,0 +1,127 @@
1
+ # Lifecycle Events Pattern
2
+ # Use before_reasoning and after_reasoning for initialization and cleanup
3
+ #
4
+ # ★ When To Use This Pattern:
5
+ # - Initialize state BEFORE the LLM starts reasoning
6
+ # - Track metrics (turn count, session duration)
7
+ # - Clean up or log AFTER reasoning completes
8
+ # - Set up context that instructions need to reference
9
+ #
10
+ # ★ Key Insight:
11
+ # - before_reasoning: Runs BEFORE each reasoning step (use for setup)
12
+ # - after_reasoning: Runs AFTER each reasoning step (use for cleanup/logging)
13
+ # - These are deterministic - they ALWAYS run, unlike LLM-chosen actions
14
+ #
15
+ # ★ CRITICAL SYNTAX RULES for Lifecycle Blocks:
16
+ # 1. Use "transition to" NOT "@utils.transition to" for transitions
17
+ # 2. The pipe (|) command is NOT supported in lifecycle blocks
18
+ # 3. after_reasoning may NOT run if a transition occurs mid-topic
19
+ # 4. `run` has inconsistent runtime behavior in lifecycle blocks —
20
+ # reliable primitives are `set`, `if`/`else`, `transition to`
21
+ #
22
+ # ★ Common Use Cases:
23
+ # - Increment conversation turn counter
24
+ # - Fetch fresh data before each response
25
+ # - Log conversation analytics after each turn
26
+ # - Reset temporary flags
27
+ # - Conditional routing based on state (use "transition to")
28
+ #
29
+ # This is a PARTIAL template - integrate into a complete agent file
30
+
31
+ # Variables needed for lifecycle tracking
32
+ variables:
33
+ # ... standard linked variables ...
34
+ turn_count: mutable number = 0
35
+ description: "Number of turns in conversation"
36
+ session_start: mutable string = ""
37
+ description: "Timestamp when session started"
38
+ last_activity: mutable string = ""
39
+ description: "Timestamp of last activity"
40
+ current_context: mutable string = ""
41
+ description: "Refreshed context for current turn"
42
+
43
+ topic conversation:
44
+ label: "Conversation"
45
+ description: "Main conversation topic with lifecycle tracking"
46
+
47
+ actions:
48
+ get_timestamp:
49
+ description: "Gets current timestamp"
50
+ outputs:
51
+ current_timestamp: string
52
+ description: "Current ISO timestamp"
53
+ target: "apex://TimeService.getCurrentTimestamp"
54
+
55
+ refresh_context:
56
+ description: "Fetches latest context for user"
57
+ inputs:
58
+ user_id: string
59
+ description: "User to get context for"
60
+ outputs:
61
+ context: string
62
+ description: "User's current context"
63
+ target: "flow://Get_User_Context"
64
+
65
+ log_turn:
66
+ description: "Logs conversation turn analytics"
67
+ inputs:
68
+ turn_number: number
69
+ description: "Which turn this is"
70
+ topic_name: string
71
+ description: "Current topic"
72
+ outputs:
73
+ logged: boolean
74
+ description: "Whether log succeeded"
75
+ target: "apex://AnalyticsService.logTurn"
76
+
77
+ # ★ before_reasoning: Runs BEFORE each reasoning step
78
+ before_reasoning:
79
+ # Increment turn counter
80
+ set @variables.turn_count = @variables.turn_count + 1
81
+
82
+ # On first turn, record session start
83
+ if @variables.turn_count == 1:
84
+ run @actions.get_timestamp
85
+ set @variables.session_start = @outputs.current_timestamp
86
+
87
+ # ★ CORRECT: Use "transition to" (not @utils.transition to) in lifecycle blocks
88
+ # Example: Route away if session expired
89
+ # if @variables.session_expired == True:
90
+ # transition to @topic.session_expired
91
+
92
+ # Refresh context before every turn
93
+ run @actions.refresh_context
94
+ with user_id=@variables.EndUserId
95
+ set @variables.current_context = @outputs.context
96
+
97
+ # Main reasoning block
98
+ reasoning:
99
+ instructions: ->
100
+ | You are on turn {!@variables.turn_count} of this conversation.
101
+ | Session started: {!@variables.session_start}
102
+ |
103
+ | Current user context:
104
+ | {!@variables.current_context}
105
+ |
106
+ | Respond helpfully using the refreshed context above.
107
+ actions:
108
+ end_conversation: @utils.transition to @topic.farewell
109
+
110
+ # ★ after_reasoning: Runs AFTER each reasoning step
111
+ after_reasoning:
112
+ # Log analytics for each turn
113
+ run @actions.log_turn
114
+ with turn_number=@variables.turn_count
115
+ with topic_name="conversation"
116
+
117
+ # Update last activity timestamp
118
+ run @actions.get_timestamp
119
+ set @variables.last_activity = @outputs.current_timestamp
120
+
121
+ # ★ Insight: Lifecycle blocks vs Action callbacks
122
+ #
123
+ # - before_reasoning/after_reasoning: Run every turn, automatic
124
+ # - run callbacks: Run only when parent action is invoked
125
+ #
126
+ # Use lifecycle for: Metrics, context refresh, session management
127
+ # Use callbacks for: Post-action processing, chained operations
@@ -0,0 +1,184 @@
1
+ # LLM-Controlled Actions Pattern
2
+ # Demonstrates both deterministic and LLM-controlled action invocation
3
+ #
4
+ # ★ When To Use This Pattern:
5
+ # - When the LLM should decide which actions to invoke based on context
6
+ # - When actions should only be available under certain conditions
7
+ # - When you want the agent to make intelligent choices about tool usage
8
+ #
9
+ # ★ Key Insight:
10
+ # - Deterministic: "run @actions.x" - ALWAYS runs when code path is reached
11
+ # - LLM-Controlled: "{!@actions.x}" in instructions - LLM decides based on context
12
+ # - Tools in reasoning.actions - LLM chooses which to invoke
13
+ #
14
+ # ★ Two Invocation Methods:
15
+ # 1. Deterministic (run @actions.x): Use in before/after_reasoning, action callbacks
16
+ # 2. LLM-Controlled ({!@actions.x}): Reference in reasoning instructions
17
+ #
18
+ # This is a PARTIAL template - integrate into a complete agent file
19
+
20
+ # Variables for tracking action context
21
+ variables:
22
+ # ... standard linked variables ...
23
+ has_order_id: mutable boolean = False
24
+ description: "Whether user has provided an order ID"
25
+ order_id: mutable string
26
+ description: "The order ID provided by user"
27
+ action_taken: mutable string
28
+ description: "Last action taken by agent"
29
+
30
+ topic order_assistance:
31
+ label: "Order Assistance"
32
+ description: "Helps customers with order-related questions"
33
+
34
+ # Define available actions
35
+ actions:
36
+ get_order_status:
37
+ description: "Retrieves order status by order ID"
38
+ inputs:
39
+ order_id: string
40
+ description: "The order ID to look up"
41
+ outputs:
42
+ status: string
43
+ description: "Current order status"
44
+ delivery_date: string
45
+ description: "Expected delivery date"
46
+ target: "flow://Get_Order_Status"
47
+
48
+ update_order:
49
+ description: "Updates an existing order"
50
+ require_user_confirmation: True # ★ Ask user before executing
51
+ inputs:
52
+ order_id: string
53
+ description: "Order to update"
54
+ changes: string
55
+ description: "Changes to make"
56
+ outputs:
57
+ success: boolean
58
+ description: "Whether update succeeded"
59
+ target: "flow://Update_Order"
60
+
61
+ cancel_order:
62
+ description: "Cancels an order"
63
+ require_user_confirmation: True # ★ Destructive action - confirm first
64
+ include_in_progress_indicator: True
65
+ inputs:
66
+ order_id: string
67
+ description: "Order to cancel"
68
+ reason: string
69
+ description: "Cancellation reason"
70
+ outputs:
71
+ refund_amount: number
72
+ description: "Refund amount"
73
+ filter_from_agent: False # Show this to LLM
74
+ target: "flow://Cancel_Order"
75
+
76
+ log_interaction:
77
+ description: "Logs customer interaction for analytics"
78
+ inputs:
79
+ interaction_type: string
80
+ description: "Type of interaction"
81
+ outputs:
82
+ logged: boolean
83
+ description: "Whether log succeeded"
84
+ target: "flow://Log_Interaction"
85
+
86
+ # ★ Deterministic logging before reasoning
87
+ before_reasoning:
88
+ run @actions.log_interaction
89
+ with interaction_type="order_inquiry"
90
+
91
+ reasoning:
92
+ # ★ LLM-Controlled: Reference actions in natural language
93
+ # The LLM decides when to use these based on conversation context
94
+ instructions: ->
95
+ | Help the customer with their order inquiry.
96
+ |
97
+ | Available capabilities:
98
+ | - Use {!@actions.get_order_status} to look up order details when they provide an order ID
99
+ | - Use {!@actions.update_order} if they want to modify their order (requires confirmation)
100
+ | - Use {!@actions.cancel_order} if they want to cancel (requires confirmation)
101
+ |
102
+ | Always confirm destructive actions before proceeding.
103
+ | If they haven't provided an order ID, ask for it first.
104
+
105
+ # ★ Tools: LLM chooses which to invoke based on conversation
106
+ actions:
107
+ # Slot filling - LLM extracts order_id from conversation
108
+ lookup: @actions.get_order_status
109
+ with order_id=...
110
+ set @variables.order_id = @outputs.status
111
+
112
+ # Conditional availability - only show when order ID is known
113
+ update: @actions.update_order
114
+ with order_id=@variables.order_id
115
+ with changes=...
116
+ available when @variables.has_order_id == True
117
+
118
+ # Conditional availability with multiple conditions
119
+ cancel: @actions.cancel_order
120
+ with order_id=@variables.order_id
121
+ with reason=...
122
+ available when @variables.has_order_id == True
123
+ available when @variables.order_status != "shipped"
124
+
125
+ # Topic transitions
126
+ go_help: @utils.transition to @topic.general_help
127
+ go_escalation: @utils.transition to @topic.escalation
128
+ available when @variables.needs_human == True
129
+
130
+ # ★ Insight: When to Use Each Method
131
+ #
132
+ # DETERMINISTIC (run @actions.x):
133
+ # - Audit logging (must always run)
134
+ # - Required follow-up actions
135
+ # - Guaranteed side effects
136
+ # - In before_reasoning / after_reasoning blocks
137
+ # - In action callbacks (run after parent)
138
+ #
139
+ # LLM-CONTROLLED (reasoning.actions or {!@actions.x}):
140
+ # - User-driven choices
141
+ # - Context-dependent operations
142
+ # - Optional actions based on conversation
143
+ # - When intelligence is needed to decide
144
+ #
145
+ # CONDITIONAL (available when):
146
+ # - Guard destructive operations
147
+ # - Show options only when prerequisites met
148
+ # - Enforce business rules
149
+
150
+ # ★ Example: Action Callback Pattern (Deterministic Chaining)
151
+ # Use "run" for guaranteed follow-up actions after a primary action
152
+
153
+ topic checkout:
154
+ label: "Checkout"
155
+ description: "Handles order checkout"
156
+
157
+ actions:
158
+ create_order:
159
+ description: "Creates a new order"
160
+ inputs:
161
+ items: list[string]
162
+ description: "Items to order"
163
+ outputs:
164
+ order_id: string
165
+ description: "Created order ID"
166
+ target: "flow://Create_Order"
167
+
168
+ send_confirmation:
169
+ description: "Sends order confirmation email"
170
+ inputs:
171
+ order_id: string
172
+ description: "Order to confirm"
173
+ target: "flow://Send_Confirmation"
174
+
175
+ reasoning:
176
+ instructions: ->
177
+ | Process the customer's checkout request.
178
+ actions:
179
+ # ★ Action callback: send_confirmation ALWAYS runs after create_order
180
+ process_checkout: @actions.create_order
181
+ with items=...
182
+ set @variables.order_id = @outputs.order_id
183
+ run @actions.send_confirmation # ★ Guaranteed to run
184
+ with order_id=@variables.order_id
@@ -0,0 +1,282 @@
1
+ # Multi-Step Workflow Pattern
2
+ # Track progress through complex multi-stage processes using boolean flags
3
+ #
4
+ # ★ When To Use This Pattern:
5
+ # - User onboarding with multiple steps
6
+ # - Order/checkout processes
7
+ # - Application submissions (loan, support case, etc.)
8
+ # - Any workflow requiring completion tracking
9
+ #
10
+ # ★ Key Insights:
11
+ # - Use boolean flags to track step completion
12
+ # - Use number variable for step counter
13
+ # - Conditionally show instructions based on completion state
14
+ # - Chain actions with `run` for deterministic sequences
15
+ #
16
+ # ★ Why This Pattern:
17
+ # - Clear visibility into workflow progress
18
+ # - Resume interrupted workflows
19
+ # - Prevent skipping required steps
20
+ # - Show progress indicators to users
21
+ #
22
+ # This is a COMPLETE template - customize for your use case
23
+ #
24
+ # ★ Step Guard Pattern (Feb 2026 Community Best Practice):
25
+ # - The topic selector re-evaluates on EVERY user utterance
26
+ # - Without a step guard, follow-up messages ("my email is X") get re-routed
27
+ # - The `if @variables.current_step > 1:` guard in start_agent forces
28
+ # re-entry to the current workflow, bypassing LLM topic selection
29
+ # - Reset current_step to 1 when the workflow completes
30
+
31
+ system:
32
+ instructions: "You are an onboarding assistant. Guide users through the account setup process step by step. Ensure all required steps are completed before finishing."
33
+ messages:
34
+ welcome: "Welcome! I'll help you set up your account. Let's go through this step by step."
35
+ error: "I encountered an issue. Let me try to continue from where we left off."
36
+
37
+ config:
38
+ agent_name: "Onboarding_Agent"
39
+ default_agent_user: "agent@company.salesforce.com"
40
+ agent_label: "Onboarding Assistant"
41
+ description: "Guides users through multi-step onboarding workflow"
42
+
43
+ variables:
44
+ # Standard linked variables
45
+ EndUserId: linked string
46
+ source: @MessagingSession.MessagingEndUserId
47
+ description: "Messaging End User ID"
48
+ RoutableId: linked string
49
+ source: @MessagingSession.Id
50
+ description: "Messaging Session ID"
51
+
52
+ # ★ WORKFLOW PROGRESS TRACKING - Boolean flags for each step
53
+ step_1_account_created: mutable boolean = False
54
+ description: "Step 1: Account has been created"
55
+ step_2_profile_completed: mutable boolean = False
56
+ description: "Step 2: Profile information has been collected"
57
+ step_3_preferences_set: mutable boolean = False
58
+ description: "Step 3: User preferences have been configured"
59
+ step_4_verification_done: mutable boolean = False
60
+ description: "Step 4: Email/phone verification completed"
61
+ onboarding_complete: mutable boolean = False
62
+ description: "All onboarding steps are complete"
63
+
64
+ # ★ STEP COUNTER - For progress indication
65
+ current_step: mutable number = 1
66
+ description: "Current step number (1-4)"
67
+ total_steps: mutable number = 4
68
+ description: "Total number of steps"
69
+
70
+ # Data collected during workflow
71
+ customer_id: mutable string = ""
72
+ description: "Created customer ID"
73
+ user_email: mutable string = ""
74
+ description: "User's email address"
75
+ user_name: mutable string = ""
76
+ description: "User's full name"
77
+ phone_number: mutable string = ""
78
+ description: "User's phone number"
79
+ notification_preference: mutable string = "email"
80
+ description: "Preferred notification method"
81
+ verification_code: mutable string = ""
82
+ description: "Verification code for confirmation"
83
+
84
+ language:
85
+ default_locale: "en_US"
86
+
87
+ start_agent onboarding:
88
+ description: "Multi-step account onboarding workflow"
89
+
90
+ actions:
91
+ # Step 1: Create account
92
+ create_account:
93
+ description: "Create a new customer account"
94
+ inputs:
95
+ email: string
96
+ description: "Customer email address"
97
+ is_required: True
98
+ name: string
99
+ description: "Customer full name"
100
+ is_required: True
101
+ outputs:
102
+ customer_id: string
103
+ description: "Newly created customer ID"
104
+ success: boolean
105
+ description: "Whether account creation succeeded"
106
+ target: "flow://Create_Customer_Account"
107
+
108
+ # Step 2: Update profile
109
+ update_profile:
110
+ description: "Update customer profile information"
111
+ inputs:
112
+ customer_id: string
113
+ description: "Customer ID to update"
114
+ is_required: True
115
+ phone: string
116
+ description: "Phone number"
117
+ is_required: False
118
+ outputs:
119
+ success: boolean
120
+ description: "Whether profile update succeeded"
121
+ target: "flow://Update_Customer_Profile"
122
+
123
+ # Step 3: Set preferences
124
+ set_preferences:
125
+ description: "Configure customer notification preferences"
126
+ inputs:
127
+ customer_id: string
128
+ description: "Customer ID"
129
+ is_required: True
130
+ notification_method: string
131
+ description: "Preferred notification method: email, sms, or both"
132
+ is_required: True
133
+ outputs:
134
+ success: boolean
135
+ description: "Whether preferences were saved"
136
+ target: "flow://Set_Customer_Preferences"
137
+
138
+ # Step 4: Send verification
139
+ send_verification:
140
+ description: "Send verification code to customer"
141
+ inputs:
142
+ customer_id: string
143
+ description: "Customer ID"
144
+ is_required: True
145
+ method: string
146
+ description: "Verification method: email or sms"
147
+ is_required: True
148
+ outputs:
149
+ success: boolean
150
+ description: "Whether verification was sent"
151
+ target: "flow://Send_Verification_Code"
152
+
153
+ # Verify code
154
+ verify_code:
155
+ description: "Verify the customer's code"
156
+ inputs:
157
+ customer_id: string
158
+ description: "Customer ID"
159
+ is_required: True
160
+ code: string
161
+ description: "Verification code entered by user"
162
+ is_required: True
163
+ outputs:
164
+ verified: boolean
165
+ description: "Whether code was correct"
166
+ target: "flow://Verify_Customer_Code"
167
+
168
+ reasoning:
169
+ instructions: ->
170
+ # ★ STEP GUARD — Force re-entry if workflow in progress
171
+ # This prevents the topic selector from re-routing the user
172
+ # mid-workflow when they provide follow-up information
173
+ if @variables.current_step > 1:
174
+ | Continuing your account setup...
175
+ # ★ PROGRESS DISPLAY - Show current status
176
+ | Welcome to account setup!
177
+ | Progress: Step {!@variables.current_step} of {!@variables.total_steps}
178
+ |
179
+ # ★ SHOW COMPLETED STEPS
180
+ if @variables.step_1_account_created == True:
181
+ | ✓ Step 1: Account Created
182
+ if @variables.step_1_account_created == False:
183
+ | ○ Step 1: Create Account (current)
184
+ if @variables.step_2_profile_completed == True:
185
+ | ✓ Step 2: Profile Complete
186
+ if @variables.step_2_profile_completed == False and @variables.step_1_account_created == True:
187
+ | ○ Step 2: Complete Profile (current)
188
+ if @variables.step_3_preferences_set == True:
189
+ | ✓ Step 3: Preferences Set
190
+ if @variables.step_3_preferences_set == False and @variables.step_2_profile_completed == True:
191
+ | ○ Step 3: Set Preferences (current)
192
+ if @variables.step_4_verification_done == True:
193
+ | ✓ Step 4: Verified
194
+ if @variables.step_4_verification_done == False and @variables.step_3_preferences_set == True:
195
+ | ○ Step 4: Verify Account (current)
196
+ |
197
+ # ★ STEP-SPECIFIC INSTRUCTIONS
198
+ if @variables.step_1_account_created == False:
199
+ | Let's start by creating your account.
200
+ | I'll need your email address and full name.
201
+
202
+ if @variables.step_1_account_created == True and @variables.step_2_profile_completed == False:
203
+ | Great! Account created. Now let's complete your profile.
204
+ | What's your phone number? (optional but recommended)
205
+
206
+ if @variables.step_2_profile_completed == True and @variables.step_3_preferences_set == False:
207
+ | Profile saved. Let's set your notification preferences.
208
+ | How would you like to receive notifications: email, sms, or both?
209
+
210
+ if @variables.step_3_preferences_set == True and @variables.step_4_verification_done == False:
211
+ | Almost done! I've sent a verification code.
212
+ | Please enter the code you received.
213
+
214
+ if @variables.onboarding_complete == True:
215
+ | 🎉 Congratulations! Your account is fully set up.
216
+ | Customer ID: {!@variables.customer_id}
217
+ | You're all ready to go!
218
+
219
+ actions:
220
+ # ★ STEP 1: Create Account
221
+ # Uses action chaining with `run` for automatic next step
222
+ do_step_1: @actions.create_account
223
+ with email=...
224
+ with name=...
225
+ set @variables.customer_id = @outputs.customer_id
226
+ set @variables.step_1_account_created = @outputs.success
227
+ set @variables.current_step = 2
228
+ available when @variables.step_1_account_created == False
229
+
230
+ # ★ STEP 2: Update Profile
231
+ do_step_2: @actions.update_profile
232
+ with customer_id=@variables.customer_id
233
+ with phone=...
234
+ set @variables.step_2_profile_completed = @outputs.success
235
+ set @variables.current_step = 3
236
+ available when @variables.step_1_account_created == True
237
+ available when @variables.step_2_profile_completed == False
238
+
239
+ # ★ STEP 3: Set Preferences
240
+ do_step_3: @actions.set_preferences
241
+ with customer_id=@variables.customer_id
242
+ with notification_method=...
243
+ set @variables.step_3_preferences_set = @outputs.success
244
+ set @variables.current_step = 4
245
+ # Automatically trigger verification after preferences
246
+ run @actions.send_verification
247
+ with customer_id=@variables.customer_id
248
+ with method=@variables.notification_preference
249
+ available when @variables.step_2_profile_completed == True
250
+ available when @variables.step_3_preferences_set == False
251
+
252
+ # ★ STEP 4: Verify
253
+ do_step_4: @actions.verify_code
254
+ with customer_id=@variables.customer_id
255
+ with code=...
256
+ set @variables.step_4_verification_done = @outputs.verified
257
+ set @variables.onboarding_complete = @outputs.verified
258
+ available when @variables.step_3_preferences_set == True
259
+ available when @variables.step_4_verification_done == False
260
+
261
+ # ★ Insight: Multi-Step Workflow Best Practices
262
+ #
263
+ # BOOLEAN FLAGS:
264
+ # - One flag per step for clear completion tracking
265
+ # - Use meaningful names: step_1_account_created, not flag1
266
+ # - Check flags to enable/disable actions
267
+ #
268
+ # STEP COUNTER:
269
+ # - Provides simple progress indication
270
+ # - Can be used in template expressions for display
271
+ #
272
+ # ACTION AVAILABILITY:
273
+ # - Use `available when` to prevent out-of-order execution
274
+ # - Multiple `available when` clauses work as AND conditions
275
+ #
276
+ # ACTION CHAINING:
277
+ # - Use `run` for automatic sequential actions
278
+ # - Good for: send confirmation after save, log after complete
279
+ #
280
+ # RESUME CAPABILITY:
281
+ # - Boolean flags persist across conversation turns
282
+ # - User can pick up where they left off