@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,160 @@
1
+ # Multi-Topic Agent Template
2
+ # Copy this file to your AiAuthoringBundle directory and rename it to match
3
+ # your agent's developer_name. Replace all placeholder values with real ones.
4
+ # Add, remove, or rename topics as needed.
5
+
6
+ system:
7
+ instructions: "You are a helpful assistant. Describe the agent's persona and purpose here."
8
+ messages:
9
+ welcome: "Hello! How can I help you today?"
10
+ error: "Sorry, it looks like something has gone wrong."
11
+
12
+ config:
13
+ developer_name: "Agent_API_Name"
14
+ agent_label: "Agent Display Name"
15
+ description: "Description of the agent's purpose"
16
+ # agent_type: "AgentforceServiceAgent" for customer-facing (requires default_agent_user)
17
+ # "AgentforceEmployeeAgent" for internal (remove default_agent_user line)
18
+ agent_type: "AgentforceServiceAgent"
19
+ default_agent_user: "username@identifier.org"
20
+
21
+ variables:
22
+ collected_input: mutable string = ""
23
+ description: "Replace with a description of what this variable tracks"
24
+
25
+ language:
26
+ default_locale: "en_US"
27
+ additional_locales: ""
28
+ all_additional_locales: False
29
+
30
+ start_agent topic_selector:
31
+ description: "Welcome the user and determine the appropriate topic based on user input"
32
+ reasoning:
33
+ actions:
34
+ go_to_topic_a: @utils.transition to @topic.topic_a
35
+ go_to_topic_b: @utils.transition to @topic.topic_b
36
+ go_to_topic_c: @utils.transition to @topic.topic_c
37
+ go_to_escalation: @utils.transition to @topic.escalation
38
+ go_to_off_topic: @utils.transition to @topic.off_topic
39
+
40
+ topic topic_a:
41
+ label: "Topic A"
42
+ description: "Describe what this topic handles"
43
+
44
+ reasoning:
45
+ instructions: ->
46
+ | Replace this with instructions for topic A.
47
+
48
+ actions:
49
+ action_a: @actions.action_a
50
+ with input_param = ...
51
+
52
+ actions:
53
+ action_a:
54
+ description: "Describe what this action does"
55
+ label: "Action A"
56
+ target: "apex://ClassName"
57
+ inputs:
58
+ input_param: string
59
+ description: "Describe this parameter"
60
+ label: "Parameter Name"
61
+ is_required: True
62
+ outputs:
63
+ output_field: string
64
+ label: "Output Name"
65
+ description: "Describe this output"
66
+ is_displayable: True
67
+ filter_from_agent: False
68
+
69
+ topic topic_b:
70
+ label: "Topic B"
71
+ description: "Describe what this topic handles"
72
+
73
+ reasoning:
74
+ instructions: ->
75
+ | Replace this with instructions for topic B. This topic demonstrates the gating pattern.
76
+
77
+ actions:
78
+ # Collect data into a variable first
79
+ collect_data: @utils.setVariables
80
+ description: "Collect user input into a variable"
81
+ with collected_input = ...
82
+
83
+ # Gate the main action behind the variable
84
+ main_action: @actions.action_b
85
+ description: "Describe what this gated action does"
86
+ available when @variables.collected_input != ""
87
+ with query_param = @variables.collected_input
88
+
89
+ actions:
90
+ action_b:
91
+ description: "Describe what this action does"
92
+ label: "Action B"
93
+ target: "prompt://PromptTemplateName"
94
+ inputs:
95
+ query_param: string
96
+ description: "Describe this parameter"
97
+ label: "Parameter Name"
98
+ is_required: True
99
+ outputs:
100
+ result_text: string
101
+ description: "Describe this output"
102
+ label: "Result"
103
+ is_displayable: False
104
+
105
+ topic topic_c:
106
+ label: "Topic C"
107
+ description: "Describe what this topic handles"
108
+
109
+ reasoning:
110
+ instructions: ->
111
+ | Replace this with base instructions for topic C.
112
+
113
+ # Conditional instructions based on variable state
114
+ if @variables.collected_input != "":
115
+ | Additional instructions when the variable has been set.
116
+ else:
117
+ | Instructions when the variable has not been set yet.
118
+
119
+ actions:
120
+ action_c: @actions.action_c
121
+ with input_param = ...
122
+ # Bind an action output to an agent variable
123
+ set @variables.collected_input = @outputs.result_value
124
+
125
+ actions:
126
+ action_c:
127
+ description: "Describe what this action does"
128
+ label: "Action C"
129
+ target: "flow://FlowName"
130
+ inputs:
131
+ input_param: string
132
+ description: "Describe this parameter"
133
+ label: "Parameter Name"
134
+ is_required: True
135
+ outputs:
136
+ result_value: string
137
+ label: "Result Value"
138
+ description: "Describe this output"
139
+ is_displayable: True
140
+ filter_from_agent: False
141
+
142
+ topic escalation:
143
+ label: "Escalation"
144
+ description: "Handles requests from users who want to transfer or escalate their conversation to a live human agent."
145
+
146
+ reasoning:
147
+ instructions: ->
148
+ | If a user explicitly asks to transfer to a live agent, escalate the conversation.
149
+ actions:
150
+ escalate_to_human: @utils.escalate
151
+ description: "Escalate to a human agent."
152
+
153
+ topic off_topic:
154
+ label: "Off Topic"
155
+ description: "Redirect conversation to relevant topics when user request goes off-topic"
156
+
157
+ reasoning:
158
+ instructions: ->
159
+ | The user request is off-topic. Do not answer general knowledge questions.
160
+ Redirect the conversation by asking how you can help with topics this agent supports.
@@ -0,0 +1,81 @@
1
+ # Single-Topic Agent Template
2
+ # Copy this file to your AiAuthoringBundle directory and rename it to match
3
+ # your agent's developer_name. Replace all placeholder values with real ones.
4
+
5
+ system:
6
+ instructions: "You are a helpful assistant. Describe the agent's persona and purpose here."
7
+ messages:
8
+ welcome: "Hello! How can I help you today?"
9
+ error: "Sorry, it looks like something has gone wrong."
10
+
11
+ config:
12
+ developer_name: "Agent_API_Name"
13
+ agent_label: "Agent Display Name"
14
+ description: "Description of the agent's purpose"
15
+ # agent_type: "AgentforceServiceAgent" for customer-facing (requires default_agent_user)
16
+ # "AgentforceEmployeeAgent" for internal (remove default_agent_user line)
17
+ agent_type: "AgentforceServiceAgent"
18
+ default_agent_user: "username@identifier.org"
19
+
20
+ language:
21
+ default_locale: "en_US"
22
+ additional_locales: ""
23
+ all_additional_locales: False
24
+
25
+ start_agent topic_selector:
26
+ description: "Welcome the user and determine the appropriate topic based on user input"
27
+ reasoning:
28
+ actions:
29
+ go_to_main: @utils.transition to @topic.main
30
+ go_to_escalation: @utils.transition to @topic.escalation
31
+ go_to_off_topic: @utils.transition to @topic.off_topic
32
+
33
+ topic main:
34
+ label: "Main Topic"
35
+ description: "Describe what this topic handles. The Atlas Reasoning Engine matches user utterances against this description."
36
+
37
+ reasoning:
38
+ instructions: ->
39
+ | Replace this with instructions for how the agent should handle requests in this topic.
40
+ Reference actions with the syntax shown below.
41
+
42
+ actions:
43
+ do_action: @actions.do_action
44
+ with input_param = ...
45
+
46
+ actions:
47
+ do_action:
48
+ description: "Describe what this action does"
49
+ label: "Action Display Name"
50
+ target: "apex://ClassName"
51
+ inputs:
52
+ input_param: string
53
+ description: "Describe this parameter"
54
+ label: "Parameter Display Name"
55
+ is_required: True
56
+ outputs:
57
+ output_field: string
58
+ label: "Output Display Name"
59
+ description: "Describe this output"
60
+ is_displayable: True
61
+ filter_from_agent: False
62
+
63
+ topic escalation:
64
+ label: "Escalation"
65
+ description: "Handles requests from users who want to transfer or escalate their conversation to a live human agent."
66
+
67
+ reasoning:
68
+ instructions: ->
69
+ | If a user explicitly asks to transfer to a live agent, escalate the conversation.
70
+ actions:
71
+ escalate_to_human: @utils.escalate
72
+ description: "Escalate to a human agent."
73
+
74
+ topic off_topic:
75
+ label: "Off Topic"
76
+ description: "Redirect conversation to relevant topics when user request goes off-topic"
77
+
78
+ reasoning:
79
+ instructions: ->
80
+ | The user request is off-topic. Do not answer general knowledge questions.
81
+ Redirect the conversation by asking how you can help with topics this agent supports.
@@ -0,0 +1,208 @@
1
+ # Verification Gate Architecture Template
2
+ # ========================================
3
+ #
4
+ # This template demonstrates the Verification Gate pattern where users
5
+ # must pass through identity verification before accessing sensitive topics.
6
+ #
7
+ # Pattern: Security gate before protected functionality
8
+ # Use when: Handling sensitive data, payments, PII access
9
+ #
10
+ # Key Features:
11
+ # - Deterministic verification (code-enforced, not LLM suggestions)
12
+ # - available when guards make actions invisible until verified
13
+ # - Post-action checks at TOP of instructions
14
+ # - Automatic escalation after 3 failed attempts
15
+
16
+ system:
17
+ messages:
18
+ welcome: "Welcome! I'll need to verify your identity before we proceed."
19
+ error: "I apologize, something went wrong. Let me try again."
20
+ instructions: "You are a secure customer service agent. Always verify identity before sensitive operations."
21
+
22
+ config:
23
+ agent_name: "SecureAgent"
24
+ agent_label: "Secure Customer Agent"
25
+ description: "Agent with verification gate for sensitive operations"
26
+ default_agent_user: "agent@yourorg.com" # REQUIRED: Change to valid Einstein Agent User
27
+
28
+ variables:
29
+ # Identity verification state
30
+ customer_verified: mutable boolean = False
31
+ description: "Has customer passed identity verification"
32
+ failed_attempts: mutable number = 0
33
+ description: "Number of failed verification attempts"
34
+
35
+ # Session context (read-only from external source)
36
+ customer_id: linked string
37
+ source: @session.customerId
38
+ description: "Customer ID from session"
39
+ customer_email: linked string
40
+ source: @session.customerEmail
41
+ description: "Customer email from session"
42
+
43
+ # Operation state
44
+ refund_status: mutable string = ""
45
+ description: "Status of refund operation"
46
+ churn_risk_score: mutable number = 0
47
+ description: "Customer churn risk from Data Cloud"
48
+
49
+ # ============================================================
50
+ # ENTRY POINT
51
+ # ============================================================
52
+
53
+ start_agent entry:
54
+ description: "Entry point - routes through verification"
55
+ reasoning:
56
+ instructions: |
57
+ Welcome the customer and route to identity verification.
58
+ actions:
59
+ start_verification: @utils.transition to @topic.identity_verification
60
+ description: "Begin identity verification process"
61
+
62
+ # ============================================================
63
+ # VERIFICATION GATE (Security Check)
64
+ # ============================================================
65
+
66
+ topic identity_verification:
67
+ description: "Verify customer identity before proceeding"
68
+ reasoning:
69
+ instructions: ->
70
+ # SECURITY: Check for lockout FIRST (deterministic)
71
+ if @variables.failed_attempts >= 3:
72
+ | Too many failed attempts. Transferring to a human agent.
73
+ transition to @topic.escalation
74
+
75
+ # Already verified? Proceed to protected topics
76
+ if @variables.customer_verified == True:
77
+ | Identity verified! How can I help you today?
78
+
79
+ # Not yet verified
80
+ if @variables.customer_verified == False:
81
+ | Please verify your identity by confirming your email address.
82
+ | I have your email on file - please confirm it matches.
83
+
84
+ actions:
85
+ verify_email: @actions.verify_email
86
+ description: "Verify customer email"
87
+ with email = @variables.customer_email
88
+ set @variables.customer_verified = @outputs.verified
89
+
90
+ # GUARDED: Only visible when verified
91
+ go_to_account: @utils.transition to @topic.account_management
92
+ description: "Access account settings"
93
+ available when @variables.customer_verified == True
94
+
95
+ go_to_refund: @utils.transition to @topic.refund_processor
96
+ description: "Process a refund request"
97
+ available when @variables.customer_verified == True
98
+
99
+ # Always available
100
+ escalate_now: @utils.escalate
101
+ description: "Transfer to human agent"
102
+
103
+ # ============================================================
104
+ # PROTECTED: Account Management
105
+ # ============================================================
106
+
107
+ topic account_management:
108
+ description: "Manage customer account (requires verification)"
109
+ reasoning:
110
+ instructions: ->
111
+ # SECURITY GATE: Re-check verification
112
+ if @variables.customer_verified == False:
113
+ transition to @topic.identity_verification
114
+
115
+ | Welcome to account management.
116
+ | What would you like to do with your account?
117
+
118
+ actions:
119
+ update_email: @actions.update_email
120
+ description: "Update email address"
121
+ available when @variables.customer_verified == True
122
+ update_preferences: @actions.update_preferences
123
+ description: "Update communication preferences"
124
+ available when @variables.customer_verified == True
125
+ back: @utils.transition to @topic.identity_verification
126
+ description: "Return to main menu"
127
+
128
+ # ============================================================
129
+ # PROTECTED: Refund Processor (with Post-Action Pattern)
130
+ # ============================================================
131
+
132
+ topic refund_processor:
133
+ description: "Process refund requests (requires verification)"
134
+ reasoning:
135
+ instructions: ->
136
+ # SECURITY GATE: Re-check verification
137
+ if @variables.customer_verified == False:
138
+ transition to @topic.identity_verification
139
+
140
+ # ====================================================
141
+ # POST-ACTION CHECK (at TOP - triggers on loop)
142
+ # ====================================================
143
+ if @variables.refund_status == "Approved":
144
+ # Deterministic follow-up - LLM cannot skip!
145
+ run @actions.create_crm_case
146
+ with customer_id = @variables.customer_id
147
+ with refund_amount = @variables.refund_amount
148
+ transition to @topic.success_confirmation
149
+
150
+ # ====================================================
151
+ # PRE-LLM: Load churn risk data
152
+ # ====================================================
153
+ run @actions.check_churn_risk
154
+ with customer_id = @variables.customer_id
155
+ set @variables.churn_risk_score = @outputs.score
156
+
157
+ # ====================================================
158
+ # DYNAMIC INSTRUCTIONS (based on churn risk)
159
+ # ====================================================
160
+ | Customer risk score: {!@variables.churn_risk_score}
161
+
162
+ if @variables.churn_risk_score >= 80:
163
+ | HIGH RISK - Offer a full cash refund to retain this customer.
164
+ else:
165
+ | STANDARD - Offer a $10 store credit as goodwill.
166
+
167
+ actions:
168
+ approve_full_refund: @actions.process_refund
169
+ description: "Approve full cash refund"
170
+ available when @variables.churn_risk_score >= 80
171
+ with type = "full"
172
+ set @variables.refund_status = @outputs.status
173
+
174
+ offer_credit: @actions.issue_credit
175
+ description: "Offer store credit"
176
+ available when @variables.churn_risk_score < 80
177
+ with amount = 10
178
+ set @variables.refund_status = @outputs.status
179
+
180
+ # ============================================================
181
+ # SUCCESS CONFIRMATION
182
+ # ============================================================
183
+
184
+ topic success_confirmation:
185
+ description: "Confirm successful operation"
186
+ reasoning:
187
+ instructions: |
188
+ Great news! Your request has been processed successfully.
189
+ Is there anything else I can help you with?
190
+ actions:
191
+ new_request: @utils.transition to @topic.identity_verification
192
+ description: "Start a new request"
193
+ end_conversation: @actions.end_session
194
+ description: "End the conversation"
195
+
196
+ # ============================================================
197
+ # ESCALATION (Handoff to Human)
198
+ # ============================================================
199
+
200
+ topic escalation:
201
+ description: "Escalate to human agent"
202
+ reasoning:
203
+ instructions: |
204
+ I'm transferring you to a human agent who can better assist you.
205
+ Please hold while I connect you.
206
+ actions:
207
+ handoff: @utils.escalate
208
+ description: "Transfer to human agent"
@@ -0,0 +1,164 @@
1
+ # Prompt Template Actions
2
+
3
+ Invoking Salesforce Prompt Templates as actions within Agent Script.
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ Prompt Template Actions let agents invoke Salesforce Prompt Templates via the `generatePromptResponse://` protocol. The agent passes structured inputs to the template and receives a generated `promptResponse` output — keeping content generation in the template while the agent manages conversation flow.
10
+
11
+ **When to use**: Personalized responses, summarization, content generation, recommendations — anything where an LLM prompt template produces better output than static Flow logic.
12
+
13
+ ---
14
+
15
+ ## Action Definition (Agentforce Assets)
16
+
17
+ Define the action in **Setup > Agentforce > Action Definitions** (or via metadata API):
18
+
19
+ ```agentscript
20
+ actions:
21
+ Generate_Personalized_Schedule:
22
+ description: "Generate a personalized schedule using a prompt template"
23
+ inputs:
24
+ "Input:email": string
25
+ description: "User's email address"
26
+ is_required: True
27
+ "Input:preferences": string
28
+ description: "User's scheduling preferences"
29
+ is_required: False
30
+ outputs:
31
+ promptResponse: string
32
+ description: "The personalized schedule generated by the template"
33
+ is_used_by_planner: True
34
+ target: "generatePromptResponse://Generate_Personalized_Schedule"
35
+ ```
36
+
37
+ ### Critical syntax rules
38
+
39
+ | Rule | Example |
40
+ |------|---------|
41
+ | Target protocol | `"generatePromptResponse://TemplateName"` |
42
+ | Input names **must be quoted** | `"Input:email"` not `Input:email` |
43
+ | Input prefix is `Input:` | Matches the template's input field API name |
44
+ | Output field is always `promptResponse` | Single string output from the template |
45
+
46
+ ---
47
+
48
+ ## Agent Script Invocation
49
+
50
+ Reference the action definition in your `.agent` file:
51
+
52
+ ```agentscript
53
+ topic schedule_generation:
54
+ reasoning:
55
+ actions:
56
+ generate_schedule: @actions.Generate_Personalized_Schedule
57
+ with "Input:email"=@variables.user_email
58
+ "Input:preferences"=...
59
+ set @variables.schedule = @outputs.promptResponse
60
+ ```
61
+
62
+ **Input binding patterns** (same as regular actions):
63
+ - `@variables.user_email` — variable binding (data from prior turns)
64
+ - `...` — LLM slot-filling (extract from conversation)
65
+ - `"professional"` — fixed value (business rule constant)
66
+
67
+ ---
68
+
69
+ ## Grounded Data Integration
70
+
71
+ Templates can include **data providers** (Apex classes, Flows) that supply contextual data for personalized responses. The grounding happens inside the template — Agent Script only needs to pass the lookup key:
72
+
73
+ ```agentscript
74
+ actions:
75
+ Get_Product_Recommendations:
76
+ description: "Generate personalized product recommendations based on purchase history"
77
+ inputs:
78
+ "Input:customerId": string
79
+ description: "Customer ID for personalization"
80
+ is_required: True
81
+ outputs:
82
+ promptResponse: string
83
+ description: "Personalized recommendations grounded in customer data"
84
+ target: "generatePromptResponse://Product_Recommender"
85
+ ```
86
+
87
+ The template itself (configured in Prompt Builder) includes:
88
+ - **Data Provider**: Apex class fetching customer purchase history
89
+ - **Grounding**: Recent orders, preferences, browsing history
90
+ - **Template instructions**: How to format recommendations using the grounded data
91
+
92
+ ---
93
+
94
+ ## Common Patterns
95
+
96
+ ### Pattern 1: Content Generation
97
+
98
+ ```agentscript
99
+ generate_email: @actions.Generate_Email_Response
100
+ with "Input:customerMessage"=@variables.user_message
101
+ "Input:tone"="professional"
102
+ "Input:context"=@variables.case_context
103
+ set @variables.email_draft = @outputs.promptResponse
104
+ ```
105
+
106
+ ### Pattern 2: Summarization
107
+
108
+ ```agentscript
109
+ summarize: @actions.Summarize_Conversation
110
+ with "Input:conversationHistory"=@variables.chat_history
111
+ "Input:maxLength"="500"
112
+ set @variables.summary = @outputs.promptResponse
113
+ ```
114
+
115
+ ### Pattern 3: Personalized Recommendations
116
+
117
+ ```agentscript
118
+ recommend: @actions.Get_Product_Recommendations
119
+ with "Input:customerId"=@variables.customer_id
120
+ "Input:category"=...
121
+ set @variables.recommendations = @outputs.promptResponse
122
+ ```
123
+
124
+ ---
125
+
126
+ ## Known Limitation: `run` Keyword with Prompt Templates
127
+
128
+ Chained actions using `run` may not properly map `"Input:X"` parameters:
129
+
130
+ ```agentscript
131
+ # ❌ MAY NOT WORK — run + prompt template input binding:
132
+ process: @actions.create_order
133
+ with customer_id=@variables.customer_id
134
+ run @actions.Generate_Order_Summary
135
+ with "Input:orderId"=@variables.order_id # Input binding may fail
136
+
137
+ # ✅ WORKAROUND — call as primary action instead:
138
+ generate_summary: @actions.Generate_Order_Summary
139
+ with "Input:orderId"=@variables.order_id # Works as primary action
140
+ set @variables.summary = @outputs.promptResponse
141
+ ```
142
+
143
+ ---
144
+
145
+ ## Common Errors
146
+
147
+ | Error | Cause | Fix |
148
+ |-------|-------|-----|
149
+ | `SyntaxError` on input binding | Missing quotes on parameter name | Use `"Input:email"` not `Input:email` |
150
+ | Template not found | Wrong protocol or template name | Verify `generatePromptResponse://ExactTemplateName` |
151
+ | Empty `promptResponse` | Template inactive or missing required inputs | Activate template in Setup, check all `is_required: True` inputs are bound |
152
+ | Input not mapped | API name mismatch | Input field name after `Input:` must exactly match template's input API name |
153
+
154
+ ---
155
+
156
+ ## Checklist
157
+
158
+ - [ ] Template exists in org and is **active**
159
+ - [ ] Input field API names match template configuration exactly
160
+ - [ ] All `is_required: True` inputs are bound (via `...`, `@variables`, or fixed)
161
+ - [ ] `promptResponse` output is captured with `set`
162
+ - [ ] Template response quality tested with representative inputs
163
+ - [ ] If using grounded data: data provider returns expected records
164
+