Build an Agent Using Agentforce DX - 使用 Agentforce DX 构建代理(练习操作步骤)

《Build an Agent Using Agentforce DX - 使用 Agentforce DX 构建代理》的分步练习操作指南。...

📅 2026/10/2 ✍️ ponybai 🏷️ agentforce, developer

本文是《Build an Agent Using Agentforce DX - 使用 Agentforce DX 构建代理》的练习操作步骤。阅读原文请见:Build an Agent Using Agentforce DX - 使用 Agentforce DX 构建代理。

1. Sign Up for a Developer Edition Org

  1. Sign up for a free [Developer Edition org with Agentforce](https://trailhead.salesforce.com/promo/orgs/agentforce-for-trailhead).
  2. Click Sign me up, open the activation email, and click Verify Account.
  3. Connect the org to Trailhead: click the hands-on org, Connect Org, sign in, Allow, then Yes! Save it.

2. Activate Agentforce in Your Org

  1. Log in and click the Setup gear icon, then Setup.
  2. Enter Einstein Setup in Quick Find, select Einstein Setup, and ensure the Turn on Einstein toggle is On.
  3. Enter Einstein Bots in Quick Find, select Einstein Bots, and toggle to On.
  4. Enter Salesforce Go in Quick Find, select Salesforce Go.
  5. In Search features, enter Agentforce and select Agentforce (Default).
  6. Click Get Started, Turn On, then Confirm.

3. Set Up Your Development Environment

  1. Install [VS Code](https://code.visualstudio.com/).
  2. Install the [Salesforce Extension Pack](https://marketplace.visualstudio.com/items?itemName=salesforce.salesforcedx-vscode) (includes Agentforce DX and Agentforce Vibes).
  3. Install [Salesforce CLI](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_install_cli.htm).
  4. Install [Node.js](https://nodejs.org/en/download) globally.

4. Clone the Sample Repo

  1. In VS Code, open View | Command Palette and choose Git: Clone.
  2. Enter https://github.com/forcedotcom/afdx-pro-code-testdrive.
  3. Select a destination directory, then click Open.

5. Authorize Your Developer Edition Org

  1. In VS Code, open View | Command Palette and choose SFDX: Authorize an Org.
  2. Click Production.
  3. Enter agentforce for the org alias.
  4. Sign in with your Developer Edition credentials, click Allow, and confirm Authentication Successful.

6. Run the Setup Script

  1. From the VS Code integrated terminal, run the setup script: ./setup (macOS/Linux) or setup.cmd (Windows).
  2. Save the unique username the script creates (needed in the next unit).

7. Preview the Agent (Simulation)

  1. In VS Code, right-click the Local_Info_Agent.agent file and select AFDX: Preview This Agent.
  2. From the Select agent… dropdown, select Local_Info_Agent.
  3. Select Simulation, then click Start Simulation.
  4. In the chat box, enter What can you help me with?, then What's the weather like? (note the pirate persona).

8. Code the Agent Script File

  1. Find the line that starts Finally, ALWAYS give answers (around line 114) and remove it.
  2. Save the file.
  3. Right-click the Agent Script file and choose AFDX: Validate this Agent.
  4. Click Restart Options, then Compile & Restart.
  5. Enter What's the weather like? again and confirm a professional reply.
  6. Click Stop Simulation.

9. Preview in Live Mode

  1. In Local_Info_Agent.agent, locate the default_agent_user property and set it to the generated username (e.g., afdx-agent@testdrive.org98eca4a312-3456xyz).
  2. Validate the agent.
  3. Right-click and select AFDX: Preview This Agent, select Live Test, then Start Live Test.
  4. Ask What's the weather like? and confirm the temperature is between 65.3F and 81.1F.

10. Change the Agent in Agentforce Builder

  1. Deploy the updated bundle: sf project deploy start --metadata aiAuthoringBundle:Local_Info_Agent.
  2. Open in Builder: sf org open agent --authoring-bundle Local_Info_Agent.
  3. In Script view, add the clown instruction after the sentence ALWAYS Provide forecasts that include a temperature range.
  4. Click Save, then optionally Preview.
  5. Retrieve the updated bundle: sf project retrieve start --metadata AiAuthoringBundle:Local_Info_Agent.

11. Publish the Authoring Bundle

  1. Right-click Local_Info_Agent.agent and choose AFDX: Publish This Agent.
  2. Check the Output tab (filter for Agentforce DX) for the publishing steps.
  3. Refresh Agentforce Builder in your org and confirm Version 1 (Committed).

12. Activate Your Agent

  1. In VS Code Explorer, navigate to force-app/main/default/bots/Local_Info_Agent.
  2. Right-click Local_Info_Agent.bot-meta.xml and choose AFDX: Activate Agent.
  3. Select Version 1 in the dropdown.
  4. Refresh Agentforce Builder and confirm Version 1 (Active).