@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.
- package/package.json +4 -4
- package/skills/agentforce-development/SKILL.md +427 -0
- package/skills/agentforce-development/assets/README-legacy.md +89 -0
- package/skills/agentforce-development/assets/agent-spec-template.md +90 -0
- package/skills/agentforce-development/assets/agents/README.md +45 -0
- package/skills/agentforce-development/assets/agents/hello-world.agent +60 -0
- package/skills/agentforce-development/assets/agents/multi-topic.agent +105 -0
- package/skills/agentforce-development/assets/agents/production-faq.agent +101 -0
- package/skills/agentforce-development/assets/agents/production-faq.bundle-meta.xml +4 -0
- package/skills/agentforce-development/assets/agents/simple-qa.agent +72 -0
- package/skills/agentforce-development/assets/apex/models-api-queueable.cls +225 -0
- package/skills/agentforce-development/assets/bundle-meta.xml +23 -0
- package/skills/agentforce-development/assets/components/apex-action.agent +52 -0
- package/skills/agentforce-development/assets/components/error-handling.agent +58 -0
- package/skills/agentforce-development/assets/components/escalation-setup.agent +169 -0
- package/skills/agentforce-development/assets/components/flow-action.agent +66 -0
- package/skills/agentforce-development/assets/components/n-ary-conditions.agent +110 -0
- package/skills/agentforce-development/assets/components/topic-with-actions.agent +40 -0
- package/skills/agentforce-development/assets/deterministic-routing.agent +166 -0
- package/skills/agentforce-development/assets/escalation-pattern.agent +209 -0
- package/skills/agentforce-development/assets/flow-action-lookup.agent +115 -0
- package/skills/agentforce-development/assets/hub-and-spoke.agent +104 -0
- package/skills/agentforce-development/assets/invocable-apex-template.cls +187 -0
- package/skills/agentforce-development/assets/local-info-agent-annotated.agent +355 -0
- package/skills/agentforce-development/assets/metadata/basic-prompt-template.promptTemplate-meta.xml +109 -0
- package/skills/agentforce-development/assets/metadata/genai-function-apex.xml +92 -0
- package/skills/agentforce-development/assets/metadata/genai-function-flow.xml +57 -0
- package/skills/agentforce-development/assets/metadata/genai-plugin.xml +72 -0
- package/skills/agentforce-development/assets/metadata/http-callout-flow.flow-meta.xml +348 -0
- package/skills/agentforce-development/assets/metadata/record-grounded-prompt.promptTemplate-meta.xml +136 -0
- package/skills/agentforce-development/assets/minimal-starter.agent +42 -0
- package/skills/agentforce-development/assets/patterns/README.md +254 -0
- package/skills/agentforce-development/assets/patterns/action-callbacks.agent +178 -0
- package/skills/agentforce-development/assets/patterns/advanced-input-bindings.agent +141 -0
- package/skills/agentforce-development/assets/patterns/bidirectional-routing.agent +156 -0
- package/skills/agentforce-development/assets/patterns/critical-input-collection.agent +244 -0
- package/skills/agentforce-development/assets/patterns/delegation-routing.agent +89 -0
- package/skills/agentforce-development/assets/patterns/lifecycle-events.agent +127 -0
- package/skills/agentforce-development/assets/patterns/llm-controlled-actions.agent +184 -0
- package/skills/agentforce-development/assets/patterns/multi-step-workflow.agent +282 -0
- package/skills/agentforce-development/assets/patterns/open-gate-routing.agent +286 -0
- package/skills/agentforce-development/assets/patterns/procedural-instructions.agent +273 -0
- package/skills/agentforce-development/assets/patterns/prompt-template-action.agent +188 -0
- package/skills/agentforce-development/assets/patterns/system-instruction-overrides.agent +293 -0
- package/skills/agentforce-development/assets/prompt-rag-search.agent +131 -0
- package/skills/agentforce-development/assets/template-multi-topic.agent +160 -0
- package/skills/agentforce-development/assets/template-single-topic.agent +81 -0
- package/skills/agentforce-development/assets/verification-gate.agent +208 -0
- package/skills/agentforce-development/references/action-prompt-templates.md +164 -0
- package/skills/agentforce-development/references/actions-reference.md +592 -0
- package/skills/agentforce-development/references/agent-access-guide.md +72 -0
- package/skills/agentforce-development/references/agent-design-and-spec-creation.md +1010 -0
- package/skills/agentforce-development/references/agent-metadata-and-lifecycle.md +575 -0
- package/skills/agentforce-development/references/agent-script-core-language.md +1218 -0
- package/skills/agentforce-development/references/agent-topic-map-diagrams.md +323 -0
- package/skills/agentforce-development/references/agent-user-setup.md +526 -0
- package/skills/agentforce-development/references/agent-validation-and-debugging.md +803 -0
- package/skills/agentforce-development/references/known-issues.md +353 -0
- package/skills/agentforce-development/references/minimal-examples.md +67 -0
- package/skills/agentforce-development/references/production-gotchas.md +279 -0
- package/skills/agentforce-development/references/salesforce-cli-for-agents.md +393 -0
- package/skills/agentforce-development/references/version-history.md +23 -0
- package/skills/generate-permission-set/SKILL.md +174 -0
- package/skills/salesforce-custom-application/SKILL.md +1 -2
- package/skills/salesforce-custom-field/SKILL.md +0 -4
- package/skills/salesforce-custom-tab/SKILL.md +84 -8
- package/skills/salesforce-experience-lwr-site/SKILL.md +196 -0
- package/skills/salesforce-experience-lwr-site/docs/bootstrap-template-byo-lwr.md +224 -0
- package/skills/salesforce-experience-lwr-site/docs/configure-content-brandingSet.md +131 -0
- package/skills/salesforce-experience-lwr-site/docs/configure-content-route.md +232 -0
- package/skills/salesforce-experience-lwr-site/docs/configure-content-themeLayout.md +141 -0
- package/skills/salesforce-experience-lwr-site/docs/configure-content-view.md +233 -0
- package/skills/salesforce-experience-lwr-site/docs/configure-guest-sharing-rules.md +42 -0
- package/skills/salesforce-experience-lwr-site/docs/handle-component-and-region-ids.md +27 -0
- package/skills/salesforce-experience-lwr-site/docs/handle-ui-components.md +215 -0
- package/skills/salesforce-flow/SKILL.md +2 -2
- package/skills/salesforce-fragment/SKILL.md +85 -10
- package/skills/salesforce-lightning-app-build/SKILL.md +102 -10
- package/skills/apex-class/SKILL.md +0 -253
- package/skills/apex-class/examples/AccountDeduplicationBatch.cls +0 -148
- package/skills/apex-class/examples/AccountSelector.cls +0 -193
- package/skills/apex-class/examples/AccountService.cls +0 -201
- package/skills/apex-class/templates/abstract.cls +0 -128
- package/skills/apex-class/templates/batch.cls +0 -125
- package/skills/apex-class/templates/domain.cls +0 -102
- package/skills/apex-class/templates/dto.cls +0 -108
- package/skills/apex-class/templates/exception.cls +0 -51
- package/skills/apex-class/templates/interface.cls +0 -25
- package/skills/apex-class/templates/queueable.cls +0 -92
- package/skills/apex-class/templates/schedulable.cls +0 -75
- package/skills/apex-class/templates/selector.cls +0 -92
- package/skills/apex-class/templates/service.cls +0 -69
- package/skills/apex-class/templates/utility.cls +0 -97
- package/skills/apex-test-class/SKILL.md +0 -101
- package/skills/apex-test-class/references/assertion-patterns.md +0 -209
- package/skills/apex-test-class/references/async-testing.md +0 -276
- package/skills/apex-test-class/references/mocking-patterns.md +0 -219
- package/skills/apex-test-class/references/test-data-factory.md +0 -176
- package/skills/deployment-readiness-check/SKILL.md +0 -257
- package/skills/deployment-readiness-check/assets/deployment_checklist.md +0 -286
- package/skills/deployment-readiness-check/references/rollback_procedures.md +0 -308
- package/skills/deployment-readiness-check/scripts/check_metadata.sh +0 -207
- package/skills/salesforce-experience-site/SKILL.md +0 -178
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Complete Agent Templates
|
|
2
|
+
|
|
3
|
+
Templates for building complete, deployable agents.
|
|
4
|
+
|
|
5
|
+
## Learning Path
|
|
6
|
+
|
|
7
|
+
| Template | Complexity | Description |
|
|
8
|
+
|----------|------------|-------------|
|
|
9
|
+
| `hello-world.agent` | Beginner | Minimal viable agent - start here |
|
|
10
|
+
| `simple-qa.agent` | Beginner | Single-topic Q&A agent |
|
|
11
|
+
| `multi-topic.agent` | Intermediate | Multi-topic routing agent |
|
|
12
|
+
| `production-faq.agent` | Advanced | Production-ready FAQ with escalation |
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
1. Copy a template to your SFDX project:
|
|
17
|
+
```bash
|
|
18
|
+
mkdir -p force-app/main/default/aiAuthoringBundles/My_Agent
|
|
19
|
+
cp hello-world.agent force-app/main/default/aiAuthoringBundles/My_Agent/My_Agent.agent
|
|
20
|
+
cp ../metadata/bundle-meta.xml force-app/main/default/aiAuthoringBundles/My_Agent/My_Agent.bundle-meta.xml
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
2. Validate and deploy:
|
|
24
|
+
```bash
|
|
25
|
+
sf agent validate authoring-bundle --api-name My_Agent --target-org your-org
|
|
26
|
+
sf agent publish authoring-bundle --api-name My_Agent --target-org your-org
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Required Blocks
|
|
30
|
+
|
|
31
|
+
Every agent must have these blocks **in this order**:
|
|
32
|
+
|
|
33
|
+
| Block | Purpose |
|
|
34
|
+
|-------|---------|
|
|
35
|
+
| `system:` | Agent personality and default messages |
|
|
36
|
+
| `config:` | Deployment metadata (agent_name, label, etc.) |
|
|
37
|
+
| `variables:` | Data connections and state storage |
|
|
38
|
+
| `language:` | Locale configuration |
|
|
39
|
+
| `start_agent` | Entry point topic (exactly one required) |
|
|
40
|
+
|
|
41
|
+
## Next Steps
|
|
42
|
+
|
|
43
|
+
- [components/](../components/) - Reusable action and topic templates
|
|
44
|
+
- [patterns/](../patterns/) - Advanced patterns for complex behaviors
|
|
45
|
+
- [metadata/](../metadata/) - XML metadata templates
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Hello World Agent
|
|
2
|
+
# The minimal viable Agentforce agent - start here!
|
|
3
|
+
#
|
|
4
|
+
# This template shows the absolute minimum structure required for a working agent.
|
|
5
|
+
# Use this as your starting point when learning Agent Script.
|
|
6
|
+
#
|
|
7
|
+
# ★ Why This Structure?
|
|
8
|
+
# - system: Sets agent personality and default messages
|
|
9
|
+
# - config: Required metadata for deployment (agent_name must be unique)
|
|
10
|
+
# - variables: Linked variables connect to Messaging context (required for deployment)
|
|
11
|
+
# - language: Locale settings (required for deployment)
|
|
12
|
+
# - start_agent: Entry point topic (exactly one required)
|
|
13
|
+
#
|
|
14
|
+
# ★ Key Validation Points (from 100-point scoring):
|
|
15
|
+
# - [10 pts] config block with all 4 required fields
|
|
16
|
+
# - [10 pts] 3 linked variables (EndUserId, RoutableId, ContactId)
|
|
17
|
+
# - [5 pts] language block present
|
|
18
|
+
# - [10 pts] At least one start_agent topic
|
|
19
|
+
#
|
|
20
|
+
# Deploy with: sf agent publish authoring-bundle --api-name Hello_World_Agent --target-org [alias]
|
|
21
|
+
|
|
22
|
+
system:
|
|
23
|
+
instructions: "You are a friendly assistant. Greet users warmly and help them."
|
|
24
|
+
messages:
|
|
25
|
+
welcome: "Hello! I'm here to help. What can I do for you today?"
|
|
26
|
+
error: "I'm sorry, something went wrong. Please try again."
|
|
27
|
+
|
|
28
|
+
config:
|
|
29
|
+
agent_name: "Hello_World_Agent"
|
|
30
|
+
default_agent_user: "your.user@company.com"
|
|
31
|
+
agent_label: "Hello World Agent"
|
|
32
|
+
description: "A minimal example agent to learn Agent Script basics"
|
|
33
|
+
|
|
34
|
+
variables:
|
|
35
|
+
# Linked variables (required) - Connect to Salesforce Messaging context
|
|
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
|
+
language:
|
|
47
|
+
default_locale: "en_US"
|
|
48
|
+
additional_locales: ""
|
|
49
|
+
all_additional_locales: False
|
|
50
|
+
|
|
51
|
+
# Entry point topic - this is where every conversation starts
|
|
52
|
+
start_agent main:
|
|
53
|
+
label: "Main"
|
|
54
|
+
description: "Greets users and provides help"
|
|
55
|
+
|
|
56
|
+
reasoning:
|
|
57
|
+
instructions: ->
|
|
58
|
+
| Welcome the user warmly.
|
|
59
|
+
| Ask how you can help them today.
|
|
60
|
+
| Be friendly and conversational.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Multi-Topic Agent Template
|
|
2
|
+
# An agent with multiple conversation topics (hub-and-spoke pattern)
|
|
3
|
+
# Users are routed to specialized topics based on their needs
|
|
4
|
+
#
|
|
5
|
+
# Usage: Replace {{placeholders}} with your values
|
|
6
|
+
# Required: agent_name, default_agent_user, agent_label, description
|
|
7
|
+
# Required: At least 2 topics with label and description
|
|
8
|
+
|
|
9
|
+
system:
|
|
10
|
+
instructions: "{{SystemInstructions}}"
|
|
11
|
+
messages:
|
|
12
|
+
welcome: "{{WelcomeMessage}}"
|
|
13
|
+
error: "I'm sorry, I encountered an issue. Please try again."
|
|
14
|
+
|
|
15
|
+
config:
|
|
16
|
+
agent_name: "{{AgentApiName}}"
|
|
17
|
+
default_agent_user: "{{AgentUser}}"
|
|
18
|
+
agent_label: "{{AgentLabel}}"
|
|
19
|
+
description: "{{AgentDescription}}"
|
|
20
|
+
|
|
21
|
+
variables:
|
|
22
|
+
EndUserId: linked string
|
|
23
|
+
source: @MessagingSession.MessagingEndUserId
|
|
24
|
+
description: "Messaging End User ID"
|
|
25
|
+
RoutableId: linked string
|
|
26
|
+
source: @MessagingSession.Id
|
|
27
|
+
description: "Messaging Session ID"
|
|
28
|
+
ContactId: linked string
|
|
29
|
+
source: @MessagingEndUser.ContactId
|
|
30
|
+
description: "Contact ID"
|
|
31
|
+
user_intent: mutable string
|
|
32
|
+
description: "What the user is trying to accomplish"
|
|
33
|
+
|
|
34
|
+
language:
|
|
35
|
+
default_locale: "en_US"
|
|
36
|
+
additional_locales: ""
|
|
37
|
+
all_additional_locales: False
|
|
38
|
+
|
|
39
|
+
start_agent topic_selector:
|
|
40
|
+
label: "Topic Selector"
|
|
41
|
+
description: "Routes users to the appropriate topic based on their needs"
|
|
42
|
+
|
|
43
|
+
reasoning:
|
|
44
|
+
instructions: ->
|
|
45
|
+
| Determine what the user needs help with.
|
|
46
|
+
| Route them to the most appropriate topic.
|
|
47
|
+
| If unclear, ask clarifying questions.
|
|
48
|
+
actions:
|
|
49
|
+
go_to_topic_one: @utils.transition to @topic.{{topic_one_name}}
|
|
50
|
+
go_to_topic_two: @utils.transition to @topic.{{topic_two_name}}
|
|
51
|
+
go_to_topic_three: @utils.transition to @topic.{{topic_three_name}}
|
|
52
|
+
go_to_farewell: @utils.transition to @topic.farewell
|
|
53
|
+
go_to_escalation: @utils.transition to @topic.escalation
|
|
54
|
+
|
|
55
|
+
topic {{topic_one_name}}:
|
|
56
|
+
label: "{{TopicOneLabel}}"
|
|
57
|
+
description: "{{TopicOneDescription}}"
|
|
58
|
+
|
|
59
|
+
reasoning:
|
|
60
|
+
instructions: ->
|
|
61
|
+
| {{TopicOneInstructions}}
|
|
62
|
+
actions:
|
|
63
|
+
back_to_menu: @utils.transition to @topic.topic_selector
|
|
64
|
+
|
|
65
|
+
topic {{topic_two_name}}:
|
|
66
|
+
label: "{{TopicTwoLabel}}"
|
|
67
|
+
description: "{{TopicTwoDescription}}"
|
|
68
|
+
|
|
69
|
+
reasoning:
|
|
70
|
+
instructions: ->
|
|
71
|
+
| {{TopicTwoInstructions}}
|
|
72
|
+
actions:
|
|
73
|
+
back_to_menu: @utils.transition to @topic.topic_selector
|
|
74
|
+
|
|
75
|
+
topic {{topic_three_name}}:
|
|
76
|
+
label: "{{TopicThreeLabel}}"
|
|
77
|
+
description: "{{TopicThreeDescription}}"
|
|
78
|
+
|
|
79
|
+
reasoning:
|
|
80
|
+
instructions: ->
|
|
81
|
+
| {{TopicThreeInstructions}}
|
|
82
|
+
actions:
|
|
83
|
+
back_to_menu: @utils.transition to @topic.topic_selector
|
|
84
|
+
|
|
85
|
+
topic farewell:
|
|
86
|
+
label: "Farewell"
|
|
87
|
+
description: "Ends the conversation gracefully"
|
|
88
|
+
|
|
89
|
+
reasoning:
|
|
90
|
+
instructions: ->
|
|
91
|
+
| Thank the user for reaching out.
|
|
92
|
+
| Wish them a great day.
|
|
93
|
+
| Let them know they can return anytime.
|
|
94
|
+
|
|
95
|
+
topic escalation:
|
|
96
|
+
label: "Escalation"
|
|
97
|
+
description: "Handles requests to transfer to a live human agent"
|
|
98
|
+
|
|
99
|
+
reasoning:
|
|
100
|
+
instructions: ->
|
|
101
|
+
| If the user explicitly asks to speak with a human, escalate.
|
|
102
|
+
| Acknowledge the request and transfer gracefully.
|
|
103
|
+
actions:
|
|
104
|
+
escalate_to_human: @utils.escalate
|
|
105
|
+
description: "Escalate to a human agent"
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Simple FAQ Agent
|
|
2
|
+
# A minimal working example of an Agentforce agent
|
|
3
|
+
# Uses pure LLM reasoning without external actions
|
|
4
|
+
#
|
|
5
|
+
# Deploy with: sf agent publish authoring-bundle --api-name Simple_FAQ_Agent --target-org [alias]
|
|
6
|
+
|
|
7
|
+
system:
|
|
8
|
+
instructions: "You are a helpful FAQ assistant for our company. Answer questions accurately and concisely. If you don't know the answer, say so honestly. Never share sensitive or confidential information. Keep responses friendly and professional."
|
|
9
|
+
messages:
|
|
10
|
+
welcome: "Hello! I'm your FAQ assistant. How can I help you today?"
|
|
11
|
+
error: "I'm sorry, I encountered an issue. Please try again."
|
|
12
|
+
|
|
13
|
+
config:
|
|
14
|
+
agent_name: "Simple_FAQ_Agent"
|
|
15
|
+
default_agent_user: "agent.user@company.com"
|
|
16
|
+
agent_label: "Simple FAQ Agent"
|
|
17
|
+
description: "A minimal FAQ agent that answers common questions using AI"
|
|
18
|
+
|
|
19
|
+
variables:
|
|
20
|
+
EndUserId: linked string
|
|
21
|
+
source: @MessagingSession.MessagingEndUserId
|
|
22
|
+
description: "Messaging End User ID"
|
|
23
|
+
RoutableId: linked string
|
|
24
|
+
source: @MessagingSession.Id
|
|
25
|
+
description: "Messaging Session ID"
|
|
26
|
+
ContactId: linked string
|
|
27
|
+
source: @MessagingEndUser.ContactId
|
|
28
|
+
description: "Contact ID"
|
|
29
|
+
user_question: mutable string
|
|
30
|
+
description: "The user's current question"
|
|
31
|
+
conversation_topic: mutable string
|
|
32
|
+
description: "The current topic being discussed"
|
|
33
|
+
question_count: mutable number
|
|
34
|
+
description: "Number of questions answered in this session"
|
|
35
|
+
|
|
36
|
+
language:
|
|
37
|
+
default_locale: "en_US"
|
|
38
|
+
additional_locales: ""
|
|
39
|
+
all_additional_locales: False
|
|
40
|
+
|
|
41
|
+
start_agent topic_selector:
|
|
42
|
+
label: "Topic Selector"
|
|
43
|
+
description: "Routes incoming questions to the FAQ handler"
|
|
44
|
+
|
|
45
|
+
reasoning:
|
|
46
|
+
instructions: ->
|
|
47
|
+
| Listen to the user's question and determine how to help.
|
|
48
|
+
| If the question is about a specific topic, note it.
|
|
49
|
+
| Route to the FAQ handler for processing.
|
|
50
|
+
actions:
|
|
51
|
+
handle_faq: @utils.transition to @topic.faq_handler
|
|
52
|
+
end_conversation: @utils.transition to @topic.farewell
|
|
53
|
+
|
|
54
|
+
topic faq_handler:
|
|
55
|
+
label: "FAQ Handler"
|
|
56
|
+
description: "Handles frequently asked questions and provides helpful answers"
|
|
57
|
+
|
|
58
|
+
reasoning:
|
|
59
|
+
instructions: ->
|
|
60
|
+
| Answer the user's question based on your knowledge.
|
|
61
|
+
| Be helpful, accurate, and concise.
|
|
62
|
+
| Keep responses under 3-4 sentences when possible.
|
|
63
|
+
| If you need more information, ask clarifying questions.
|
|
64
|
+
|
|
|
65
|
+
| Common topics you can help with:
|
|
66
|
+
| - Business hours and location
|
|
67
|
+
| - Return and refund policies
|
|
68
|
+
| - Shipping information
|
|
69
|
+
| - Product questions
|
|
70
|
+
| - Account and billing
|
|
71
|
+
|
|
|
72
|
+
| If the question is outside your knowledge:
|
|
73
|
+
| - Acknowledge you don't have that information
|
|
74
|
+
| - Suggest contacting customer support
|
|
75
|
+
| - Offer to help with something else
|
|
76
|
+
actions:
|
|
77
|
+
new_question: @utils.transition to @topic.topic_selector
|
|
78
|
+
end_conversation: @utils.transition to @topic.farewell
|
|
79
|
+
escalate: @utils.transition to @topic.escalation
|
|
80
|
+
|
|
81
|
+
topic farewell:
|
|
82
|
+
label: "Farewell"
|
|
83
|
+
description: "Ends the conversation politely"
|
|
84
|
+
|
|
85
|
+
reasoning:
|
|
86
|
+
instructions: ->
|
|
87
|
+
| Thank the user for their questions.
|
|
88
|
+
| Wish them a great day.
|
|
89
|
+
| Let them know they can return anytime for more help.
|
|
90
|
+
|
|
91
|
+
topic escalation:
|
|
92
|
+
label: "Escalation"
|
|
93
|
+
description: "Handles requests to speak with a human agent"
|
|
94
|
+
|
|
95
|
+
reasoning:
|
|
96
|
+
instructions: ->
|
|
97
|
+
| If the user wants to speak with a human, escalate gracefully.
|
|
98
|
+
| Acknowledge their request and transfer the conversation.
|
|
99
|
+
actions:
|
|
100
|
+
escalate_to_human: @utils.escalate
|
|
101
|
+
description: "Transfer to a human agent"
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Simple Q&A Agent Template
|
|
2
|
+
# A minimal agent that handles basic questions using LLM reasoning only
|
|
3
|
+
# No external actions - just conversational AI
|
|
4
|
+
#
|
|
5
|
+
# Usage: Replace {{placeholders}} with your values
|
|
6
|
+
# Required: agent_name, default_agent_user, agent_label, description
|
|
7
|
+
|
|
8
|
+
system:
|
|
9
|
+
instructions: "{{SystemInstructions}}"
|
|
10
|
+
messages:
|
|
11
|
+
welcome: "{{WelcomeMessage}}"
|
|
12
|
+
error: "I'm sorry, I encountered an issue. Please try again."
|
|
13
|
+
|
|
14
|
+
config:
|
|
15
|
+
agent_name: "{{AgentApiName}}"
|
|
16
|
+
default_agent_user: "{{AgentUser}}"
|
|
17
|
+
agent_label: "{{AgentLabel}}"
|
|
18
|
+
description: "{{AgentDescription}}"
|
|
19
|
+
|
|
20
|
+
variables:
|
|
21
|
+
EndUserId: linked string
|
|
22
|
+
source: @MessagingSession.MessagingEndUserId
|
|
23
|
+
description: "Messaging End User ID"
|
|
24
|
+
RoutableId: linked string
|
|
25
|
+
source: @MessagingSession.Id
|
|
26
|
+
description: "Messaging Session ID"
|
|
27
|
+
ContactId: linked string
|
|
28
|
+
source: @MessagingEndUser.ContactId
|
|
29
|
+
description: "Contact ID"
|
|
30
|
+
user_query: mutable string
|
|
31
|
+
description: "The user's current question or request"
|
|
32
|
+
|
|
33
|
+
language:
|
|
34
|
+
default_locale: "en_US"
|
|
35
|
+
additional_locales: ""
|
|
36
|
+
all_additional_locales: False
|
|
37
|
+
|
|
38
|
+
start_agent topic_selector:
|
|
39
|
+
label: "Topic Selector"
|
|
40
|
+
description: "Routes incoming requests to the Q&A handler"
|
|
41
|
+
|
|
42
|
+
reasoning:
|
|
43
|
+
instructions: ->
|
|
44
|
+
| Listen to the user's question.
|
|
45
|
+
| Route to the Q&A handler for processing.
|
|
46
|
+
actions:
|
|
47
|
+
handle_question: @utils.transition to @topic.qa_handler
|
|
48
|
+
end_conversation: @utils.transition to @topic.farewell
|
|
49
|
+
|
|
50
|
+
topic qa_handler:
|
|
51
|
+
label: "Q&A Handler"
|
|
52
|
+
description: "Handles questions and provides answers"
|
|
53
|
+
|
|
54
|
+
reasoning:
|
|
55
|
+
instructions: ->
|
|
56
|
+
| Answer the user's question based on your knowledge.
|
|
57
|
+
| Be helpful, accurate, and concise.
|
|
58
|
+
| Keep responses clear and easy to understand.
|
|
59
|
+
| If you need more information, ask clarifying questions.
|
|
60
|
+
actions:
|
|
61
|
+
new_question: @utils.transition to @topic.topic_selector
|
|
62
|
+
end_conversation: @utils.transition to @topic.farewell
|
|
63
|
+
|
|
64
|
+
topic farewell:
|
|
65
|
+
label: "Farewell"
|
|
66
|
+
description: "Ends the conversation gracefully"
|
|
67
|
+
|
|
68
|
+
reasoning:
|
|
69
|
+
instructions: ->
|
|
70
|
+
| Thank the user for their questions.
|
|
71
|
+
| Wish them a great day.
|
|
72
|
+
| Let them know they can return anytime for more help.
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Queueable job for AI generation using Agentforce Models API
|
|
3
|
+
* Generates {{Description}} for {{ObjectName}} records
|
|
4
|
+
* @author {{Author}}
|
|
5
|
+
* @date {{Date}}
|
|
6
|
+
*
|
|
7
|
+
* @requires API v61.0+ (Spring '24)
|
|
8
|
+
* @requires Einstein Generative AI enabled
|
|
9
|
+
* @requires Einstein Generative AI User permission set
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Invoke from trigger or other context:
|
|
13
|
+
* List<Id> recordIds = new List<Id>{ '001xx000003DGXXX' };
|
|
14
|
+
* System.enqueueJob(new {{ClassName}}_AI_Queueable(recordIds));
|
|
15
|
+
*/
|
|
16
|
+
public with sharing class {{ClassName}}_AI_Queueable implements Queueable, Database.AllowsCallouts {
|
|
17
|
+
|
|
18
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
19
|
+
// CONFIGURATION
|
|
20
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Available Models:
|
|
24
|
+
* - sfdc_ai__DefaultOpenAIGPT4OmniMini (Cost-effective, faster)
|
|
25
|
+
* - sfdc_ai__DefaultOpenAIGPT4Omni (More capable, slower)
|
|
26
|
+
* - sfdc_ai__DefaultAnthropic (Claude - nuanced)
|
|
27
|
+
* - sfdc_ai__DefaultGoogleGemini (Multimodal capable)
|
|
28
|
+
*/
|
|
29
|
+
private static final String AI_MODEL = 'sfdc_ai__DefaultOpenAIGPT4OmniMini';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Maximum records to process in a single job.
|
|
33
|
+
* Recommended: 10-20 for AI processing to avoid timeouts.
|
|
34
|
+
*/
|
|
35
|
+
private static final Integer MAX_RECORDS_PER_JOB = 20;
|
|
36
|
+
|
|
37
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
38
|
+
// INSTANCE VARIABLES
|
|
39
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
40
|
+
|
|
41
|
+
private List<Id> recordIds;
|
|
42
|
+
|
|
43
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
44
|
+
// CONSTRUCTOR
|
|
45
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @description Constructor
|
|
49
|
+
* @param recordIds List of {{ObjectName}} record IDs to process
|
|
50
|
+
*/
|
|
51
|
+
public {{ClassName}}_AI_Queueable(List<Id> recordIds) {
|
|
52
|
+
this.recordIds = recordIds;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
56
|
+
// QUEUEABLE EXECUTION
|
|
57
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @description Execute the queueable job
|
|
61
|
+
* @param context QueueableContext
|
|
62
|
+
*/
|
|
63
|
+
public void execute(QueueableContext context) {
|
|
64
|
+
if (recordIds == null || recordIds.isEmpty()) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Split into current batch and remaining
|
|
69
|
+
List<Id> currentBatch = new List<Id>();
|
|
70
|
+
List<Id> remainingIds = new List<Id>();
|
|
71
|
+
|
|
72
|
+
for (Integer i = 0; i < recordIds.size(); i++) {
|
|
73
|
+
if (i < MAX_RECORDS_PER_JOB) {
|
|
74
|
+
currentBatch.add(recordIds[i]);
|
|
75
|
+
} else {
|
|
76
|
+
remainingIds.add(recordIds[i]);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Process current batch
|
|
81
|
+
processRecords(currentBatch);
|
|
82
|
+
|
|
83
|
+
// Chain next job if more records remain
|
|
84
|
+
if (!remainingIds.isEmpty() && !Test.isRunningTest()) {
|
|
85
|
+
System.enqueueJob(new {{ClassName}}_AI_Queueable(remainingIds));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
90
|
+
// PROCESSING LOGIC
|
|
91
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @description Process a batch of records
|
|
95
|
+
* @param batchIds Record IDs to process in this batch
|
|
96
|
+
*/
|
|
97
|
+
private void processRecords(List<Id> batchIds) {
|
|
98
|
+
// Query records with fields needed for AI prompt
|
|
99
|
+
List<{{ObjectName}}> records = [
|
|
100
|
+
SELECT Id, Name
|
|
101
|
+
// TODO: Add fields needed for AI context
|
|
102
|
+
// , Description, Subject, Type
|
|
103
|
+
FROM {{ObjectName}}
|
|
104
|
+
WHERE Id IN :batchIds
|
|
105
|
+
WITH USER_MODE
|
|
106
|
+
];
|
|
107
|
+
|
|
108
|
+
List<{{ObjectName}}> toUpdate = new List<{{ObjectName}}>();
|
|
109
|
+
|
|
110
|
+
for ({{ObjectName}} record : records) {
|
|
111
|
+
try {
|
|
112
|
+
// Generate AI content
|
|
113
|
+
String aiContent = generateAIContent(record);
|
|
114
|
+
|
|
115
|
+
if (String.isNotBlank(aiContent)) {
|
|
116
|
+
// TODO: Update the target field with AI-generated content
|
|
117
|
+
// record.AI_Summary__c = aiContent;
|
|
118
|
+
toUpdate.add(record);
|
|
119
|
+
}
|
|
120
|
+
} catch (Exception e) {
|
|
121
|
+
// Log error but continue processing other records
|
|
122
|
+
logError(record.Id, e);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Batch update
|
|
127
|
+
if (!toUpdate.isEmpty()) {
|
|
128
|
+
try {
|
|
129
|
+
update toUpdate;
|
|
130
|
+
} catch (DmlException e) {
|
|
131
|
+
System.debug(LoggingLevel.ERROR, 'DML Error: ' + e.getMessage());
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
137
|
+
// AI GENERATION
|
|
138
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @description Generate AI content for a single record
|
|
142
|
+
* @param record The record to generate content for
|
|
143
|
+
* @return Generated text content
|
|
144
|
+
*/
|
|
145
|
+
private String generateAIContent({{ObjectName}} record) {
|
|
146
|
+
// Build the prompt with record context
|
|
147
|
+
String prompt = buildPrompt(record);
|
|
148
|
+
|
|
149
|
+
// Create Models API request
|
|
150
|
+
aiplatform.ModelsAPI.createGenerations_Request request =
|
|
151
|
+
new aiplatform.ModelsAPI.createGenerations_Request();
|
|
152
|
+
request.modelName = AI_MODEL;
|
|
153
|
+
|
|
154
|
+
aiplatform.ModelsAPI_GenerationRequest genRequest =
|
|
155
|
+
new aiplatform.ModelsAPI_GenerationRequest();
|
|
156
|
+
genRequest.prompt = prompt;
|
|
157
|
+
request.body = genRequest;
|
|
158
|
+
|
|
159
|
+
// Call the API
|
|
160
|
+
aiplatform.ModelsAPI.createGenerations_Response response =
|
|
161
|
+
aiplatform.ModelsAPI.createGenerations(request);
|
|
162
|
+
|
|
163
|
+
// Extract and return generated text
|
|
164
|
+
if (response.Code200 != null &&
|
|
165
|
+
response.Code200.generations != null &&
|
|
166
|
+
!response.Code200.generations.isEmpty()) {
|
|
167
|
+
return response.Code200.generations[0].text;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* @description Build the AI prompt for a record
|
|
175
|
+
* @param record The record to build prompt for
|
|
176
|
+
* @return Formatted prompt string
|
|
177
|
+
*/
|
|
178
|
+
private String buildPrompt({{ObjectName}} record) {
|
|
179
|
+
// TODO: Customize this prompt for your use case
|
|
180
|
+
String prompt =
|
|
181
|
+
'{{PromptInstructions}}\n\n' +
|
|
182
|
+
'Record Information:\n' +
|
|
183
|
+
'- Name: ' + record.Name + '\n';
|
|
184
|
+
// TODO: Add more fields as needed
|
|
185
|
+
// '- Description: ' + record.Description + '\n' +
|
|
186
|
+
// '- Type: ' + record.Type + '\n';
|
|
187
|
+
|
|
188
|
+
return prompt;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
192
|
+
// ERROR HANDLING
|
|
193
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* @description Log processing errors
|
|
197
|
+
* @param recordId The record that failed
|
|
198
|
+
* @param e The exception that occurred
|
|
199
|
+
*/
|
|
200
|
+
private void logError(Id recordId, Exception e) {
|
|
201
|
+
System.debug(LoggingLevel.ERROR,
|
|
202
|
+
'{{ClassName}}_AI_Queueable Error for ' + recordId + ': ' + e.getMessage());
|
|
203
|
+
System.debug(LoggingLevel.ERROR, 'Stack Trace: ' + e.getStackTraceString());
|
|
204
|
+
|
|
205
|
+
// TODO: Implement custom error logging
|
|
206
|
+
// Options:
|
|
207
|
+
// 1. Create Error_Log__c record
|
|
208
|
+
// 2. Publish Platform Event for monitoring
|
|
209
|
+
// 3. Send email notification
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
213
|
+
// TEST SUPPORT
|
|
214
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* @description Test-visible method to verify prompt generation
|
|
218
|
+
* @param record Test record
|
|
219
|
+
* @return Generated prompt
|
|
220
|
+
*/
|
|
221
|
+
@TestVisible
|
|
222
|
+
private String testBuildPrompt({{ObjectName}} record) {
|
|
223
|
+
return buildPrompt(record);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!--
|
|
3
|
+
AUTHORING BUNDLE METADATA FILE
|
|
4
|
+
==============================
|
|
5
|
+
|
|
6
|
+
CRITICAL NAMING CONVENTION:
|
|
7
|
+
- File MUST be named: AgentName.bundle-meta.xml
|
|
8
|
+
- NOT: AgentName.aiAuthoringBundle-meta.xml
|
|
9
|
+
|
|
10
|
+
DIRECTORY STRUCTURE:
|
|
11
|
+
force-app/main/default/aiAuthoringBundles/
|
|
12
|
+
└── MyAgent/
|
|
13
|
+
├── MyAgent.agent <- Agent Script file
|
|
14
|
+
└── MyAgent.bundle-meta.xml <- This file (rename to match agent)
|
|
15
|
+
|
|
16
|
+
DEPLOYMENT COMMAND:
|
|
17
|
+
sf agent publish authoring-bundle --api-name MyAgent --target-org TARGET_ORG
|
|
18
|
+
|
|
19
|
+
DO NOT USE: sf project deploy start (will fail with "Required fields are missing: [BundleType]")
|
|
20
|
+
-->
|
|
21
|
+
<AiAuthoringBundle xmlns="http://soap.sforce.com/2006/04/metadata">
|
|
22
|
+
<bundleType>AGENT</bundleType>
|
|
23
|
+
</AiAuthoringBundle>
|