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 for creating and testing 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 you can use when you want to 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 directly run Salesforce CLI commands. Other commands you run directly from the IDE’s Command Palette.
You install Salesforce CLI and VS Code locally on your computer. Code Builder is pre-installed with the Salesforce extension pack and Salesforce CLI. To set up Code Builder, see Set Up Code Builder.
-
Install the Salesforce Extension Pack into VS Code from the VS Code Marketplace.
If you prefer to use open-source projects, you can alternatively install the Salesforce Extension Pack from the Open VSX Registry, an alternative to the VS Code Marketplace.
-
Install the Agentforce DX VS Code extension from either the VS Code Marketplace or the Open VSX Registry. If you're using Code Builder, you must install the extension from the Open VSX Registry.
-
Open VS Code.
-
From VS Code's integrated terminal, run the
sf search
CLI command to view the availableagent
commands.A summary of the command appears at the bottom as you use the arrow keys to scroll through the list.
You can also run Salesforce CLI commands from a separate terminal (macOS, Linux) or command prompt (Windows) if you prefer.
-
To view detailed information about a particular command, such as its flags and examples of how to use it, use the
-–help
flag. Use-h
for concise information.The
agent
CLI plugin is "just in time" (JIT), which means that Salesforce CLI automatically installs it the first time you run one of its commands. The command help is always available. To see the list of installed and uninstalled JIT plugins, run thesf plugins
CLI command.
If you’re new to pro-code development using VS Code, check out the Trailhead badge Quick Start: Visual Studio Code for Salesforce Development.
You can use either a sandbox or scratch org for Agentforce development, but it’s important to understand the capabilities and limitations of each.
You can use both sandboxes and scratch orgs 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 that was in your org at the time they were created. Developers often use Developer and Developer Pro sandboxes, 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 contain data from your production org in addition to the metadata, although this ability restricts how often Partial and Full Copy sandboxes can be refreshed.
Scratch orgs are empty environments that don’t have any metadata or data from your Salesforce production org, so you can create them quickly. Scratch orgs are ideal for source-driven development where you externalize all the metadata from your production org, then deploy the metadata 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:
- No Data Libraries Required: Use scratch orgs configured for Agentforce development.
- Data Libraries Required: Use a sandbox org capable of connecting to 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.
To create a sandbox, use one of these two methods:
- Salesforce CLI: Run the
org create sandbox
command. See Sandboxes in the Salesforce DX Developer Guide. - Setup UI in your org. See Create, Clone, or Refresh a Sandbox in Salesforce Help.
To create a scratch org, run the org create scratch
CLI command. For details on enabling Agentforce in the scratch org, See Scratch Org Access in the Agentforce Developer Guide.
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.
-
Log in to your sandbox.
-
If your agents don’t require Data Cloud, skip to the next step. If your agents require Data Cloud, turn on Data Cloud.
-
From Setup, find and select Data Cloud Setup Home.
-
Follow the directions in Turn On Data Cloud.
Data Cloud setup can take up to 60 minutes to complete; the Setup page lets you know when it's finished.
Don’t continue to the next step until Data Cloud setup has fully completed.
-
-
From Setup, find and select Einstein Setup.
-
Make sure that Einstein is enabled. If not, select Turn on Einstein.
-
Reload the Setup UI.
If you just enabled Einstein for the first time, reloading Setup is required so that Agent setup becomes available.
-
-
From Setup, find and select Agentforce Agents
- Select Agentforce.
- Select Enable the Agentforce (Default) Agent.
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 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.
- Open VS Code, click View | Command Palette, and then select SFDX: Create Project.
- Select Standard (Standard project template default).
- Enter a name for your project, such as
agentforcedx
. - Go to where you want to create the project, then click Create Project.
If you want to use Salesforce CLI commands directly in integrated terminal, or from a separate terminal (macOS, Linux) or command prompt (Windows), here are the equivalent commands for setting up a Salesforce DX project:
cd <directory-to-contain-dx-projects>
sf project generate --name agentforcedx
cd agentforcedx
Authorize your sandbox org so you can work in it with VS Code and the CLI commands.
- In VS Code, click View | Command Palette and then select SFDX: Authorize an Org.
- Click Project Default.
- Enter an alias for your sandbox org, such as
agentforce
. - 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.
- 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.
- Trailhead: Quick Start: VS Code Development for Salesforce Development
- Salesforce CLI Setup Guide: Install Salesforce CLI
- Salesforce Extensions for Visual Studio Code
- Salesforce DX Developer Guide: Project Setup
- Salesforce DX Developer Guide: Authorization
- Salesforce CLI Command Reference: agent Commands
- Salesforce Help: Agentforce Agents