Set Up Your Development Environment for Agentforce DX

Setting up your Agentforce DX environment is similar to setting up your Salesforce DX environment, but with a few agent-specific extras. If you're already a Salesforce pro-code developer, you've probably completed most of these tasks or are familiar with them.

The pro-code tools to create and test agents are Visual Studio Code (VS Code), Code Builder, and Salesforce CLI. VS Code is an integrated and extensible development environment (IDE) and consists of a code editor, build automation tools, a debugger, and intelligent code completion. Code Builder is a web-based version of VS Code that lets you run VS Code inside a web browser.

Salesforce provides an extension pack for VS Code and Code Builder that includes tools for developing on the Salesforce Platform. VS Code and Code Builder have an integrated terminal from which you run Salesforce CLI commands directly. Other commands you run directly from the IDE’s Command Palette.

You install Salesforce CLI and VS Code locally on your computer. To set up Code Builder, see Set Up Code Builder; Code Builder is pre-installed with the Salesforce extension pack and Salesforce CLI.

  1. Download and install VS Code.

  2. Install the Salesforce Extension Pack into VS Code from either the VS Code Marketplace or the Open VSX Registry.

  3. Install the Agentforce DX VS Code extension from either the VS Code Marketplace or the Open VSX Registry. If you're using Code Builder, install the extension from the Open VSX Registry.

  4. Install Salesforce CLI.

  5. From the VS Code integrated terminal, run this command to install the Salesforce CLI plugin that contains the agent commands:

    You can also run CLI commands from a separate terminal (macOS, Linux) or command prompt (Windows) if you prefer.

  6. Run this command to see the list of user-installed plugins:

    If the Agentforce DX plug-in is installed correctly, you see agent 1.19.0 listed in the output; your plugin version might be more recent.

  7. Use the 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 keys:

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

Check out the Quick Start: Visual Studio Code for Salesforce Development Trailhead badge if you’re new to pro-code development using VS Code and you want more information.

You can use either a sandbox or scratch org for Agentforce development, but it’s important to understand the capabilities and limitations of each.

Both sandboxes and scratch orgs allow you to develop and test agents, code, and other configuration changes without compromising the data and applications in your production org.

Sandboxes are copies of your Salesforce production org. They contain all the metadata in your org at the time they were created. Developer and Developer Pro sandboxes are commonly used by developers because they can be refreshed often, which brings in new changes from your production org. Partial and Full Copy sandboxes are useful for integration and user testing because they also contain the data from your production org, although this ability restricts how often they can be refreshed.

Scratch orgs are empty environments that don’t have any of the metadata or data from your Salesforce production org and so you can create them quickly. Scratch orgs are ideal for source-driven development where you externalize all of the metadata from your production org, then deploy it to the scratch org when you want to work on a specific part of your application.

To select the appropriate developer environment, consider whether your agents require access to Agentforce Data Libraries and Data Cloud:

Combining Data Cloud and Agentforce is the best way to create successful agents. For that reason, we recommend that you work in a sandbox when using Agentforce DX. Developer and Developer Pro sandboxes are ideal choices. See Choose the Right Salesforce Org for the Right Job for a deeper dive into the available choices.

Create a sandbox using one of these two methods:

Create a scratch org using the org create scratch CLI command. See Scratch Org Access in the Agentforce Developer Guide for details on enabling Agentforce in the scratch org.

Although sandboxes are a copy of your production org, some additional manual configuration is required after the sandbox is created to enable Agentforce in it.

One of these steps applies only if your agents require Agentforce Data Libraries and Data Cloud. If your agents don’t require Data Cloud, skip to the next step.

  1. Log in to your sandbox.

  2. (Only if agents require Data Cloud) Enable Data Cloud.

    1. From Setup, find and select Data Cloud Setup.
    2. Follow the directions in Turn On Data Cloud. Data Cloud setup can take up to 60 minutes to complete.

      Don’t continue to the next step until Data Cloud setup has fully completed.

  3. From Setup, find and select Einstein Setup.

    1. Ensure Einstein is enabled. If not, click the Einstein toggle to On.
    2. Reload the Setup UI. If you just enabled Einstein for the first time, reloading Setup is required for the Agent setup tree to become available. Einstein Setup page in Setup showing Einstein enabled.
  4. From Setup, find and select Agents

    1. Click the Agentforce toggle, and make sure Agentforce is On. Agent Studio page in Setup showing Agentforce enabled.

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 customization 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 a name for your project, such as agentforcedx.
  4. Navigate to the location on your computer where you want to create the project, then click Create Project.

Do you want to use Salesforce CLI commands directly in VS Code’s integrated terminal, or from a separate terminal (macOS, Linux) or command prompt (Windows)? Here are the equivalent commands:

Authorize your sandbox 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 an alias for your sandbox org, such as agentforce.
  4. In the browser window that opens, sign in to your sandbox with your login credentials. Click Allow, which allows Salesforce CLI to access your sandbox.
  5. Close the browser window. Your sandbox is now authorized and set as your default org.

Here’s the equivalent Salesforce CLI command that you can use in VS Code’s integrated terminal. Or run it in a separate terminal (macOS, Linux) or command prompt (Windows) from within your DX project.