Apex - Custom Action Example
Agent Script - Customer Support
Agent Script - Update Agents With New Terms
Agent Script - Enforce Subagent Sequencing With Variables
This agent helps customers get information about their order. It contains three subagents:
agent_router subagent, which provides general instructions to the LLM and exposes two tools that the LLM can choose to call. The two tools are utilities that transition to the required subagents, based on user input.Identity subagent, which verifies the user’s identity. This subagent allows the LLM to request the user’s email (if it doesn’t exist), then sends a verification code to the provided email. Then, the LLM can validate the verification code that the customer provides. This subagent contains deterministic tools and actions, while allowing the LLM freedom to use natural language to interact with the user.order_management subagent, which allows the user to look up order details.developer_name. If you make multiple agents from one example script, change the developer name each time.Tip
1system:
2 instructions: "You are a helpful, professional assistant that provides customers with information about their orders."
3 messages:
4 welcome: "Hi there, I'm your Pronto Customer Support Assistant."
5 error: "Sorry, something went wrong on my end. Could you say that again in a different way?"
6
7config:
8 developer_name: "pronto_customer_support_assistant"
9 description: "Assists customers with their orders while following defined support policies."
10
11access:
12 default_agent_user: "agentforce@salesforce.com"
13
14variables:
15 # Identity
16 member_name: mutable string
17 description: "This is the name of the member."
18 member_email: mutable string = ""
19 description: "This is the email address of the member."
20 member_number: mutable string
21 description: "This is the member number for identification."
22 verification_code: mutable string
23 description: "This is the verification code to validate against the user's."
24 user_verification_code: mutable string
25 description: "This is the verification code entered by the user."
26 verified: mutable boolean = False
27 description: "Shows whether or not the user's identity has been verified."
28 first_name: mutable string
29 description: "this is the first name"
30 days_since_order: mutable number
31 description: "this is the days since the order was placed"
32
33 # Orders
34 order_id: mutable string
35 description: "This is the Order ID of the order they placed."
36 order_summary: mutable string = ""
37 description: "This is the summary of the order."
38 order_canceled: mutable boolean
39 description: "This indicates if the order has been canceled."
40
41
42language:
43 default_locale: "en_US"
44 additional_locales: ""
45 all_additional_locales: False
46
47# The entry point for the agent, on every customer utterance.
48start_agent agent_router:
49 description: "Welcome the user and determine the appropriate subagent based on user input"
50 reasoning:
51 instructions: ->
52 | You are an agent router for a Customer Service Bot assistant.
53 Welcome the guest and analyze their input to determine the most appropriate subagent to handle their request.
54 NEVER escalate to a human unless explicitly requested. A bad experience shouldn't automatically escalate.
55 # This section lists the tools that the LLM
56 # can choose to use. In this example, the LLM has two tools:
57 # transitioning to the Identity subagent or transitioning to the
58 # Order_Management subagent
59 actions:
60 # Transitions deterministically route execution to the specified subagent.
61 # Once the LLM chooses to use this tool, the execution is guaranteed
62 # to transition.
63 go_to_identity: @utils.transition to @subagent.Identity
64 description: "verifies user identity"
65 available when @variables.verified == False
66 go_to_order: @utils.transition to @subagent.Order_Management
67 description: "Handles order lookup, refunds, order updates, and summarizes status, order date, current location, delivery address, items, and driver name."
68 available when @variables.verified == True
69
70subagent Identity:
71 description: "Handles verification of the user's identity before providing access to all other topics."
72 reasoning:
73 instructions: ->
74 if @variables.member_email != "":
75 run @actions.send_verification_code
76 with email=@variables.member_email
77 with member_number = @variables.member_number
78 set @variables.verification_code=@outputs.verification_code
79 set @variables.member_name=@outputs.member_name
80
81 | Greet the user and inform them that to help them get started you've sent them a verification code via email.
82 # This prompt contains two actions that the LLM can choose to run -
83 # a tool to send the verification code, and a tool to validate the
84 # verification code. Once the LLM chooses to run these actions,
85 # the actions are run deterministically
86 Ask the user for the verification code they received and verify it using {!@actions.validate_verification_code}.
87 If the user says they did not receive the code, ask them to confirm their email and resend the verification code using {!@actions.send_verification_code}
88
89 # The reasoning.actions section declares the tools that the LLM can choose
90 # to run. This section has three tools - two actions and
91 # one transition.
92 actions:
93 send_verification_code: @actions.send_verification_code
94 with email=@variables.member_email
95 with member_number=@variables.member_number
96 set @variables.verification_code=@outputs.verification_code
97
98 validate_verification_code: @actions.validate_verification_code
99 available when @variables.verification_code != None
100 with user_verification_code=@variables.user_verification_code
101 set @variables.verified=@outputs.verification
102
103 go_to_order_management: @utils.transition to @subagent.Order_Management
104 available when @variables.verified == True
105
106
107 # This section defines the actions available to this subagent. Actions are
108 # only valid within the subagent in which they are defined.
109 actions:
110 send_verification_code:
111 description: "Send a verification code to the member and verify confirmation."
112 inputs:
113 email: string
114 member_number: string
115 outputs:
116 verification_code: string
117 member_name: string
118 target: "flow://Get_Verification_Code"
119
120
121 validate_verification_code:
122 description: "validate the verification code"
123 inputs:
124 verification_code: string
125 outputs:
126 verification: boolean
127 description: "always validate and return True"
128 target: "flow://validate_Verification_Code"
129
130
131subagent Order_Management:
132 description: "Handles order lookup, order updates, and summaries including status, date, location, items, and driver."
133
134 reasoning:
135 instructions: ->
136 if @variables.order_summary == "":
137 run @actions.lookup_current_order
138 with member_email=@variables.member_email
139 set @variables.order_summary=@outputs.order_summary
140
141 | Refer to the user by name {!@variables.member_name}.
142 Show their current order summary: {!@variables.order_summary} when conversation starts or if requested.
143 If they want past order info, ask for Order ID and use {!@actions.lookup_order}.
144
145 actions:
146 # The ... indicates that the LLM can use reasoning to select the
147 # information from the customer's conversation, then input
148 # the information into the correct input variables
149 lookup_order: @actions.lookup_order
150 with query = ...
151 # Store the action's output into variables
152 set @variables.order_summary=@outputs.order_summary
153 set @variables.order_id=@outputs.order_id
154
155
156 lookup_current_order: @actions.lookup_current_order
157 with member_email=@variables.member_email
158 set @variables.order_summary=@outputs.order_summary
159 set @variables.order_id=@outputs.order_id
160
161 actions:
162 lookup_order:
163 description: "Retrieve order details."
164 inputs:
165 query: string
166 outputs:
167 order_summary: string
168 order_id: string
169 target: "flow://SvcCopilotTmpl__GetOrdersByContact"
170
171 lookup_current_order:
172 description: "Retrieve current order details."
173 inputs:
174 member_email: string
175 outputs:
176 order_summary: string
177 order_id: string
178 target: "flow://SvcCopilotTmpl__GetOrderByOrderNumber"
179# End of customer support script