# Multi-Surface Example: Ground an Agent with an Agentforce Data Library

In this example, you develop an agent, ground it with an Agentforce data library, test, and activate it. This multi-surface example shows you how to complete the steps using Headless or the Salesforce UI by choosing the tab for your preferred method.

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

:::::tabset{tabs="[&#x22;Headless&#x22;, &#x22;Salesforce UI&#x22;]"}
::::tab
### Step 1: Complete the Prerequisites

Complete all the prerequisites in [Headless Examples](/docs/ai/agentforce/guide/headless-examples.md).

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

### Step 2: Build an Agent

Copy and paste this prompt into your AI assistant:

```
Create 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. The files contain information about a fictitious DiamondVision TV from Acme Corp.

1. [`order-tracking.txt`](https://resources.docs.salesforce.com/rel1/doc/en-us/static/misc/order-tracking.txt)
2. [`product-troubleshooting.txt`](https://resources.docs.salesforce.com/rel1/doc/en-us/static/misc/product-troubleshooting.txt)
3. [`technical-support.txt`](https://resources.docs.salesforce.com/rel1/doc/en-us/static/misc/technical-support.txt)

### Step 4: Create an Agentforce Data Library

Create a file-based data libary Agentforce data library.

Copy and paste this prompt into your AI assistant:

```
Create an Agentforce data library. Add the order-tracking.txt, product-troubleshooting.txt, and technical-support.txt files to the data library.
```

Your AI assistant creates the data library with the three sample files.

### Step 5: Ground the Agent with the Data Library

Wire the new Agentforce data library into the QnA agent.

Copy and paste this prompt into your AI assistant:

```
Ground the QnA agent with the new Agentforce data library.
```

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

### Step 6: Test the Agent

Copy and paste this prompt into your AI assistant:

```
Test 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.

:::note
These tests aren't saved to a regression test suite. For an example that creates test cases headlessly, see [Optimize an Agent by Analyzing Production Data](/docs/ai/agentforce/guide/headless-examples-agent-optimize.md). Also, see [Testing API Developer Guide](/docs/ai/agentforce/guide/testing-api.md) or the [Agentforce Testing Center](https://help.salesforce.com/s/articleView?id=ai.agent_testing_center.htm) in *Salesforce Help*.
:::

### Step 7: Activate the Agent

Copy and paste this prompt into your AI assistant:

```
Commit and activate the agent in the org.
```

Your AI assistant publishes and activates the agent.
::::

:::tab
### Step 1: Complete the Prerequisites

Complete steps 1 and 2 in [Headless Examples](/docs/ai/agentforce/guide/headless-examples.md).

This example also requires:

- Data 360

### Step 2: Build an Agent

Complete these steps by opening Salesforce org in your browser.

1. From the App Launcher, enter `Agent`, and then select **Agentforce Studio**.
2. On the Agents tab, click **New Agent**.
3. Select an Agentforce Service agent template. Under Agent Details, select or create an **Agent's User Record** for this agent. See [Configure Service Agent Access](https://help.salesforce.com/s/articleView?id=ai.agent_user.htm\&type=5) for details.
4. Enter `QnA` as the agent's name and then click **Let's Go**.

### 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. The files contain information about a fictitious DiamondVision TV from Acme Corp.

1. [`order-tracking.txt`](https://resources.docs.salesforce.com/rel1/doc/en-us/static/misc/order-tracking.txt)
2. [`product-troubleshooting.txt`](https://resources.docs.salesforce.com/rel1/doc/en-us/static/misc/product-troubleshooting.txt)
3. [`technical-support.txt`](https://resources.docs.salesforce.com/rel1/doc/en-us/static/misc/technical-support.txt)

### Step 4: Create an Agentforce Data Library

Create a file-based Agentforce data library.

1. From Setup, in the Quick Find box, enter `data library`, and then select **Agentforce Data Library**.
2. Click **Add Data**, then **Upload Files**.
3. Name the library `File Data Library`, and the API name is automatically populated. Optionally, enter a description.
4. Click **Upload Files** and add the three files downloaded in the previous step.
5. Click **Save** and wait for the Status of each file to say **Uploaded**.

### Step 5: Ground the Agent with the Data Library

Wire the new Agentforce data library into the QnA agent.

1. Return to Agentforce Studio and open the QnA agent.
2. In the Explorer tab, scroll down to **Data** and select **Data Library**.
3. Select **File Data Library** from the dropdown.
4. Save your agent.

### Step 6: Test the Agent

1. Click **Preview**.
2. Select your [test mode](https://help.salesforce.com/s/articleView?id=ai.agent_simulate_and_live_modes.htm\&language=en_US\&type=5).
3. To start a preview conversation, in the chat window, enter a typical user question or request. See the example interaction below.
4. To review the agent’s behavior and reasoning, start with the Interaction Summary in the Summary tab. The Interaction Summary shows you a high-level overview of the steps your agent took to generate a response, including the result of each. Hover over each step for more details.
5. To get AI assistance, click **Ask Agentforce** in the Interaction Summary panel. We send the integrated Agentforce assistant information about the preview session so you can ask it questions.
6. If the test reveals errors or gaps, ask the assistant to make updates, or make changes yourself in the Canvas view. If your agent version is committed, make a new version first and modify it.
7. To test changes, refresh the session by clicking the reset icon on the Preview panel. Continue testing, modifying, and retesting until you're satisfied with the agent’s behavior.

#### Example Test Interaction

| User Input                                                                       | Agent Response                                                                                                                                                                                                                                                                                                                                          |
| -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| The DiamondVision Voice Remote isn't responding to voice commands. What's wrong? | Make sure the remote is paired (hold Home + Back for 5 seconds until the blue LED flashes). Voice commands require an active internet connection, so verify the TV is online. Check that the microphone permission is enabled under Settings > Voice Assistant > Permissions, and replace the AAA batteries if the remote's LED is dim or unresponsive. |
| Where can I find the serial number and model number on my Acme Corp product?     | The serial number and model number are typically printed on a label affixed to the back or bottom of the product. You can also find this information in your original packaging, on your purchase receipt, or within the Acme Corp companion app under Device Details if the product is registered.                                                     |

### Step 7: Activate the Agent

1. Click **Commit Version**, then click **Commit** again.
2. Click **Activate**, then click **Activate** again.
:::
:::::

### See Also

- **Salesforce Help**: [Agentforce Data Library](https://help.salesforce.com/s/articleView?id=ai.data_library_parent.htm)
