Headless Example: Ground an Agent with Agentforce Data Libraries

In this headless example, you develop an agent, ground it with Agentforce data libraries, test, and activate it.

Use your preferred AI assistant, such as Claude Code or Agentforce Vibes.

Step 1: Complete the Prerequisites 

Complete all the prerequisites in Headless Examples.

In your terminal, run sf org list. If you see the headless org alias in the list, you’re successfully authenticated.

This example also requires:

  • Data 360
  • Salesforce Knowledge if you want to add an Agentforce data library using knowledge articles

Step 2: Build an Agent 

Copy and paste this prompt into your AI assistant:

1Create a Q&A agent called "QnA".

Your AI assistant creates the agent. We’re not ready to publish and activate it yet.

Step 3: Download Sample Files for an Agentforce Data Library 

Agentforce Data Libraries (ADL) enhance the accuracy of AI features, such as Agentforce agents, by connecting them to your trusted data sources. Data libraries use unstructured or semi-structured data. They convert large sets of information from the web, documents, or text fields into useful, searchable information.

Download these files to your filesystem so that you can use them to ground the agent.

  1. order-tracking.txt
  2. product-troubleshooting.txt
  3. technical-support.txt

Step 4: Create Agentforce Data Libraries 

Create two Agentforce data libraries: one file-based data libary and a second data library based on Salesforce Knowledge articles.

Copy and paste this prompt into your AI assistant:

1Create an Agentforce data library. Add the order-tracking.txt, product-troubleshooting.txt, and technical-support.txt files to the data library. Create a second data library and link Salesforce Knowledge articles from the Product category to the data library.

Your AI assistant creates the two data libraries. A data library can’t support multiple data sources so we need two data libraries, one for the files and one for the knowledge articles.

Step 5: Ground the Agent with the Data Libraries 

Wire the two new Agentforce data libraries into the QnA agent.

Copy and paste this prompt into your AI assistant:

1Ground the QnA agent with the two new Agentforce data libraries.

Your AI assistant connects the data libraries to the agent to improve the accuracy of agent responses.

Step 6: Test the Agent 

Copy and paste this prompt into your AI assistant:

1Test the agent with realistic customer scenarios and interactions.

Your AI assistant generates a test plan and executes the tests. If any tests fail, review the root causes returned by your AI assistant and ask it to apply the recommended fixes.

These tests aren’t saved to a regression test suite. That step is outside the scope of this example. To build a test suite, see Testing API Developer Guide or the Agentforce Testing Center in Salesforce Help.

Note

Step 7: Activate the Agent 

Copy and paste this prompt into your AI assistant:

1Commit and activate the agent in the org.

Your AI assistant publishes and activates the agent.

See Also