部署 Agent 认证 — 客户验证 + 条件逻辑 + 双因素认证(练习操作步骤)

《部署 Agent 认证 — 客户验证 + 条件逻辑 + 双因素认证》的分步练习操作指南。...

📅 2026/10/2 ✍️ ponybai 🏷️ agentforce, salesforce, security

本文是《部署 Agent 认证 — 客户验证 + 条件逻辑 + 双因素认证》的练习操作步骤。阅读原文请见:部署 Agent 认证 — 客户验证 + 条件逻辑 + 双因素认证。

1. Import the Agent

  1. Open the App Launcher and select Agentforce Studio.
  2. Click the down arrow next to New Agent and select New from Script.
  3. Paste the provided Agent Script, then click Create Agent.
  4. If needed, click Pronto Service Agent to open it, then click Save.
  5. In the Assign a user record section, select Select User, choose EinsteinServiceAgent User, then Save.

2. Create the Issues and Refunds Subagent

  1. Click the + sign next to Subagents, then + New Subagent.
  2. Name: Order Issues and Refunds; add the provided "job" description; click Create and Open.
  3. Paste the provided Instructions text, then Save.

3. Create Actions for the Subagent

  1. 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.
  2. 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.

4. Update the Get Related Cases Agent Script

  1. In the Get Related Cases action, switch from Canvas to Script view.
  2. Find cases: object and change to cases: list[object].
  3. Find complex_data_type_name: "lightning__listType" and replace lightning__listType with @apexClassType/c__AgentCaseActions$CaseSummary.
  4. Click Save.

5. Add Instructions and Test

  1. 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.
  2. Click Preview and enter Can you show me all of my cases?, press Enter.
  3. When asked, enter my email is alex.morgan@example.com.
  4. Confirm the agent runs Get Customer Profile then Get Related Cases and shows case results.

6. Create the Verify Customers Subagent

  1. Click the + next to Subagents, then + New Subagent.
  2. Name: Verify Customers; Description: This subagent verifies the identity of the customer before allowing access to sensitive support actions.; Create and Open.
  3. Paste Verify the identity of the customer. into Instructions, then Save.

7. Create Actions for Verify Customers

  1. 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.
  2. 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

  1. Expand Variables and click Variables, then New > Create a Custom Variable:
    • IsVerifiedCustomer (Boolean, default False, enable API write access), Create.
  2. Click New again and create:
    • AuthenticationKey (String, enable API write access), Create, then Save.

9. Map Variables to the Verify Customers Subagent

  1. 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.
  2. Expand Verify Code:
    • Map AuthenticationKey variable to the authenticationKey input (Agent Populated); map IsVerifiedCustomer variable to the isVerified output; Save.
  3. Add a new line after the last action and select Get Customer Profile, then Save.

10. Update Verify Customers Instructions

  1. 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

  1. Open Order Issues and Refunds and remove the instruction about running Get Customer Profile / Get Related Cases.
  2. Type / and select If/Else (Conditional).
  3. Select variable IsVerifiedCustomer, operator ==, value True.
  4. In the Write instructions area, add Run the Get Related Cases action.
  5. In Add to Block, select Else, then type / and select Transition, and select Verify Customers.
  6. Click Save, then Commit Version twice, then Activate twice.

12. Test the End-to-End Journey

  1. Click Preview and close the AI assistant panel.
  2. Click the Reset Simulator icon.
  3. Enter Hi, I'm Alex Morgan. Can you show me all of my cases?
  4. Confirm the agent transitions to Verify Customers before running sensitive actions.
  5. Enter alex.morgan@example.com is my email address when asked.
  6. Open the Send Email with Verification Code action in Interaction Details.
  7. Copy the six verificationCode numbers from the output.
  8. Paste the code into the conversation and press Enter.
  9. Confirm verification, then respond Yes to show your cases.