@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,188 @@
1
+ # Prompt Template Action Pattern
2
+ # Invoke Salesforce PromptTemplates directly from Agent Script
3
+ #
4
+ # ★ When To Use This Pattern:
5
+ # - Generate dynamic AI content (summaries, emails, recommendations)
6
+ # - Use Einstein Prompt Builder templates from agents
7
+ # - Combine structured data with LLM generation
8
+ # - Leverage existing PromptTemplate investments
9
+ #
10
+ # ★ Key Insights:
11
+ # - Target uses generatePromptResponse:// protocol (not flow://)
12
+ # - Input names MUST have "Input:" prefix (critical!)
13
+ # - Output field is always named "promptResponse"
14
+ # - PromptTemplate must be deployed BEFORE the agent
15
+ #
16
+ # ★ Important Limitation:
17
+ # - Template API name must exactly match target
18
+ # - Record-bound templates require recordId input
19
+ #
20
+ # This is a COMPLETE template - customize for your use case
21
+
22
+ system:
23
+ instructions: "You are a content generation assistant. Help users create personalized content using AI templates. Always verify the generated content meets quality standards."
24
+ messages:
25
+ welcome: "Hello! I can help generate personalized content for you."
26
+ error: "I encountered an issue generating content. Let me try again."
27
+
28
+ config:
29
+ agent_name: "Content_Generator_Agent"
30
+ default_agent_user: "agent@company.salesforce.com"
31
+ agent_label: "Content Generator"
32
+ description: "Agent that generates AI content using Prompt Templates"
33
+
34
+ variables:
35
+ # Standard linked variables
36
+ EndUserId: linked string
37
+ source: @MessagingSession.MessagingEndUserId
38
+ description: "Messaging End User ID"
39
+ RoutableId: linked string
40
+ source: @MessagingSession.Id
41
+ description: "Messaging Session ID"
42
+ ContactId: linked string
43
+ source: @MessagingEndUser.ContactId
44
+ description: "Contact ID"
45
+
46
+ # Content generation variables
47
+ generated_schedule: mutable string = ""
48
+ description: "AI-generated schedule content"
49
+ generated_email: mutable string = ""
50
+ description: "AI-generated email content"
51
+ user_email: mutable string = ""
52
+ description: "User's email address"
53
+ user_timezone: mutable string = "America/Los_Angeles"
54
+ description: "User's timezone"
55
+ recipient_name: mutable string = ""
56
+ description: "Email recipient name"
57
+ email_topic: mutable string = ""
58
+ description: "Topic for email generation"
59
+
60
+ language:
61
+ default_locale: "en_US"
62
+
63
+ start_agent topic_selector:
64
+ label: "Content Generator"
65
+ description: "Routes to content generation options"
66
+
67
+ reasoning:
68
+ instructions: ->
69
+ | Ask the user what type of content they'd like to generate:
70
+ | 1. Personalized daily schedule
71
+ | 2. Professional email
72
+ |
73
+ | Route to the appropriate topic.
74
+ actions:
75
+ go_schedule: @utils.transition to @topic.schedule_generation
76
+ go_email: @utils.transition to @topic.email_generation
77
+
78
+ topic schedule_generation:
79
+ label: "Schedule Generation"
80
+ description: "Generate personalized daily schedules"
81
+
82
+ actions:
83
+ # ★ PROMPT TEMPLATE ACTION - Key syntax elements:
84
+ # 1. target: uses generatePromptResponse:// protocol
85
+ # 2. inputs: MUST use "Input:" prefix
86
+ # 3. outputs: field name is always "promptResponse"
87
+ Generate_Personalized_Schedule:
88
+ description: "Generate a personalized daily schedule using AI."
89
+ inputs:
90
+ # ★ CRITICAL: Input names must have "Input:" prefix
91
+ # These map to {!email} and {!timezone} in the PromptTemplate
92
+ "Input:email": string
93
+ description: "User's email address for preference lookup"
94
+ is_required: True
95
+ "Input:timezone": string
96
+ description: "User's timezone for schedule formatting"
97
+ is_required: False
98
+ outputs:
99
+ # ★ Standard output field name for prompt responses
100
+ promptResponse: string
101
+ description: "The AI-generated schedule content"
102
+ is_used_by_planner: True
103
+ is_displayable: True
104
+ # ★ Target protocol: generatePromptResponse://TemplateApiName
105
+ target: "generatePromptResponse://Generate_Personalized_Schedule"
106
+
107
+ reasoning:
108
+ instructions: ->
109
+ | Help the user create a personalized daily schedule.
110
+ |
111
+ | 1. Ask for their email (required)
112
+ | 2. Ask for their timezone (optional, defaults to Pacific)
113
+ | 3. Generate the schedule using the AI template
114
+ | 4. Present the generated schedule
115
+ |
116
+ | The schedule will include morning routine, work blocks,
117
+ | breaks, and evening wind-down based on preferences.
118
+
119
+ actions:
120
+ create_schedule: @actions.Generate_Personalized_Schedule
121
+ # ★ Input binding with quoted field names
122
+ with "Input:email"=@variables.user_email
123
+ with "Input:timezone"=@variables.user_timezone
124
+ set @variables.generated_schedule = @outputs.promptResponse
125
+
126
+ back: @utils.transition to @topic.topic_selector
127
+
128
+ topic email_generation:
129
+ label: "Email Generation"
130
+ description: "Generate professional emails"
131
+
132
+ actions:
133
+ # Another Prompt Template action example
134
+ Generate_Professional_Email:
135
+ description: "Generate a professional email draft."
136
+ inputs:
137
+ "Input:recipientName": string
138
+ description: "Name of the email recipient"
139
+ is_required: True
140
+ "Input:topic": string
141
+ description: "Topic or purpose of the email"
142
+ is_required: True
143
+ "Input:tone": string
144
+ description: "Desired tone: formal, friendly, urgent"
145
+ is_required: False
146
+ outputs:
147
+ promptResponse: string
148
+ description: "The generated email content"
149
+ is_used_by_planner: True
150
+ is_displayable: True
151
+ target: "generatePromptResponse://Generate_Professional_Email"
152
+
153
+ reasoning:
154
+ instructions: ->
155
+ | Help the user draft a professional email.
156
+ |
157
+ | Collect:
158
+ | 1. Recipient's name (required)
159
+ | 2. Email topic/purpose (required)
160
+ | 3. Desired tone: formal, friendly, or urgent (optional)
161
+ |
162
+ | Generate the email and present it for review.
163
+
164
+ actions:
165
+ create_email: @actions.Generate_Professional_Email
166
+ with "Input:recipientName"=...
167
+ with "Input:topic"=...
168
+ with "Input:tone"=...
169
+ set @variables.generated_email = @outputs.promptResponse
170
+
171
+ back: @utils.transition to @topic.topic_selector
172
+
173
+ # ★ Insight: Prompt Template Integration Checklist
174
+ #
175
+ # BEFORE PUBLISHING AGENT:
176
+ # 1. Create PromptTemplate metadata file
177
+ # 2. Deploy PromptTemplate: sf project deploy start -m "PromptTemplate:Template_Name"
178
+ # 3. Verify template exists: sf org list metadata -m PromptTemplate
179
+ #
180
+ # INPUT MAPPING:
181
+ # Agent Script "Input:fieldName" → PromptTemplate {!fieldName}
182
+ # "Input:email" → {!email}
183
+ # "Input:customerName" → {!customerName}
184
+ #
185
+ # COMMON ERRORS:
186
+ # - HTTP 404: PromptTemplate not deployed yet
187
+ # - "property X not found": Input name doesn't match template variable
188
+ # - Missing "Input:" prefix: Inputs won't map correctly
@@ -0,0 +1,293 @@
1
+ # System Instruction Overrides Pattern
2
+ # Customize agent behavior with dynamic system-level instructions
3
+ #
4
+ # ★ When To Use This Pattern:
5
+ # - Different behavior for different user segments (VIP, standard, etc.)
6
+ # - Time-based instruction changes (business hours vs after hours)
7
+ # - Feature flags that change agent personality
8
+ # - A/B testing different conversation styles
9
+ #
10
+ # ★ Key Insight:
11
+ # - System block defines BASE behavior (always applies)
12
+ # - Topic instructions can OVERRIDE or EXTEND system behavior
13
+ # - Use conditionals in reasoning to dynamically adjust tone
14
+ # - Variables can control instruction branches
15
+ #
16
+ # ★ Important Limitation:
17
+ # - The system: block itself cannot use conditionals or variables
18
+ # - Dynamic behavior must be implemented in topic reasoning
19
+ #
20
+ # This is a COMPLETE template - customize for your use case
21
+
22
+ system:
23
+ # Base instructions - always apply these guardrails
24
+ instructions: "You are a professional customer service agent. Always be helpful, courteous, and accurate. Never share confidential information. Escalate complex issues to human agents."
25
+ messages:
26
+ welcome: "Hello! How can I assist you today?"
27
+ error: "I apologize, but I encountered an issue. Let me try that again."
28
+
29
+ config:
30
+ agent_name: "Dynamic_Service_Agent"
31
+ default_agent_user: "agent@company.salesforce.com"
32
+ agent_label: "Dynamic Service Agent"
33
+ description: "Agent with dynamic instruction overrides based on context"
34
+
35
+ variables:
36
+ # Standard linked variables
37
+ EndUserId: linked string
38
+ source: @MessagingSession.MessagingEndUserId
39
+ description: "Messaging End User ID"
40
+ RoutableId: linked string
41
+ source: @MessagingSession.Id
42
+ description: "Messaging Session ID"
43
+ ContactId: linked string
44
+ source: @MessagingEndUser.ContactId
45
+ description: "Contact ID"
46
+
47
+ # Variables for dynamic instruction control
48
+ customer_tier: mutable string = "standard"
49
+ description: "Customer tier: standard, premium, or vip"
50
+ business_hours: mutable boolean = True
51
+ description: "Whether we're in business hours"
52
+ agent_mode: mutable string = "helpful"
53
+ description: "Agent personality mode: helpful, concise, formal"
54
+ feature_flags: mutable string = ""
55
+ description: "Comma-separated feature flags"
56
+
57
+ language:
58
+ default_locale: "en_US"
59
+ additional_locales: ""
60
+ all_additional_locales: False
61
+
62
+ start_agent topic_selector:
63
+ label: "Topic Selector"
64
+ description: "Routes to appropriate topic based on user tier"
65
+
66
+ # ★ Use before_reasoning to set up context-based variables
67
+ before_reasoning:
68
+ # In a real implementation, these would come from a Flow/Apex lookup
69
+ # Here we show the pattern
70
+ run @actions.get_customer_tier
71
+ with contact_id=@variables.ContactId
72
+ set @variables.customer_tier = @outputs.tier
73
+ run @actions.check_business_hours
74
+ set @variables.business_hours = @outputs.is_business_hours
75
+
76
+ reasoning:
77
+ # ★ OVERRIDE PATTERN: Conditional instructions based on variables
78
+ instructions: ->
79
+ # VIP customers get personalized treatment
80
+ if @variables.customer_tier == "vip":
81
+ | PRIORITY CUSTOMER DETECTED
82
+ | Provide white-glove service. Use their name when possible.
83
+ | Offer proactive solutions. Never say "I can't" without an alternative.
84
+ | You have authority to offer 20% discounts.
85
+
86
+ # Premium gets enhanced support
87
+ if @variables.customer_tier == "premium":
88
+ | PREMIUM CUSTOMER
89
+ | Provide thorough, detailed responses.
90
+ | Offer to connect with a specialist if needed.
91
+ | You can offer 10% discounts.
92
+
93
+ # Standard tier
94
+ if @variables.customer_tier == "standard":
95
+ | Provide helpful, efficient service.
96
+ | Focus on resolving the issue quickly.
97
+
98
+ # After-hours override
99
+ if @variables.business_hours == False:
100
+ | NOTE: We are currently outside business hours.
101
+ | Complex issues should be logged for follow-up tomorrow.
102
+ | You cannot transfer to live agents right now.
103
+
104
+ # Mode-based personality adjustments
105
+ if @variables.agent_mode == "concise":
106
+ | Keep responses brief and to the point. Use bullet points.
107
+
108
+ if @variables.agent_mode == "formal":
109
+ | Use formal language. Address customer as Sir/Madam.
110
+
111
+ | Route the customer to the appropriate topic.
112
+
113
+ actions:
114
+ go_orders: @utils.transition to @topic.orders
115
+ go_billing: @utils.transition to @topic.billing
116
+ go_support: @utils.transition to @topic.support
117
+ available when @variables.business_hours == True
118
+
119
+ actions:
120
+ get_customer_tier:
121
+ description: "Get customer tier from Salesforce"
122
+ inputs:
123
+ contact_id: string
124
+ description: "Contact ID to look up"
125
+ outputs:
126
+ tier: string
127
+ description: "Customer tier: standard, premium, vip"
128
+ target: "flow://Get_Customer_Tier"
129
+
130
+ check_business_hours:
131
+ description: "Check if currently in business hours"
132
+ outputs:
133
+ is_business_hours: boolean
134
+ description: "True if in business hours"
135
+ target: "flow://Check_Business_Hours"
136
+
137
+ topic orders:
138
+ label: "Order Management"
139
+ description: "Handle order inquiries with tier-appropriate service"
140
+
141
+ reasoning:
142
+ instructions: ->
143
+ # ★ Tier-specific instructions carry through to subtopics
144
+ if @variables.customer_tier == "vip":
145
+ | This is a VIP customer. Expedite all order requests.
146
+ | Offer free shipping upgrades proactively.
147
+
148
+ | Help the customer with their order inquiry.
149
+ | Look up order status, process changes, or handle returns.
150
+
151
+ actions:
152
+ back: @utils.transition to @topic.topic_selector
153
+
154
+ topic billing:
155
+ label: "Billing Support"
156
+ description: "Handle billing with appropriate authority levels"
157
+
158
+ reasoning:
159
+ instructions: ->
160
+ # ★ Different authority based on tier
161
+ if @variables.customer_tier == "vip":
162
+ | You can waive fees up to $100 for VIP customers.
163
+ | Proactively offer payment plan options.
164
+
165
+ if @variables.customer_tier == "premium":
166
+ | You can waive fees up to $25 for premium customers.
167
+
168
+ if @variables.customer_tier == "standard":
169
+ | Fee waivers require manager approval. Escalate if requested.
170
+
171
+ | Help the customer understand their bill and resolve issues.
172
+
173
+ actions:
174
+ back: @utils.transition to @topic.topic_selector
175
+ escalate: @utils.escalate
176
+ description: "Transfer to billing specialist"
177
+ available when @variables.customer_tier == "standard"
178
+
179
+ topic support:
180
+ label: "Technical Support"
181
+ description: "Technical support with business hours awareness"
182
+
183
+ reasoning:
184
+ instructions: ->
185
+ if @variables.business_hours == False:
186
+ | Technical support is limited outside business hours.
187
+ | Log the issue for follow-up and provide self-service resources.
188
+
189
+ if @variables.business_hours == True:
190
+ | Full technical support available. Troubleshoot thoroughly.
191
+
192
+ | Help resolve the customer's technical issue.
193
+
194
+ actions:
195
+ back: @utils.transition to @topic.topic_selector
196
+
197
+ # ═══════════════════════════════════════════════════════════════════════════
198
+ # ★ TOPIC-LEVEL SYSTEM OVERRIDES (NEW PATTERN)
199
+ # These topics demonstrate complete persona switching using topic-level
200
+ # system: blocks that OVERRIDE the global system instructions.
201
+ # ═══════════════════════════════════════════════════════════════════════════
202
+
203
+ topic formal_mode:
204
+ label: "Formal Communication"
205
+ description: "Professional business communication mode"
206
+
207
+ # ★ TOPIC-LEVEL SYSTEM OVERRIDE
208
+ # This completely replaces global system instructions for this topic
209
+ system:
210
+ instructions: "You are a formal business professional. Use professional language at all times. Address users as Sir or Madam. Avoid contractions, slang, and casual expressions. Focus on efficiency and clarity. Maintain a respectful, corporate tone."
211
+
212
+ reasoning:
213
+ instructions: ->
214
+ | [Formal Mode Engaged]
215
+ |
216
+ | Good day. How may I be of assistance?
217
+ | I am prepared to address your inquiry with the utmost professionalism.
218
+
219
+ actions:
220
+ back: @utils.transition to @topic.topic_selector
221
+
222
+ topic creative_mode:
223
+ label: "Creative Assistant"
224
+ description: "Creative and imaginative communication mode"
225
+
226
+ # ★ TOPIC-LEVEL SYSTEM OVERRIDE
227
+ # Different persona entirely
228
+ system:
229
+ instructions: "You are a creative and imaginative assistant. Be playful, use metaphors and analogies. Think outside the box. Encourage brainstorming and wild ideas. Use emojis sparingly but effectively. Make conversations engaging and fun while still being helpful."
230
+
231
+ reasoning:
232
+ instructions: ->
233
+ | 🎨 [Creative Mode Activated!]
234
+ |
235
+ | Hey there, creative spirit! Ready to explore some ideas together?
236
+ | Think of me as your brainstorming buddy - no idea is too wild!
237
+ |
238
+ | What shall we dream up today?
239
+
240
+ actions:
241
+ back: @utils.transition to @topic.topic_selector
242
+
243
+ topic technical_expert:
244
+ label: "Technical Expert"
245
+ description: "Deep technical expertise mode"
246
+
247
+ # ★ TOPIC-LEVEL SYSTEM OVERRIDE
248
+ # Specialist persona
249
+ system:
250
+ instructions: "You are a technical expert with deep knowledge. Use precise technical terminology. Provide detailed explanations with examples. Reference documentation when helpful. Assume the user has technical background. Be thorough but avoid unnecessary verbosity."
251
+
252
+ reasoning:
253
+ instructions: ->
254
+ | [Technical Expert Mode]
255
+ |
256
+ | I'm ready to dive deep into technical details.
257
+ | Feel free to use technical terminology - I'll match your level.
258
+ |
259
+ | What technical challenge are we solving?
260
+
261
+ actions:
262
+ back: @utils.transition to @topic.topic_selector
263
+
264
+ # ★ Insight: Three Levels of Instruction Control
265
+ #
266
+ # LEVEL 1: GLOBAL SYSTEM BLOCK
267
+ # - Static text only (no variables, no conditionals)
268
+ # - Applies to ALL topics as baseline
269
+ # - Good for: Guardrails, base personality, universal rules
270
+ # - Example: "Never share confidential information"
271
+ #
272
+ # LEVEL 2: TOPIC-LEVEL SYSTEM BLOCK (NEW!)
273
+ # - Placed inside topic definition
274
+ # - COMPLETELY OVERRIDES global system for that topic
275
+ # - Good for: Persona switching, mode changes, specialist behavior
276
+ # - Example: topic formal_mode: system: instructions: "Be professional..."
277
+ #
278
+ # LEVEL 3: TOPIC REASONING INSTRUCTIONS
279
+ # - Dynamic (variables, conditionals, template expressions)
280
+ # - Extends/adjusts behavior within topic
281
+ # - Good for: Context-aware responses, personalization
282
+ # - Example: if @variables.is_vip: | Provide priority service
283
+ #
284
+ # OVERRIDE HIERARCHY:
285
+ # Topic system: > Global system: > Default behavior
286
+ #
287
+ # COMBINING APPROACHES:
288
+ # - Use GLOBAL system for universal guardrails
289
+ # - Use TOPIC system: for complete persona changes
290
+ # - Use TOPIC reasoning for dynamic conditional behavior
291
+ #
292
+ # Best Practice: Put guardrails in global system, personas in topic system,
293
+ # and context-aware personalization in topic reasoning instructions.
@@ -0,0 +1,131 @@
1
+ # Prompt Template with RAG Search Template
2
+ # =========================================
3
+ #
4
+ # This template demonstrates the pattern for combining Prompt Templates
5
+ # with Data Cloud RAG (Retrieval Augmented Generation) for grounded responses.
6
+ #
7
+ # Pattern: Knowledge search + grounded response generation
8
+ # Use when: FAQ bots, product knowledge agents, documentation assistants
9
+ #
10
+ # CREDIT CONSUMPTION:
11
+ # - Prompt Templates: 2-16 credits per invocation
12
+ # - Retriever actions: 20 credits per search
13
+ # - TIP: Cache retriever results in variables, reuse across topics
14
+
15
+ system:
16
+ messages:
17
+ welcome: "Hello! I can help answer questions about our products and services."
18
+ error: "I apologize, I couldn't find the information you need."
19
+ instructions: "You are a helpful knowledge assistant. Always provide grounded answers based on retrieved knowledge."
20
+
21
+ config:
22
+ agent_name: "RAGSearchAgent"
23
+ agent_label: "Knowledge Assistant"
24
+ description: "Agent demonstrating Prompt Template with Data Cloud RAG pattern"
25
+ default_agent_user: "agent@yourorg.com" # REQUIRED: Change to valid Einstein Agent User
26
+
27
+ variables:
28
+ # Search state
29
+ search_query: mutable string = ""
30
+ description: "User's current search query"
31
+ search_results: mutable string = ""
32
+ description: "Retrieved knowledge chunks (cached for reuse)"
33
+ has_results: mutable boolean = False
34
+ description: "Whether search returned results"
35
+
36
+ # Response tracking
37
+ response_generated: mutable boolean = False
38
+ description: "Whether a response has been generated for current query"
39
+
40
+ start_agent entry:
41
+ description: "Entry point - welcome and route to knowledge search"
42
+ reasoning:
43
+ instructions: |
44
+ Welcome the user and offer to help with questions.
45
+ actions:
46
+ go_search: @utils.transition to @topic.knowledge_search
47
+ description: "Start knowledge search"
48
+
49
+ # ============================================================
50
+ # KNOWLEDGE SEARCH TOPIC (RAG Pattern)
51
+ # ============================================================
52
+
53
+ topic knowledge_search:
54
+ description: "Search knowledge base and generate grounded responses"
55
+ reasoning:
56
+ instructions: ->
57
+ # POST-ACTION: Generate response after retrieval
58
+ if @variables.has_results == True and @variables.response_generated == False:
59
+ # Use Prompt Template to generate grounded response
60
+ run @actions.Generate_Grounded_Response
61
+ with query = @variables.search_query
62
+ with context = @variables.search_results
63
+ set @variables.response_generated = True
64
+
65
+ # NO RESULTS: Escalate or try different search
66
+ if @variables.has_results == False and @variables.search_query != "":
67
+ | I couldn't find information about that topic.
68
+ | Would you like to try a different search, or speak with a human agent?
69
+
70
+ # INITIAL STATE: Ask for question
71
+ if @variables.search_query == "":
72
+ | What would you like to know? I can help with:
73
+ | - Product information
74
+ | - Pricing and plans
75
+ | - Technical specifications
76
+ | - Troubleshooting guides
77
+
78
+ actions:
79
+ # Retriever action for RAG search
80
+ # This searches Data Cloud knowledge base
81
+ search_knowledge: @actions.Search_Knowledge_Base
82
+ description: "Search for relevant information"
83
+ with query = ... # LLM extracts user's question
84
+ include_in_progress_indicator: True
85
+ progress_indicator_message: "Searching our knowledge base..."
86
+ set @variables.search_query = @outputs.original_query
87
+ set @variables.search_results = @outputs.retrieved_chunks
88
+ set @variables.has_results = @outputs.has_results
89
+ set @variables.response_generated = False # Reset for new search
90
+
91
+ # Prompt Template for grounded response
92
+ # Configure in Agentforce Assets with:
93
+ # - Template instructions referencing retrieved context
94
+ # - Set output is_displayable: True (response shown to user)
95
+ generate_answer: @actions.Generate_Grounded_Response
96
+ description: "Generate answer from retrieved knowledge"
97
+ available when @variables.has_results == True
98
+ with query = @variables.search_query
99
+ with context = @variables.search_results
100
+
101
+ # New search
102
+ new_search: @utils.setVariables
103
+ description: "Search for something else"
104
+ with search_query = ""
105
+ with search_results = ""
106
+ with has_results = False
107
+ with response_generated = False
108
+
109
+ escalate_now: @utils.escalate
110
+ description: "Transfer to human agent"
111
+
112
+ # ============================================================
113
+ # FOLLOW-UP QUESTIONS TOPIC
114
+ # ============================================================
115
+
116
+ topic follow_up:
117
+ description: "Handle follow-up questions using cached context"
118
+ reasoning:
119
+ instructions: ->
120
+ # COST OPTIMIZATION: Reuse cached search_results instead of re-searching
121
+ if @variables.search_results != "":
122
+ | Based on what we discussed:
123
+ run @actions.Generate_Grounded_Response
124
+ with query = ... # Follow-up question extracted by LLM
125
+ with context = @variables.search_results # Reuse cached results!
126
+ else:
127
+ transition to @topic.knowledge_search
128
+
129
+ actions:
130
+ back_to_search: @utils.transition to @topic.knowledge_search
131
+ description: "Start a new search"