Build Agents with Agentforce DX

You’re likely 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, VS Code extensions, Code Builder, DevOps Center, and more. The tools also include dev environments such as scratch orgs and sandboxes. Agentforce DX extends these tools to also work with agents.

You’ve probably created and previewed an agent in an org using the Agent Builder UI, which is a low-code development tool. These in-org builders let you 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 source control repository (also version control system, or VCS). It then 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 and test agents outside the Agent Builder UI. It helps you move agent metadata between your Salesforce DX project and the scratch orgs, sandboxes, and production orgs you work with. These abilities let you incorporate agents into your modern software development process.

When you build an agent, you can switch between low-code tools, such as the Agent Builder or Flow Builder UIs in your org, and pro-code tools, such as VS Code and Salesforce CLI on your local computer. Using both types of tools gives you flexibility, and is all part of the iterative process of building an agent. The main thing is to always keep your Salesforce DX project in sync with your org.

Here’s a high-level example of how you can go back and forth between the two types of tools as you iteratively build your agent. These steps are generic and simple; they’re simply meant to show that you have lots of options when developing agents.

  • Create a simple and basic agent by running CLI commands in VS Code’s integrated terminal. The metadata is automatically synced between your DX project and your org.
  • Open the agent in your org’s Agent Builder UI and modify a topic by adding an action from the asset library.
  • Retrieve the agent metadata that was generated when you added an action back to your DX project. Everything is in sync!
  • Periodically check the new and updated metadata into your source control repository (also version control system, or VCS), such as GitHub. Remember: Your VCS is the source of truth, so be sure you keep it updated.
  • Use VS Code (with the Agentforce for Developers dev assistants) to create an Apex class that implements a new custom action for one of your topics. The Apex code is in your local Salesforce DX project.
  • Deploy the local updates you made while coding the new Apex class back up to your org.
  • Use low-code tools in the org, such as Agent Studio, to convert the Apex class into an agent action.
  • Use Agent Builder to add the new action to a topic.
  • Retrieve all the new metadata back to your DX project, and check the updated files into your VCS.
  • Use Flow Builder in your org to create an autolaunched flow, and then Agent Builder to add an action to your agent that uses the flow.
  • Retrieve the new metadata back to your DX project, and check updated files into your VCS

And so on. I think you get the idea. When you’re ready to test your agent and incorporate it into your continuous integration (CI) system, you similarly have low-code and pro-code options.

This guide shows you how to set up a Salesforce DX project and how to use Salesforce CLI and VS Code to create agents, test agents, and more. While this guide doesn’t go into the details of coding an Apex class or creating a flow, we point you in the right direction when necessary.

Give us your feedback about Agentforce DX and report problems by entering an issue in our GitHub repository. Check out the discussion page to read about new features we're considering, add your comments, and propose your own.

We release new versions of Salesforce CLI and its core plugins weekly. Read the weekly release notes to learn about recent and upcoming changes.