Golden-record RAG pipeline for revenue — accounts, people and orders from CRM into Data 360, unified into golden records, rolled up into revenue insights, served as real-time context (data graph) and semantic context (narrative search index and retriever), and used by a revenue agent; fully automated and verified stage by stage
End-to-end design for revenue context on Data 360 golden records. CRM accounts, contacts, orders, order items and products are streamed and mapped, unified by identity resolution, and rolled up by calculated insights. A data graph serves one golden record with its orders; a narrative DMO with hybrid search index and retriever serves semantic search. An agent briefs sellers, finds lookalikes and proposes offers. Scripted, credit-gated and SQL-verified per stage.
markdownpatternv1CW9B-D581stage: designtrust: officialservice: data360service: agentforceinterface: restinterface: cliinterface: agent-scriptinterface: typescriptgolden record RAG pipelinerevenue generation Data 360account 360 for sellersaccounts people orders pipelineend-to-end automation Data 360 Agentforcereal-time context data graphsemantic context search indexnarrative DMOlookalike accountsnext best offerRFMlifetime revenuepipeline verificationpipeline stages and ownersknown-bad pipeline designs
Golden-record RAG pipeline for revenue
Goal: a seller asks "brief me on Acme", "who buys like Acme but has gone quiet?" or "what should I offer them?". The agent answers from one reconciled view of each customer: every duplicate account and contact merged, with all their orders counted once.
Architecture
flowchart LR
CRM[CRM: Account, Contact, Order, OrderItem, Product2] --> S[Data streams → DLOs]
S --> M[Mappings → Account, Individual, Contact Points, Sales Order, Sales Order Product]
M --> IR[Identity resolution → golden people + accounts]
IR --> CI[Calculated insight: revenue rollup per golden record]
CI --> DG[Data graph: golden record + orders + rollup]
CI --> N[Transform: account narrative DMO]
N --> IX[Hybrid search index] --> R[Retriever] --> L[Data Library]
DG --> F[Flow: Get_Account_Revenue_Context]
F --> A[Revenue Assistant agent]
L --> A
P[Prompt: Next_Best_Offer] --> A
Stages
| # | Stage | Built with | Output | Verify (query-sql) |
|---|---|---|---|---|
| 1 | Ingest | POST /ssot/data-streams × 5 (reference/data360/streams-and-mapping.md) | Five DLOs | Rows in each DLO |
| 2 | Map | Standard Account and Contact mappings; your own Order → Sales Order and OrderItem → Sales Order Product | Revenue DMOs | COUNT(*) on ssot__SalesOrder__dlm matches the Order DLO |
| 3 | Unify | Two rulesets, people and accounts (reference/data360/identity-resolution.md) | Unified and link DMOs | Consolidation rate within the expected band |
| 4 | Roll up | Revenue_Rollup__cio (reference/data360/insights-and-data-graphs.md) | Lifetime revenue, order count, last order date and average order value per golden record | SUM of revenue equals SUM(ssot__GrandTotalAmount__c) |
| 5a | Real-time context | Data graph rooted on the unified account, with orders and rollup | One JSON document per golden record | A known account returns its orders |
| 5b | Semantic context | Batch transform writing Account_Narrative__dlm (one text row per golden account) → hybrid index → retriever | Searchable narratives with the account name prepended to every chunk | Chunk count > 0; the index is Ready |
| 6 | Agent | Data Library (RETRIEVER), flow, prompt template, Revenue Assistant (guides/data360/ground-a-revenue-agent.md) | Published, active agent | Agent tests pass the gate |
Stages 1 to 5 are scripted by guides/data360/automate-the-golden-record-pipeline.md. Stage 6 uses sf agent commands. Moving to another org uses data kits for the Data 360 parts (reference/data360/automation-and-data-kits.md) and sf project deploy for the flow, prompt and agent.
The narrative row (stage 5b)
One row per golden account, built from the unified account and the rollup. The hub's reading: indexing a generated narrative is how to make structured golden records searchable, because a search index embeds text fields.
Acme Corporation (golden record of 3 CRM accounts). 14 orders, lifetime revenue 120,400 USD,
average order 8,600, last order 2026-09-12 (41 days ago). Top products: Pro Licence, Support Plus.
Segment: high value, recently active.
- Put the account name first, and prepend it to every chunk, so citations name the right account.
- Write numbers as words the seller would use; keyword search in a hybrid index matches them.
- Never include contact points (email, phone) in the narrative: the agent doesn't need them to sell, and the index would expose them to every agent user.
Known-good
- Unify before you roll up, and roll up before you index. Re-run stages 3 to 5 in that order after each ingest cycle.
- One golden ID flows through everything: the data graph root, the narrative row key, and the flow's lookup.
- Stage gates in CI:
apply→run --allow-billable→wait→run→verify, then the agent tests.
Known-bad
| Design | What happens |
|---|---|
| Indexing the CRM Account object directly | Duplicates surface as separate accounts, and revenue is split across them |
| Rolling up Sales Order Product and Sales Order in one aggregate | Revenue is multiplied by the line count |
Joining orders straight to UnifiedIndividual__dlm without the link DMO and key qualifier | Few or no matches |
| Putting the data graph JSON into the search index | Large chunks of IDs embed badly. Index the narrative, look the graph up by ID |
| A service agent with no Data 360 access for the agent user | Empty knowledge summaries; the agent refuses every search |
| Running identity resolution on every CI build | The daily on-demand quota runs out and credits are wasted. Run only after data or rule changes |