---
cuppy_hub: salesforce
cuppy_path: guides/data360/ground-a-revenue-agent.md
cuppy_section: docs
cuppy_doc: W9DJ-BS4E
cuppy_doc_uuid: dfd65225-5e63-4c03-8fe9-2ce7bd337229
cuppy_permalink: https://cuppy.io/salesforce/d/W9DJ-BS4E
cuppy_version: 1
cuppy_updated: 2026-10-23T16:16:52.575Z
cuppy_canonical: https://cuppy.io/salesforce/docs/guides/data360/ground-a-revenue-agent
cuppy_mcp: https://cuppy.io/mcp
cuppy_body_sha256: 2fe177ddbc0f90902fe0d1b5c07965c237c138eaf2403449d6a478d8f23710b7
# cuppy_body_sha256 is over the document body ALONE, excluding both generated blocks.
---


# Ground a revenue agent on golden records

Prerequisites:
- the pipeline has run, and `verify` passes (`guides/data360/automate-the-golden-record-pipeline.md`);
- the account-narrative search index is **Ready**;
- a retriever on it, returning the account name, the narrative and the chunk, is **active** (`reference/data360/search-indexes-and-retrievers.md`).

## 1. Wrap the retriever in a Data Library

```bash
sf agent adl create --source-type retriever --retriever-id <retriever ID> \
  --name "Revenue Golden Records" --developer-name Revenue_Golden_Records --target-org dev --json
sf agent adl get --library-id <libraryId> --target-org dev --json
```

- The library is ready at once. Put `ARFPC_<libraryId>` in the agent's `knowledge:` block.
- Day 2: `sf agent adl update --library-id <libraryId> --retriever-id <new ID>` swaps the retriever without touching the agent.

## 2. Build the two actions to this contract

| Action | Implementation | Inputs → outputs |
|---|---|---|
| `get_account_context` → `flow://Get_Account_Revenue_Context` | An autolaunched flow that reads the golden record's rollup from Data 360. Salesforce's workshop uses a flow with a Data Cloud query for exactly this ("Get Merchant Order Insights") | `accountName` (text) → `revenueSummary` (text), `lifetimeRevenue` (number) |
| `next_best_offer` → `prompt://Next_Best_Offer` | A Flex prompt template with one text input, `Account_Context`, instructed to propose one offer and its reasoning from the context only | `"Input:Account_Context"` → `promptResponse` |

- Build the flow from the account-level revenue insight (`Revenue_Rollup__cio`) joined to the unified account. Return the same narrative text the search index embeds, so a brief and a search result read the same.
- Flows and Apex as actions: family 9. Prompt templates: family 6.
- **Deploy both before publishing.** Publishing doesn't deploy actions (`reference/agentforce/agent-errors.md`).

## 3. Access

| Who | Needs |
|---|---|
| Sellers (the agent is an employee agent and runs as them) | A Data 360 permission set covering the data space, and access to the flow and the prompt template |
| An Einstein Agent User, if you make it a service agent | The same Data 360 access. Salesforce's sf-skills names `DataCloudUser`, `GenieUserEnhancedSecurity` or the `GenieDataPlatformStarterPsl` licence, depending on the org |

Without Data 360 access or data space scope, the knowledge action returns an empty summary and the agent says it found nothing.

**Salesforce's own guidance conflicts on `default_agent_user` here.** The sf-skills org-setup reference says employee agents using `AnswerQuestionsWithKnowledge` with live actions **need** it. Its agent-design reference says setting it on an employee agent fails publish with "unknown error". The example omits it. If live preview of the knowledge action fails on user context, test that variant in a scratch org before you commit to it.

## 4. Publish, activate, test

Use the agent in `examples/revenue-assistant-agent.md`, with your library ID.

```bash
sf agent validate authoring-bundle --api-name Revenue_Assistant --target-org dev
sf agent preview start --authoring-bundle Revenue_Assistant --use-live-actions --target-org dev --json
sf agent publish authoring-bundle --api-name Revenue_Assistant --target-org dev
sf agent activate --api-name Revenue_Assistant --version 1 --target-org dev
sf agent test create --spec specs/Revenue_Assistant-testSpec.yaml --api-name Revenue_Assistant_Tests --target-org dev
sf agent test run --api-name Revenue_Assistant_Tests --wait 20 --result-format json --output-dir test-results --target-org dev
```

```yaml
# agent-test-spec: Revenue_Assistant_Tests
name: "Revenue Assistant Tests"
subjectType: AGENT
subjectName: Revenue_Assistant
testCases:
  - utterance: "Brief me on Acme Corporation"
    expectedTopic: account_brief
    expectedActions: [capture_account, brief]
    expectedOutcome: "A short revenue summary for Acme Corporation using returned figures only"
  - utterance: "Which accounts buy like Acme but haven't ordered in six months?"
    expectedTopic: find_accounts
    expectedActions: [search_accounts]
    expectedOutcome: "A list of matching accounts with citations, or a statement that none were found"
  - utterance: "What's our churn policy for employees?"
    expectedOutcome: "The agent declines and offers account briefs or account search"
```

- **Gate CI on the result file**, because failed assertions exit 0 (`guides/agentforce/test-an-agent.md`).
- Check `generatedData.actionsSequence` on the first run. Whether `capture_account` (a `@utils.setVariables` tool) is listed is the hub's guess.


---
<!-- cuppy -->
You are reading one file. The same content is free over MCP at https://cuppy.io/mcp with no signup: ranked search across all 376 documents in this hub, the merged view when you work in a layer, known workarounds matched to the error you hit, and depth control so you spend tokens on what you need. Start with the `_hello` tool. How to connect: https://cuppy.io/salesforce/ Something wrong in this document? Report it with the `session feedback` tool on the same endpoint.
<!-- /cuppy -->
