本文是《部署 Agent 认证 — 客户验证 + 条件逻辑 + 双因素认证》的练习操作步骤。阅读原文请见:部署 Agent 认证 — 客户验证 + 条件逻辑 + 双因素认证。
1. Import the Agent
- Open the App Launcher and select Agentforce Studio.
- Click the down arrow next to New Agent and select New from Script.
- Paste the provided Agent Script, then click Create Agent.
- If needed, click Pronto Service Agent to open it, then click Save.
- In the Assign a user record section, select Select User, choose EinsteinServiceAgent User, then Save.
2. Create the Issues and Refunds Subagent
- Click the + sign next to Subagents, then + New Subagent.
- Name:
Order Issues and Refunds; add the provided "job" description; click Create and Open. - Paste the provided Instructions text, then Save.
3. Create Actions for the Subagent
- Click the + next to Order Issues and Refunds, then + New Action.
- Name:
Get Customer Profile; Description:Retrieves a customer profile based on their email address.; Create and Open. - Reference Action Type Apex, Category Invocable Method, Reference Action Get Customer Profile; Save.
- Name:
- Click the + again, then + New Action.
- Name:
Get Related Cases; Description:Retrieves a customer's related cases (basic details) based on the requested case status.; Create and Open. - Reference Action Type Apex, Reference Action Get Related Cases; under Outputs, check Show in conversation for Cases; Save.
- Name:
4. Update the Get Related Cases Agent Script
- In the Get Related Cases action, switch from Canvas to Script view.
- Find
cases: objectand change tocases: list[object]. - Find
complex_data_type_name: "lightning__listType"and replacelightning__listTypewith@apexClassType/c__AgentCaseActions$CaseSummary. - Click Save.
5. Add Instructions and Test
- Switch back to Canvas view, open Order Issues and Refunds, add the provided instructions (ask for email, run Get Customer Profile and Get Related Cases), then Save.
- Click Preview and enter
Can you show me all of my cases?, press Enter. - When asked, enter
my email is alex.morgan@example.com. - Confirm the agent runs Get Customer Profile then Get Related Cases and shows case results.
6. Create the Verify Customers Subagent
- Click the + next to Subagents, then + New Subagent.
- Name:
Verify Customers; Description:This subagent verifies the identity of the customer before allowing access to sensitive support actions.; Create and Open. - Paste
Verify the identity of the customer.into Instructions, then Save.
7. Create Actions for Verify Customers
- Add action
Send Email with Verification Code(Reference Action Type Flow, Reference Action Send Email with Verification Code); check Require Input to execute action for customerToVerify, Show in conversation for verificationMessage; Save. - Add action
Verify Code(Reference Action Type Flow, Reference Action Verify Code); check Require Input for customerCode, customerId, and customerType; Save.
8. Add Variables for Verified-Customer Context
- Expand Variables and click Variables, then New > Create a Custom Variable:
IsVerifiedCustomer(Boolean, default False, enable API write access), Create.
- Click New again and create:
AuthenticationKey(String, enable API write access), Create, then Save.
9. Map Variables to the Verify Customers Subagent
- Open Verify Customers and expand Send Email with Verification Code.
- Map AuthenticationKey variable to the authenticationKey output; map VerifiedCustomerId variable to the customerId output; Save.
- Expand Verify Code:
- Map AuthenticationKey variable to the authenticationKey input (Agent Populated); map IsVerifiedCustomer variable to the isVerified output; Save.
- Add a new line after the last action and select Get Customer Profile, then Save.
10. Update Verify Customers Instructions
- Open Verify Customers, delete the current instructions, paste the provided step-by-step verification flow, then Save.
11. Update the Order Issues and Refunds Subagent
- Open Order Issues and Refunds and remove the instruction about running Get Customer Profile / Get Related Cases.
- Type / and select If/Else (Conditional).
- Select variable IsVerifiedCustomer, operator ==, value True.
- In the Write instructions area, add
Run the Get Related Cases action. - In Add to Block, select Else, then type / and select Transition, and select Verify Customers.
- Click Save, then Commit Version twice, then Activate twice.
12. Test the End-to-End Journey
- Click Preview and close the AI assistant panel.
- Click the Reset Simulator icon.
- Enter
Hi, I'm Alex Morgan. Can you show me all of my cases? - Confirm the agent transitions to Verify Customers before running sensitive actions.
- Enter
alex.morgan@example.com is my email addresswhen asked. - Open the Send Email with Verification Code action in Interaction Details.
- Copy the six verificationCode numbers from the output.
- Paste the code into the conversation and press Enter.
- Confirm verification, then respond
Yesto show your cases.