Skip to main content

Get Started with Agentforce DX

Learning Objectives

In this project, you’ll:

  • Learn how Agentforce DX helps you develop agents.
  • Generate an agent spec using a Salesforce CLI command.
  • Create an agent from the agent spec.
  • View the metadata components associated with the agent.
  • Open the agent in the Developer Edition org’s Agentforce Builder UI.

Coral Cloud Resorts + Agentforce DX

After Coral Cloud Resorts added an Agentforce service agent to assist clients with bookings, business is booming. (See this Trailhead project for details about how to create the agent.) You’re a Coral Cloud developer, and based on your excellent experience with the service agent, you now want to add a resort manager agent that can take customer complaints, fix employee schedules, and more.

But this time, rather than start development in your org’s Agentforce Builder UI, you want to start using modern development tools right away. These tools include storing the agent’s source code in a version control system like GitHub and incorporating the agent development into continuous integration (CI) jobs. Agentforce DX to the rescue!

What Is Agentforce DX?

You’re probably already familiar with Salesforce Developer Experience (DX): a set of tools to build, test, and ship applications on the Salesforce Platform. These tools include Salesforce CLI, Visual Studio Code (VS Code) extensions, Code Builder, DevOps Center, and more. Agentforce DX extends these tools to also work with agents.

You may have created and previewed an agent in an org using the Agentforce Builder UI, which is a low-code development tool. With these in-org builders, you can create agents with clicks, not code. But incorporating agent development and testing into a modern DevOps process requires storing the agent’s source code in a version control system (VCS). So it becomes part of the source of truth for your production org. Agentforce DX makes this possible.

Agents are made of metadata, just like any other Salesforce customization. Agentforce DX provides pro-code tools to create, preview, and test agents outside the Agentforce Builder UI. And it helps you move agent metadata between your DX project and the scratch orgs, sandboxes, and production orgs you work with. With these abilities, you can incorporate agents into your modern software development process.

This Trailhead project starts your journey by walking you through the agent creation features of Agentforce DX.

Sign Up for a Developer Edition Org with Agentforce

To complete this project, you need a special Developer Edition org that contains Agentforce and our sample data. Get the free Developer Edition and connect it to Trailhead now so you can complete the challenges in this project. Note that this Developer Edition is designed to work with the challenges in this badge, and may not work for other badges. Always check that you’re using the Trailhead Playground or special Developer Edition org that we recommend.

  1. Sign up for a free Developer Edition org with Agentforce.
  2. Fill out the form.
    • For Email, enter an active email address.
    • For Username, enter a username that looks like an email address and is unique, but it doesn't need to be a valid email account (for example, yourname@test.com).
  3. After you fill out the form, click Sign me up. A confirmation message appears.
  4. When you receive the activation email (this might take a few minutes), open it and click Verify Account.
  5. Complete your registration by setting your password and challenge question.
    • Tip: Save your username, password, and login URL in a secure place—such as a password manager—for easy access later. You’ll need this information later when you authorize Salesforce CLI to use your Developer Edition org.
  6. You are logged in to your Developer Edition.

Now connect your new Developer Edition org to Trailhead.

  1. Make sure you're logged in to your Trailhead account.
  2. In the Verify Step section at the bottom of this page, click the hands-on org that’s showing, and then click Connect Org.
  3. On the login screen, enter the username and password for the Developer Edition you just set up.
  4. On the Allow Access? screen, click Allow.
  5. On the Want to connect this org for hands-on challenges? screen, click Yes! Save it. You are redirected back to the challenge page and ready to use your new Developer Edition to earn this badge.

Enable Einstein and Agentforce in Your Developer Edition Org

To develop agents using Agentforce DX, you must enable Einstein and Agentforce in your Developer Edition org.

  1. Log in to your Developer Edition org and click the Setup gear icon in the top-right corner.
  2. Click Setup in the drop-down menu.
  3. Enter Einstein Setup in the Quick Find box, then click Einstein Setup.
  4. Click the Einstein toggle, and make sure Einstein is On.

Einstein Setup page in Setup showing Einstein enabled.

  1. Enter Agent in the Quick Find box, then click Agentforce Agents.
  2. Click Agentforce, and make sure Agentforce is On.
  3. Click Enable the Agentforce (Default) Agent and make sure it’s on.

Agentforce Studio page in Setup showing Agentforce and the default Agentforce agent enabled.

Set Up Your Development Environment

This project shows how to use Visual Studio Code (or VS Code) and CLI commands to create an agent. VS Code is an integrated development environment (IDE) and consists of a code editor, build automation tools, a debugger, and intelligent code completion.

Set up VS Code by installing it locally on your computer as described in these installation instructions. If you’re already a Salesforce developer who uses our pro-code tools, you’ve probably already installed VS Code (with the Salesforce Extensions) on your computer. If you want to use the same setup for this project, then your environment is ready for this project. See Quick Start: Visual Studio Code for Salesforce Development for details.

Note

Confirm the CLI is properly installed and on the latest version by running the following command from the command line: sf update

You should see output like: @salesforce/cli: Updating CLI….

When using VS Code, you run commands from either the Command Palette, or by executing Salesforce CLI commands from the integrated terminal.

Create a Salesforce DX Project

A Salesforce DX project provides a project structure for your org’s metadata (code and configuration), sample data, and all your team’s tests. Development teams store these items in a version control system, such as GitHub. Agents are just like any other Salesforce org item in that they’re made up of metadata, so you still use DX projects to store and work with them.

  1. Open VS Code and click View | Command Palette and choose SFDX: Create Project.
  2. Click Standard (Standard project template default).
  3. Enter agentforcedx for the project name.
  4. Navigate to the location on your computer where you want to create the project, then click Create Project.

The standard Salesforce DX project folders appear in VS Code.

Visual Studio Code showing a Salesforce DX project called “agentforcedx” open in the explorer panel.

Authorize Your Developer Edition Org

Let’s now use your Developer Edition org username and password to locally authorize the org so VS Code and the CLI commands can work with it.

  1. In VS Code, click View | Command Palette and choose SFDX: Authorize an Org.
  2. Click Project Default.
  3. Enter agentforce for the org alias.
  4. In the browser window that opens, sign in to your Developer Edition org with your login credentials.
  5. Click Allow, which allows Salesforce CLI to access your org. You should see a message that says Authentication Successful.
  6. Close the browser window.
    Your Developer Edition org is now authorized and set as your default org.

View the Agent Commands

Let’s explore the agent commands before we start using some of them.

  1. From the VS Code integrated terminal, run the sf search CLI command to view all the available agent commands. A summary of the command appears at the bottom as you scroll through the list with the arrow key

Visual Studio Code showing the integrated terminal running the “sf search” Salesforce CLI command.

This project focuses on only the agent generate agent-spec and agent create commands.

  1. Use the --helpflag to view detailed information about a particular command, such as its flags and examples of how to use it. Use -h for concise information.

VS Code’s integrated terminal showing the output of the “sf agent generate agent-spec -h” CLI command.

Now that you’ve learned about Agentforce DX and have set up your development environment, let’s get to the fun stuff: Create an agent.

Resources

Salesforce ヘルプで Trailhead のフィードバックを共有してください。

Trailhead についての感想をお聞かせください。[Salesforce ヘルプ] サイトから新しいフィードバックフォームにいつでもアクセスできるようになりました。

詳細はこちら フィードバックの共有に進む