Build Agents with Agentforce DX

Agentforce is a proactive, conversational AI solution, made up of autonomous agents, that sits on the Salesforce Platform. An autonomous agent is an advanced type of AI that can understand and respond to inquiries, then take action, with or without human intervention. When an agent is given an objective, it can generate tasks for itself, anticipate next steps, change course based on user input, and initiate new tasks within the use cases and guardrails you set up. You might think of your Agentforce as trusted digital teammates.

To learn more about Agentforce, check out these Trailhead modules:

So what is 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, and DevOps Center. 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 Agentforce Builder, which is a low-code development tool that's part of Agentforce Studio. You might even have tested your agent using your org's Testing Center. You can use these in-org builders to create and test 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). The source control repository 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 Agentforce Builder. It helps you move agent metadata between your Salesforce 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.

Agentforce DX extends our Salesforce DX tooling and can be used at the command-line or with a VS Code extension. To test agents using the Salesforce UI, see the Agentforce Testing Center. To test agents using an API, see the Testing API.

When you build an agent, you can switch between low-code tools, such as the Agentforce 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.

  1. 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.
  2. Open the agent in your org’s Agentforce Builder UI and modify a topic by adding an action from the asset library.
  3. Retrieve the agent metadata that was generated when you added an action back to your DX project. Everything is in sync!
  4. Periodically check the new and updated metadata into your VCS, such as GitHub. Remember: Your VCS is the source of truth, so be sure that you keep it updated.
  5. 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.
  6. Deploy the local updates you made while coding the new Apex class back up to your org.
  7. Use low-code tools in the org, such as Agentforce Studio, to convert the Apex class into an agent action.
  8. Use Agentforce Builder to add the new action to a topic.
  9. Retrieve all the new metadata back to your DX project, and check the updated files into your VCS.
  10. Use Flow Builder in your org to create an autolaunched flow, and then use Agentforce Builder to add an action to your agent that uses the flow.
  11. Retrieve the new metadata back to your DX project, and check updated files into your VCS.

After you’re ready to test your agent and incorporate it into your continuous integration (CI) system, you again 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 and test agents. 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.