@salesforce/afv-skills 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/package.json +4 -4
  2. package/skills/agentforce-development/SKILL.md +427 -0
  3. package/skills/agentforce-development/assets/README-legacy.md +89 -0
  4. package/skills/agentforce-development/assets/agent-spec-template.md +90 -0
  5. package/skills/agentforce-development/assets/agents/README.md +45 -0
  6. package/skills/agentforce-development/assets/agents/hello-world.agent +60 -0
  7. package/skills/agentforce-development/assets/agents/multi-topic.agent +105 -0
  8. package/skills/agentforce-development/assets/agents/production-faq.agent +101 -0
  9. package/skills/agentforce-development/assets/agents/production-faq.bundle-meta.xml +4 -0
  10. package/skills/agentforce-development/assets/agents/simple-qa.agent +72 -0
  11. package/skills/agentforce-development/assets/apex/models-api-queueable.cls +225 -0
  12. package/skills/agentforce-development/assets/bundle-meta.xml +23 -0
  13. package/skills/agentforce-development/assets/components/apex-action.agent +52 -0
  14. package/skills/agentforce-development/assets/components/error-handling.agent +58 -0
  15. package/skills/agentforce-development/assets/components/escalation-setup.agent +169 -0
  16. package/skills/agentforce-development/assets/components/flow-action.agent +66 -0
  17. package/skills/agentforce-development/assets/components/n-ary-conditions.agent +110 -0
  18. package/skills/agentforce-development/assets/components/topic-with-actions.agent +40 -0
  19. package/skills/agentforce-development/assets/deterministic-routing.agent +166 -0
  20. package/skills/agentforce-development/assets/escalation-pattern.agent +209 -0
  21. package/skills/agentforce-development/assets/flow-action-lookup.agent +115 -0
  22. package/skills/agentforce-development/assets/hub-and-spoke.agent +104 -0
  23. package/skills/agentforce-development/assets/invocable-apex-template.cls +187 -0
  24. package/skills/agentforce-development/assets/local-info-agent-annotated.agent +355 -0
  25. package/skills/agentforce-development/assets/metadata/basic-prompt-template.promptTemplate-meta.xml +109 -0
  26. package/skills/agentforce-development/assets/metadata/genai-function-apex.xml +92 -0
  27. package/skills/agentforce-development/assets/metadata/genai-function-flow.xml +57 -0
  28. package/skills/agentforce-development/assets/metadata/genai-plugin.xml +72 -0
  29. package/skills/agentforce-development/assets/metadata/http-callout-flow.flow-meta.xml +348 -0
  30. package/skills/agentforce-development/assets/metadata/record-grounded-prompt.promptTemplate-meta.xml +136 -0
  31. package/skills/agentforce-development/assets/minimal-starter.agent +42 -0
  32. package/skills/agentforce-development/assets/patterns/README.md +254 -0
  33. package/skills/agentforce-development/assets/patterns/action-callbacks.agent +178 -0
  34. package/skills/agentforce-development/assets/patterns/advanced-input-bindings.agent +141 -0
  35. package/skills/agentforce-development/assets/patterns/bidirectional-routing.agent +156 -0
  36. package/skills/agentforce-development/assets/patterns/critical-input-collection.agent +244 -0
  37. package/skills/agentforce-development/assets/patterns/delegation-routing.agent +89 -0
  38. package/skills/agentforce-development/assets/patterns/lifecycle-events.agent +127 -0
  39. package/skills/agentforce-development/assets/patterns/llm-controlled-actions.agent +184 -0
  40. package/skills/agentforce-development/assets/patterns/multi-step-workflow.agent +282 -0
  41. package/skills/agentforce-development/assets/patterns/open-gate-routing.agent +286 -0
  42. package/skills/agentforce-development/assets/patterns/procedural-instructions.agent +273 -0
  43. package/skills/agentforce-development/assets/patterns/prompt-template-action.agent +188 -0
  44. package/skills/agentforce-development/assets/patterns/system-instruction-overrides.agent +293 -0
  45. package/skills/agentforce-development/assets/prompt-rag-search.agent +131 -0
  46. package/skills/agentforce-development/assets/template-multi-topic.agent +160 -0
  47. package/skills/agentforce-development/assets/template-single-topic.agent +81 -0
  48. package/skills/agentforce-development/assets/verification-gate.agent +208 -0
  49. package/skills/agentforce-development/references/action-prompt-templates.md +164 -0
  50. package/skills/agentforce-development/references/actions-reference.md +592 -0
  51. package/skills/agentforce-development/references/agent-access-guide.md +72 -0
  52. package/skills/agentforce-development/references/agent-design-and-spec-creation.md +1010 -0
  53. package/skills/agentforce-development/references/agent-metadata-and-lifecycle.md +575 -0
  54. package/skills/agentforce-development/references/agent-script-core-language.md +1218 -0
  55. package/skills/agentforce-development/references/agent-topic-map-diagrams.md +323 -0
  56. package/skills/agentforce-development/references/agent-user-setup.md +526 -0
  57. package/skills/agentforce-development/references/agent-validation-and-debugging.md +803 -0
  58. package/skills/agentforce-development/references/known-issues.md +353 -0
  59. package/skills/agentforce-development/references/minimal-examples.md +67 -0
  60. package/skills/agentforce-development/references/production-gotchas.md +279 -0
  61. package/skills/agentforce-development/references/salesforce-cli-for-agents.md +393 -0
  62. package/skills/agentforce-development/references/version-history.md +23 -0
  63. package/skills/generate-permission-set/SKILL.md +174 -0
  64. package/skills/salesforce-custom-application/SKILL.md +1 -2
  65. package/skills/salesforce-custom-field/SKILL.md +0 -4
  66. package/skills/salesforce-custom-tab/SKILL.md +84 -8
  67. package/skills/salesforce-experience-lwr-site/SKILL.md +196 -0
  68. package/skills/salesforce-experience-lwr-site/docs/bootstrap-template-byo-lwr.md +224 -0
  69. package/skills/salesforce-experience-lwr-site/docs/configure-content-brandingSet.md +131 -0
  70. package/skills/salesforce-experience-lwr-site/docs/configure-content-route.md +232 -0
  71. package/skills/salesforce-experience-lwr-site/docs/configure-content-themeLayout.md +141 -0
  72. package/skills/salesforce-experience-lwr-site/docs/configure-content-view.md +233 -0
  73. package/skills/salesforce-experience-lwr-site/docs/configure-guest-sharing-rules.md +42 -0
  74. package/skills/salesforce-experience-lwr-site/docs/handle-component-and-region-ids.md +27 -0
  75. package/skills/salesforce-experience-lwr-site/docs/handle-ui-components.md +215 -0
  76. package/skills/salesforce-flow/SKILL.md +2 -2
  77. package/skills/salesforce-fragment/SKILL.md +85 -10
  78. package/skills/salesforce-lightning-app-build/SKILL.md +102 -10
  79. package/skills/apex-class/SKILL.md +0 -253
  80. package/skills/apex-class/examples/AccountDeduplicationBatch.cls +0 -148
  81. package/skills/apex-class/examples/AccountSelector.cls +0 -193
  82. package/skills/apex-class/examples/AccountService.cls +0 -201
  83. package/skills/apex-class/templates/abstract.cls +0 -128
  84. package/skills/apex-class/templates/batch.cls +0 -125
  85. package/skills/apex-class/templates/domain.cls +0 -102
  86. package/skills/apex-class/templates/dto.cls +0 -108
  87. package/skills/apex-class/templates/exception.cls +0 -51
  88. package/skills/apex-class/templates/interface.cls +0 -25
  89. package/skills/apex-class/templates/queueable.cls +0 -92
  90. package/skills/apex-class/templates/schedulable.cls +0 -75
  91. package/skills/apex-class/templates/selector.cls +0 -92
  92. package/skills/apex-class/templates/service.cls +0 -69
  93. package/skills/apex-class/templates/utility.cls +0 -97
  94. package/skills/apex-test-class/SKILL.md +0 -101
  95. package/skills/apex-test-class/references/assertion-patterns.md +0 -209
  96. package/skills/apex-test-class/references/async-testing.md +0 -276
  97. package/skills/apex-test-class/references/mocking-patterns.md +0 -219
  98. package/skills/apex-test-class/references/test-data-factory.md +0 -176
  99. package/skills/deployment-readiness-check/SKILL.md +0 -257
  100. package/skills/deployment-readiness-check/assets/deployment_checklist.md +0 -286
  101. package/skills/deployment-readiness-check/references/rollback_procedures.md +0 -308
  102. package/skills/deployment-readiness-check/scripts/check_metadata.sh +0 -207
  103. package/skills/salesforce-experience-site/SKILL.md +0 -178
@@ -0,0 +1,52 @@
1
+ # Apex-Based Action Template
2
+ # Define an action that calls a Salesforce Apex @InvocableMethod
3
+ # This is a PARTIAL template - define actions inside a topic block
4
+ #
5
+ # Usage: Replace {{placeholders}} with your values
6
+ # Place this inside a topic's actions: block
7
+ #
8
+ # ⚠️ The target format is apex://ClassName (NOT ClassName.MethodName)
9
+ # The runtime auto-discovers the @InvocableMethod on the class.
10
+ # ⚠️ NO GenAiFunction metadata needed for AiAuthoringBundle (Agent Script).
11
+
12
+ # Action Definition (place inside topic's actions: block)
13
+ {{action_name}}:
14
+ description: "{{ActionDescription}}"
15
+ inputs:
16
+ {{input_1_name}}: {{input_1_type}}
17
+ description: "{{Input1Description}}"
18
+ {{input_2_name}}: {{input_2_type}}
19
+ description: "{{Input2Description}}"
20
+ outputs:
21
+ {{output_1_name}}: {{output_1_type}}
22
+ description: "{{Output1Description}}"
23
+ success: boolean
24
+ description: "Whether the operation succeeded"
25
+ error_message: string
26
+ description: "Error message if operation failed"
27
+ target: "apex://{{ApexClassName}}"
28
+
29
+ # Usage in reasoning block:
30
+ #
31
+ # reasoning:
32
+ # instructions: ->
33
+ # | Help the user with their request.
34
+ # actions:
35
+ # invoke_{{action_name}}: @actions.{{action_name}}
36
+ # with {{input_1_name}}=... # LLM fills from conversation
37
+ # with {{input_2_name}}=@variables.some_var # From variable
38
+ # set @variables.result = @outputs.{{output_1_name}}
39
+ # set @variables.success = @outputs.success
40
+
41
+ # Common Apex Target Patterns:
42
+ # - apex://AccountService
43
+ # - apex://CaseService
44
+ # - apex://OrderService
45
+ # - apex://IntegrationService
46
+ # - apex://CalculationService
47
+
48
+ # Apex Class Requirements:
49
+ # - Must be global or public with sharing
50
+ # - Must have exactly ONE @InvocableMethod annotation
51
+ # - Use @InvocableVariable annotations on input/output wrapper class fields
52
+ # - No GenAiFunction metadata needed for AiAuthoringBundle (Agent Script)
@@ -0,0 +1,58 @@
1
+ # Error Handling Topic Template
2
+ # A topic with validation and guard clauses for critical operations
3
+ # This is a PARTIAL template - use within a complete agent file
4
+ #
5
+ # Usage: Replace {{placeholders}} with your values
6
+ # Note: Includes validation patterns and error handling
7
+
8
+ topic {{topic_name}}:
9
+ label: "{{TopicLabel}}"
10
+ description: "{{TopicDescription}} - includes validation and error handling"
11
+
12
+ actions:
13
+ {{action_name}}:
14
+ description: "{{ActionDescription}}"
15
+ inputs:
16
+ {{input_name}}: {{input_type}}
17
+ description: "{{InputDescription}}"
18
+ outputs:
19
+ success: boolean
20
+ description: "Whether the operation succeeded"
21
+ error_message: string
22
+ description: "Error message if operation failed"
23
+ {{output_name}}: {{output_type}}
24
+ description: "{{OutputDescription}}"
25
+ target: "{{ActionTarget}}"
26
+
27
+ reasoning:
28
+ instructions: ->
29
+ # Validation guard clauses
30
+ if @variables.{{required_field}} is None:
31
+ set @variables.validation_passed = False
32
+ | I need {{RequiredFieldDescription}} before I can proceed.
33
+ | Please provide this information.
34
+
35
+ if @variables.{{amount_field}} > {{MaxAmount}}:
36
+ set @variables.validation_passed = False
37
+ | The {{AmountFieldDescription}} exceeds the maximum of {{MaxAmount}}.
38
+ | Would you like to:
39
+ | - Use the maximum allowed amount
40
+ | - Split into multiple operations
41
+ | - Contact support for a higher limit
42
+
43
+ if @variables.validation_passed == True:
44
+ | All validations passed. Proceeding with the operation.
45
+
46
+ actions:
47
+ # Only available when validation passes
48
+ execute_action: @actions.{{action_name}}
49
+ with {{input_name}}=@variables.{{input_variable}}
50
+ set @variables.operation_success = @outputs.success
51
+ set @variables.result = @outputs.{{output_name}}
52
+ available when @variables.validation_passed == True
53
+
54
+ # Handle errors
55
+ retry_operation: @utils.transition to @topic.{{topic_name}}
56
+ available when @variables.operation_success == False
57
+
58
+ back_to_menu: @utils.transition to @topic.topic_selector
@@ -0,0 +1,169 @@
1
+ # Escalation Setup Pattern
2
+ # Complete agent template with connection block for human escalation
3
+ #
4
+ # ★ When To Use This Pattern:
5
+ # - Agent needs to transfer conversations to human agents
6
+ # - Using Omni-Channel for routing
7
+ # - Enhanced Chat or other messaging channels
8
+ #
9
+ # ★ Key Components:
10
+ # 1. connection messaging: block - defines routing destination
11
+ # 2. @utils.escalate action - triggers the transfer
12
+ # 3. escalation topic - handles the handoff flow
13
+ #
14
+ # ★ Prerequisites:
15
+ # - Omni-Channel configured in Salesforce
16
+ # - Queue/Skill created for routing
17
+ # - Messaging channel active (Enhanced Chat, etc.)
18
+ #
19
+ # This is a COMPLETE template - customize for your use case
20
+
21
+ system:
22
+ instructions: "You are a helpful customer service agent. Be professional, friendly, and helpful. If you cannot resolve an issue or the customer requests a human, transfer them to a live agent."
23
+ messages:
24
+ welcome: "Hello! I'm here to help you today. What can I assist you with?"
25
+ error: "I apologize, but I encountered an issue. Let me connect you with a human agent."
26
+
27
+ config:
28
+ agent_name: "{{AGENT_NAME}}"
29
+ default_agent_user: "{{AGENT_USER_EMAIL}}"
30
+ agent_label: "{{AGENT_LABEL}}"
31
+ description: "Customer service agent with human escalation capability"
32
+
33
+ variables:
34
+ # Required linked variables for messaging context
35
+ EndUserId: linked string
36
+ source: @MessagingSession.MessagingEndUserId
37
+ description: "Messaging End User ID"
38
+ RoutableId: linked string
39
+ source: @MessagingSession.Id
40
+ description: "Messaging Session ID"
41
+ ContactId: linked string
42
+ source: @MessagingEndUser.ContactId
43
+ description: "Contact ID"
44
+
45
+ # Escalation tracking variables
46
+ escalation_requested: mutable boolean = False
47
+ description: "Whether customer requested human agent"
48
+ escalation_reason: mutable string
49
+ description: "Reason for escalation"
50
+ # ⚠️ Use 'number' not 'integer' - integer type is NOT supported in AiAuthoringBundle
51
+ attempts_before_escalation: mutable number = 0
52
+ description: "Number of attempts before escalating"
53
+
54
+ language:
55
+ default_locale: "en_US"
56
+ additional_locales: ""
57
+ all_additional_locales: False
58
+
59
+ # ★ CONNECTION BLOCK - Required for @utils.escalate to work
60
+ # This defines where escalated conversations are routed
61
+ # Use singular 'connection' for one channel, plural 'connections' for multiple
62
+ connection messaging:
63
+ # ⚠️ IMPORTANT: Only "OmniChannelFlow" is supported (not "queue", "skill", or "agent")
64
+ outbound_route_type: "OmniChannelFlow"
65
+ # API name of your Omni-Channel Flow
66
+ outbound_route_name: "{{OMNI_CHANNEL_FLOW_NAME}}"
67
+ # ⚠️ REQUIRED: escalation_message must be included when connection block is present
68
+ escalation_message: "Transferring you to a human agent now..."
69
+ # Optional: Allow agent to adapt responses during escalation
70
+ adaptive_response_allowed: True
71
+
72
+ # ★ MULTI-CHANNEL EXAMPLE (use 'connections' plural for multiple channels)
73
+ # connections:
74
+ # messaging:
75
+ # outbound_route_type: "OmniChannelFlow"
76
+ # outbound_route_name: "Chat_Support_Flow"
77
+ # escalation_message: "Connecting you to chat support..."
78
+ # adaptive_response_allowed: True
79
+ # telephony:
80
+ # outbound_route_type: "OmniChannelFlow"
81
+ # outbound_route_name: "Phone_Support_Flow"
82
+ # escalation_message: "Transferring to phone support..."
83
+ # adaptive_response_allowed: False
84
+
85
+ # Entry point
86
+ start_agent topic_selector:
87
+ label: "Topic Selector"
88
+ description: "Routes users to appropriate topics based on intent"
89
+
90
+ reasoning:
91
+ instructions: ->
92
+ | Greet the customer and determine their needs.
93
+ | If they ask for a human or live agent, route to escalation.
94
+ | Otherwise, try to help them directly.
95
+ actions:
96
+ go_help: @utils.transition to @topic.help
97
+ go_escalation: @utils.transition to @topic.escalation
98
+ available when @variables.escalation_requested == True
99
+
100
+ topic help:
101
+ label: "Help"
102
+ description: "Provides assistance to customers"
103
+
104
+ reasoning:
105
+ instructions: ->
106
+ | Help the customer with their question.
107
+ | If you cannot resolve their issue after 2-3 attempts, offer to connect them with a human.
108
+ | If they explicitly ask for a human agent at any time, transfer immediately.
109
+ |
110
+ | Phrases that indicate escalation request:
111
+ | - "talk to a human"
112
+ | - "speak to someone"
113
+ | - "real person"
114
+ | - "live agent"
115
+ | - "customer service representative"
116
+ |
117
+ | Track escalation reason if provided:
118
+ set @variables.escalation_reason = ...
119
+ actions:
120
+ offer_escalation: @utils.transition to @topic.escalation
121
+
122
+ immediate_escalation: @utils.transition to @topic.escalation
123
+
124
+ topic escalation:
125
+ label: "Escalation"
126
+ description: "Transfers conversation to human agent"
127
+
128
+ reasoning:
129
+ instructions: ->
130
+ | The customer is being transferred to a human agent.
131
+ | Acknowledge their request and apologize for any inconvenience.
132
+ | Let them know a human will be with them shortly.
133
+ |
134
+ | Say something like:
135
+ | "I understand you'd like to speak with a human agent. I'm connecting you now.
136
+ | A customer service representative will be with you shortly. Thank you for your patience."
137
+ actions:
138
+ # ★ ESCALATION ACTION
139
+ # This transfers the conversation to the queue defined in connection block
140
+ transfer_to_human: @utils.escalate
141
+ description: "Transfer to human agent when customer requests or issue cannot be resolved"
142
+
143
+ # ★ NOTE: Skill-Based and Queue-Based Routing
144
+ # ⚠️ As of Dec 2025, only "OmniChannelFlow" is supported for outbound_route_type
145
+ # "queue", "skill", and "agent" cause validation errors
146
+ # You must create an Omni-Channel Flow that routes to your desired queue/skill
147
+
148
+ # ★ Alternative: GenAiPlannerBundle Escalation with Reason
149
+ # If using GenAiPlannerBundle (not visible in Studio), you can use:
150
+ #
151
+ # actions:
152
+ # escalate_with_reason: @utils.escalate with reason="Customer requested human assistance"
153
+ #
154
+ # NOTE: The "with reason" syntax only works in GenAiPlannerBundle!
155
+ # AiAuthoringBundle will fail with SyntaxError if you use it.
156
+
157
+ # ★ Troubleshooting Escalation:
158
+ #
159
+ # Issue: "escalate" action not recognized
160
+ # Fix: Add the connection messaging: block
161
+ #
162
+ # Issue: Transfer fails silently
163
+ # Fix: Verify Omni-Channel queue exists and has available agents
164
+ #
165
+ # Issue: SyntaxError: Unexpected 'with'
166
+ # Fix: You're using AiAuthoringBundle - remove "with reason" syntax
167
+ #
168
+ # Issue: Agent user lacks permissions
169
+ # Fix: Grant Omni-Channel permissions to the default_agent_user
@@ -0,0 +1,66 @@
1
+ # Flow-Based Action Template
2
+ # Define an action that calls a Salesforce Flow
3
+ # This is a PARTIAL template - define actions inside a topic block
4
+ #
5
+ # ⚠️ NOTE ON DEPLOYMENT METHODS:
6
+ # - AiAuthoringBundle: `with`/`set` clauses ARE supported (TDD validated v1.7.0+)
7
+ # - GenAiPlannerBundle: Full syntax including `with`/`set` also supported
8
+ #
9
+ # Both deployment methods support the Two-Level Action System:
10
+ # Level 1: Action definition in topic `actions:` block (with target/inputs/outputs)
11
+ # Level 2: Action invocation in `reasoning.actions:` block (with `with`/`set` clauses)
12
+ #
13
+ # Usage: Replace {{placeholders}} with your values
14
+ # Place this inside a topic's actions: block
15
+
16
+ # Action Definition (place inside topic's actions: block)
17
+ {{action_name}}:
18
+ description: "{{ActionDescription}}"
19
+ inputs:
20
+ {{input_1_name}}: {{input_1_type}}
21
+ description: "{{Input1Description}}"
22
+ {{input_2_name}}: {{input_2_type}}
23
+ description: "{{Input2Description}}"
24
+ outputs:
25
+ {{output_1_name}}: {{output_1_type}}
26
+ description: "{{Output1Description}}"
27
+ {{output_2_name}}: {{output_2_type}}
28
+ description: "{{Output2Description}}"
29
+ target: "flow://{{FlowApiName}}"
30
+
31
+ # Usage in reasoning block:
32
+ #
33
+ # ═══════════════════════════════════════════════════════════════════════════════
34
+ # ✅ Recommended Pattern — Level 2 invocation with `with`/`set` (works in both
35
+ # AiAuthoringBundle and GenAiPlannerBundle, TDD validated v1.7.0+)
36
+ # ═══════════════════════════════════════════════════════════════════════════════
37
+ #
38
+ # reasoning:
39
+ # instructions: ->
40
+ # | Help the user with their request.
41
+ # actions:
42
+ # invoke_{{action_name}}: @actions.{{action_name}}
43
+ # with {{input_1_name}}=... # LLM fills from conversation
44
+ # with {{input_2_name}}=@variables.some_var # From variable
45
+ # set @variables.result1 = @outputs.{{output_1_name}}
46
+ # set @variables.result2 = @outputs.{{output_2_name}}
47
+ #
48
+ # ═══════════════════════════════════════════════════════════════════════════════
49
+ # Alternative: LLM auto-invoke based on action description (no explicit binding)
50
+ # ═══════════════════════════════════════════════════════════════════════════════
51
+ #
52
+ # reasoning:
53
+ # instructions: ->
54
+ # | Help the user with their request.
55
+ # | Use the available actions when needed.
56
+ # actions:
57
+ # back_to_menu: @utils.transition to @topic.topic_selector
58
+
59
+ # Common Flow Target Patterns:
60
+ # - flow://Get_Account_Details
61
+ # - flow://Create_Case
62
+ # - flow://Update_Opportunity
63
+ # - flow://Send_Email_Notification
64
+ # - flow://Calculate_Discount
65
+
66
+ # Input/Output Types: string, number, boolean, list[string], object
@@ -0,0 +1,110 @@
1
+ # N-ary Boolean Conditions Template
2
+ # Demonstrates using 3+ conditions with and/or operators
3
+ #
4
+ # This is a PARTIAL template - integrate into a complete agent file
5
+ #
6
+ # ★ KEY CONCEPTS:
7
+ #
8
+ # N-ary AND: All conditions must be true
9
+ # N-ary OR: At least one condition must be true
10
+ # Grouping: Use () for complex expressions
11
+ #
12
+ # ★ Supported Contexts:
13
+ # - if statements in before_reasoning/after_reasoning
14
+ # - available when clauses on actions
15
+ #
16
+ # ★ Common Mistake:
17
+ # DO NOT nest if statements. Use N-ary and/or instead.
18
+ # ❌ if a: if b: if c: (nested - INVALID)
19
+ # ✅ if a and b and c: (flat - CORRECT)
20
+
21
+ # ═══════════════════════════════════════════════════════════════
22
+ # PATTERN 1: Three+ AND conditions in lifecycle
23
+ # ═══════════════════════════════════════════════════════════════
24
+
25
+ # Example: Require multiple authentication checks
26
+ topic secure_action:
27
+ label: "Secure Action"
28
+ description: "Performs security-sensitive operations"
29
+
30
+ before_reasoning:
31
+ # All three conditions must be true
32
+ if @variables.is_authenticated and @variables.has_permission and @variables.session_valid:
33
+ transition to @topic.authorized_action
34
+ # Otherwise stay in this topic
35
+
36
+ reasoning:
37
+ instructions: ->
38
+ | User needs to authenticate before proceeding.
39
+
40
+ # ═══════════════════════════════════════════════════════════════
41
+ # PATTERN 2: Three+ OR conditions in lifecycle
42
+ # ═══════════════════════════════════════════════════════════════
43
+
44
+ # Example: Any elevated role gets access
45
+ topic admin_panel:
46
+ label: "Admin Panel"
47
+ description: "Administrative features"
48
+
49
+ before_reasoning:
50
+ # Any one of these roles grants access
51
+ if @variables.is_admin or @variables.is_moderator or @variables.is_superuser:
52
+ transition to @topic.admin_features
53
+ # Non-admins redirected
54
+ transition to @topic.access_denied
55
+
56
+ # ═══════════════════════════════════════════════════════════════
57
+ # PATTERN 3: N-ary conditions in available when
58
+ # ═══════════════════════════════════════════════════════════════
59
+
60
+ topic order_management:
61
+ label: "Order Management"
62
+ description: "Handles order operations"
63
+
64
+ reasoning:
65
+ instructions: ->
66
+ | Help the customer with their order.
67
+ actions:
68
+ # Action available only when ALL conditions met
69
+ process_return: @actions.handle_return
70
+ description: "Process a return request"
71
+ available when @variables.order_exists == True and @variables.within_return_window == True and @variables.item_eligible == True
72
+
73
+ # Action available when ANY premium tier matches
74
+ use_priority: @actions.priority_service
75
+ description: "Use priority service queue"
76
+ available when @variables.tier == "gold" or @variables.tier == "platinum" or @variables.tier == "enterprise"
77
+
78
+ # Mixed: specific product AND any valid status
79
+ expedite: @actions.expedite_order
80
+ description: "Expedite the current order"
81
+ available when @variables.product_type == "perishable" and (@variables.status == "pending" or @variables.status == "processing")
82
+
83
+ # ═══════════════════════════════════════════════════════════════
84
+ # PATTERN 4: Complex grouped conditions
85
+ # ═══════════════════════════════════════════════════════════════
86
+
87
+ topic smart_routing:
88
+ label: "Smart Routing"
89
+ description: "Routes based on complex criteria"
90
+
91
+ before_reasoning:
92
+ # Premium with any product type OR standard with warranty
93
+ if (@variables.tier == "premium" and @variables.product_type != None) or (@variables.tier == "standard" and @variables.has_warranty == True):
94
+ transition to @topic.priority_support
95
+
96
+ # ═══════════════════════════════════════════════════════════════
97
+ # ANTI-PATTERNS - DO NOT USE
98
+ # ═══════════════════════════════════════════════════════════════
99
+
100
+ # ❌ WRONG - Nested if statements (causes "Missing required element" error)
101
+ # before_reasoning:
102
+ # if @variables.a == True:
103
+ # if @variables.b == True:
104
+ # if @variables.c == True:
105
+ # transition to @topic.x
106
+
107
+ # ✅ CORRECT - Flat N-ary condition
108
+ # before_reasoning:
109
+ # if @variables.a == True and @variables.b == True and @variables.c == True:
110
+ # transition to @topic.x
@@ -0,0 +1,40 @@
1
+ # Topic with Actions Template
2
+ # A topic that integrates with external systems via Flow or Apex actions
3
+ # This is a PARTIAL template - use within a complete agent file
4
+ #
5
+ # Two-Level Action System:
6
+ # Level 1: topic.actions block DEFINES actions (with target:, inputs:, outputs:)
7
+ # Level 2: reasoning.actions block INVOKES them (with @actions.name, with/set)
8
+ #
9
+ # Usage: Replace {{placeholders}} with your values
10
+ # Note: Actions defined inside topic are local to that topic
11
+
12
+ topic {{topic_name}}:
13
+ description: "{{TopicDescription}}"
14
+
15
+ # Level 1: DEFINE actions available to this topic
16
+ actions:
17
+ {{action_name}}:
18
+ description: "{{ActionDescription}}"
19
+ inputs:
20
+ {{input_name}}: {{input_type}}
21
+ description: "{{InputDescription}}"
22
+ outputs:
23
+ {{output_name}}: {{output_type}}
24
+ description: "{{OutputDescription}}"
25
+ target: "{{ActionTarget}}" # flow://FlowName or apex://ClassName
26
+
27
+ reasoning:
28
+ instructions: ->
29
+ | {{TopicInstructions}}
30
+ | Use the available actions to help the user.
31
+ | Capture and communicate results clearly.
32
+
33
+ # Level 2: INVOKE the actions defined above
34
+ actions:
35
+ invoke_action: @actions.{{action_name}}
36
+ with {{input_name}}=...
37
+ set @variables.{{result_variable}} = @outputs.{{output_name}}
38
+
39
+ back_to_menu: @utils.transition to @topic.topic_selector
40
+ description: "Return to main menu"
@@ -0,0 +1,166 @@
1
+ # Deterministic Routing Template (Zero-Hallucination Pattern)
2
+ # ============================================================
3
+ #
4
+ # This template demonstrates the zero-hallucination intent classification
5
+ # pattern using action output flags to control LLM behavior.
6
+ #
7
+ # Pattern: Classify intent deterministically, route without hallucination
8
+ # Use when: Critical routing decisions that must not be influenced by LLM creativity
9
+ #
10
+ # KEY PATTERN:
11
+ # In Agentforce Assets, set action outputs with:
12
+ # - is_displayable: False (LLM cannot show this to user)
13
+ # - is_used_by_planner: True (LLM can use for routing)
14
+ #
15
+ # This ensures the LLM routes based on classification but cannot
16
+ # generate hallucinated responses based on the classification data.
17
+
18
+ system:
19
+ messages:
20
+ welcome: "Hello! How can I help you today?"
21
+ error: "I apologize, something went wrong. Let me try again."
22
+ instructions: "You are a customer service agent. Route users to the correct department based on their intent."
23
+
24
+ config:
25
+ agent_name: "DeterministicRoutingAgent"
26
+ agent_label: "Smart Router Agent"
27
+ description: "Agent demonstrating zero-hallucination intent routing pattern"
28
+ default_agent_user: "agent@yourorg.com" # REQUIRED: Change to valid Einstein Agent User
29
+
30
+ variables:
31
+ # Intent classification (populated by action with is_displayable: False)
32
+ classified_intent: mutable string = ""
33
+ description: "Classification result - hidden from user responses"
34
+ confidence_score: mutable number = 0
35
+ description: "Classification confidence (0-100)"
36
+
37
+ # Routing state
38
+ needs_classification: mutable boolean = True
39
+ description: "Whether user intent needs classification"
40
+ low_confidence_warning: mutable boolean = False
41
+ description: "Flag for low confidence routing"
42
+
43
+ start_agent topic_selector:
44
+ description: "Classify intent and route deterministically"
45
+ reasoning:
46
+ instructions: ->
47
+ # ====================================================
48
+ # DETERMINISTIC ROUTING (based on classified_intent)
49
+ # ====================================================
50
+
51
+ # Route ONLY when classification is complete
52
+ if @variables.needs_classification == False:
53
+
54
+ # HIGH-CONFIDENCE ROUTING
55
+ if @variables.confidence_score >= 80:
56
+ if @variables.classified_intent == "billing":
57
+ transition to @topic.billing
58
+ if @variables.classified_intent == "technical_support":
59
+ transition to @topic.technical_support
60
+ if @variables.classified_intent == "sales":
61
+ transition to @topic.sales
62
+ if @variables.classified_intent == "returns":
63
+ transition to @topic.returns
64
+
65
+ # LOW-CONFIDENCE: Confirm with user
66
+ if @variables.confidence_score < 80:
67
+ set @variables.low_confidence_warning = True
68
+ | I want to make sure I route you correctly.
69
+ | It sounds like you need help with **{!@variables.classified_intent}**.
70
+ | Is that correct?
71
+
72
+ # INITIAL STATE: Ask for help topic
73
+ if @variables.needs_classification == True:
74
+ | I can help with billing, technical support, sales, or returns.
75
+ | What do you need help with today?
76
+
77
+ actions:
78
+ # CRITICAL: This action's outputs must be configured in Agentforce Assets:
79
+ # - classified_intent: is_displayable=False, is_used_by_planner=True
80
+ # - confidence_score: is_displayable=False, is_used_by_planner=True
81
+ #
82
+ # This ensures LLM cannot hallucinate based on classification data
83
+ classify_intent: @actions.Classify_User_Intent
84
+ description: "Determine what the user needs help with"
85
+ with user_message = ... # LLM extracts from conversation
86
+ set @variables.classified_intent = @outputs.intent
87
+ set @variables.confidence_score = @outputs.confidence
88
+ set @variables.needs_classification = False
89
+
90
+ # Manual routing for low-confidence cases
91
+ go_billing: @utils.transition to @topic.billing
92
+ description: "Yes, I need billing help"
93
+ available when @variables.low_confidence_warning == True and @variables.classified_intent == "billing"
94
+
95
+ go_support: @utils.transition to @topic.technical_support
96
+ description: "Yes, I need technical support"
97
+ available when @variables.low_confidence_warning == True and @variables.classified_intent == "technical_support"
98
+
99
+ go_sales: @utils.transition to @topic.sales
100
+ description: "Yes, I need sales help"
101
+ available when @variables.low_confidence_warning == True and @variables.classified_intent == "sales"
102
+
103
+ go_returns: @utils.transition to @topic.returns
104
+ description: "Yes, I need returns help"
105
+ available when @variables.low_confidence_warning == True and @variables.classified_intent == "returns"
106
+
107
+ # Reclassify if user said "no"
108
+ reclassify: @utils.setVariables
109
+ description: "That's not what I need - let me clarify"
110
+ available when @variables.low_confidence_warning == True
111
+ with needs_classification = True
112
+ with classified_intent = ""
113
+ with confidence_score = 0
114
+ with low_confidence_warning = False
115
+
116
+ # ============================================================
117
+ # ROUTED TOPICS
118
+ # ============================================================
119
+
120
+ topic billing:
121
+ description: "Handle billing inquiries"
122
+ reasoning:
123
+ instructions: |
124
+ Help the customer with their billing question.
125
+ You can view invoices, explain charges, or process payments.
126
+ actions:
127
+ back: @utils.transition to @topic.topic_selector
128
+ description: "Return to main menu"
129
+ escalate_now: @utils.escalate
130
+ description: "Transfer to billing specialist"
131
+
132
+ topic technical_support:
133
+ description: "Handle technical support issues"
134
+ reasoning:
135
+ instructions: |
136
+ Help the customer with their technical issue.
137
+ Troubleshoot problems and provide solutions.
138
+ actions:
139
+ back: @utils.transition to @topic.topic_selector
140
+ description: "Return to main menu"
141
+ escalate_now: @utils.escalate
142
+ description: "Transfer to technical specialist"
143
+
144
+ topic sales:
145
+ description: "Handle sales inquiries"
146
+ reasoning:
147
+ instructions: |
148
+ Help the customer with sales questions.
149
+ Provide product information and pricing.
150
+ actions:
151
+ back: @utils.transition to @topic.topic_selector
152
+ description: "Return to main menu"
153
+ escalate_now: @utils.escalate
154
+ description: "Transfer to sales representative"
155
+
156
+ topic returns:
157
+ description: "Handle return requests"
158
+ reasoning:
159
+ instructions: |
160
+ Help the customer with their return request.
161
+ Check eligibility and process returns.
162
+ actions:
163
+ back: @utils.transition to @topic.topic_selector
164
+ description: "Return to main menu"
165
+ escalate_now: @utils.escalate
166
+ description: "Transfer to returns specialist"