An AI-powered Salesforce application that automatically discovers and visualizes business relationships by analyzing CRM data and web sources.
Relationship Research Agent (RRA) enhances your Salesforce CRM by automatically discovering and mapping business relationships between people and organizations. Using AI-powered analysis, RRA:
- Discovers hidden connections between accounts, contacts, leads, and opportunities
- Visualizes relationship networks with interactive D3.js-based graphs
- Enriches CRM data by combining internal records with web research
- Provides context with citations and sources for every relationship discovered
- π Automated Relationship Discovery - Analyzes CRM data and web sources to find connections
- π Interactive Graph Visualization - D3.js-powered relationship network display
- π€ AI-Powered Entity Matching - Uses Einstein Prompt Builder for intelligent entity resolution
- β‘ Async Processing - Background job processing for large data sets
- π± Lightning Experience Ready - Custom components for Account, Contact, Lead, and Opportunity pages
Before installing RRA, ensure your Salesforce org has:
- Salesforce Edition: Enterprise, Unlimited, or Developer Edition
- API Version: 62.0 or higher
- Agentforce: Enabled
- Einstein Prompt Builder: GenAI Prompt Template support
- Agentforce Data Library: Web Retriever configured
- Platform Cache: Org cache allocated
- Lightning Experience: Enabled
- My Domain: Deployed
-
Clone the Repository
git clone https://github.com/SalesforceLabs/RelationshipResearchAgent.git cd RelationshipResearchAgent -
(Optional) Install Dev Dependencies
Only needed if you plan to run tests, linters, or formatters.
nvm use # optional: if using nvm npm install -
Authenticate to Salesforce
sf org login web --set-default
Or authenticate to a specific instance:
sf org login web --instance-url https://your-domain.my.salesforce.com --alias rra-org
-
Configure Salesforce Org Prerequisites
a. Enable Agentforce
- Navigate to Setup > Agentforce
- Enable Agentforce for your org
b. Create Web Retriever (Agentforce Data Library)
- Navigate to Setup > Agentforce Data Library
- Click New
- Configure:
- Data Type: Web
- Turn on Web Search: Enabled
- Web Source: Search the Web
- Save
c. Disable Data Masking
- Navigate to Setup > Einstein Trust Layer
- Select Large Language Model Data Masking
- Turn Off
Note: Data masking will hinder entity name recognition and relationship extraction.
-
Deploy All Metadata to Salesforce
sf project deploy start --test-level NoTestRun
Or deploy using the manifest:
sf project deploy start --manifest manifest/package.xml
-
Activate Custom Record Pages
- Navigate to Setup > Lightning App Builder
- Open each custom record page:
Account_Record_PageContact_Record_PageLead_Record_Page1Opportunity_Record_Page
- Click Activation
- Set as org default or assign to specific apps/profiles
- Save
Alternatively, you can add the RRA component to your own custom record pages.
-
Verify Prompt Templates
Navigate to Setup > Prompt Builder and verify all templates are active:
RRA_CommonNameVariantsRRA_EntityMatcherRRA_EntitiesFromCRMRRA_ConsolidateInsightsRRA_AppendRelationshipsRRA_DeepWebResearch_DiscoveryRRA_DeepWebResearch_RefinementRRA_ConsolidateCrossSourceInsights
Known Issue: Templates may deploy as inactive. Manually activate if needed, and ensure output mode is set to JSON.
- Navigate to an Account, Contact, Lead, or Opportunity record
- The RRA component appears on the Lightning page
- Click Start Research
- Processing occurs in the background (async)
- View the interactive relationship graph when complete
- Nodes: Represent people and organizations
- Edges: Show relationships with predicates (e.g., "founded", "CEO of")
- Colors: Indicate entity types
Click on entities to:
- Create Record: Create a new CRM record (Account, Contact, or Lead) from an unmatched entity
- Link Record: Associate an entity with an existing CRM record
- View Record: Navigate to the linked CRM record
- View Citations: See source URLs and references for discovered relationships
RRA processes relationships asynchronously in the background. To monitor job progress:
- Navigate to Setup > Environments > Jobs > Apex Jobs
- Look for jobs with class name RRAClientAsync
- Check the Status column (Queued, Processing, Completed, Failed)
- Refresh the record page to see updated results when the job completes
Apex Classes:
RRAClient/RRAClientAsync- Main API entry pointsCrmRelationshipInsightsProcessor- Orchestrates relationship discoveryDeepWebResearchEngine- Web research via AgentforceEntityMatcher- AI-powered entity resolutionEntityMatcherDataCloud- Data Cloud subroutines for entity resolutionCrmDatabaseSelectors- Database queries for CRM dataRelationshipInsightsPersister- Persists discovered relationships
Lightning Web Components:
rraComponent- Main component for Lightning pagesrraGraph- D3.js-based graph visualizationrraConfirmMatchModal- Entity matching UIrraCreateRecordModal- Record creation dialog
Custom Objects:
RRARelationships__c- Stores relationship data as JSON
GenAI Prompt Templates:
- 7 specialized prompts for entity extraction, matching, consolidation, and web research
Data Cloud components are optional and requires manual building of pipelines per the reference documentation. See DataCloud Readme
With Data Cloud components enabled, Entity Resolution can be executed against data coming from external datasources (such as leads or SSOT), and can be customized to work with custom text fields, not just default name fields.
RRA will fail gracefully if DataCloud components are not available, e.g. will perform CRM matching instead.
Run all Apex tests:
sf apex run test --synchronous --code-coverage --result-format humanRun specific test class:
sf apex run test --synchronous --tests EntityMatcherTestGet the most recent log:
sf apex log get --number 1Filter to USER_DEBUG only:
sf apex log get --number 1 | grep 'USER_DEBUG'Remove ANSI color codes with ansi2txt:
sf apex log get --number 1 | ansi2txt > test.logFormat code with Prettier:
npm run prettierVerify formatting:
npm run prettier:verifyRun linter:
npm run lintDeploy a single Apex class:
sf project deploy start --metadata ApexClass:EntityMatcherDeploy multiple components:
sf project deploy start --metadata ApexClass:EntityMatcher --metadata ApexClass:EntityMatcherTestThe graph component uses Salesforce Lightning Design System icons via SVG sprite files.
To update icons:
# Install SLDS
npm install @salesforce-ux/design-system --save-dev
# Copy sprite files to static resources
cp node_modules/@salesforce-ux/design-system/assets/icons/standard-sprite/svg/symbols.svg force-app/main/default/staticresources/symbols.svg
cp node_modules/@salesforce-ux/design-system/assets/icons/utility-sprite/svg/symbols.svg force-app/main/default/staticresources/symbolsutil.svg- Templates may deploy as inactive even when exported as active
- Output mode may reset from JSON
- Workaround: Manually activate templates and set output mode to JSON in Prompt Builder
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
To report security vulnerabilities, see SECURITY.md.
Copyright (c) 2025 Salesforce, Inc.
Licensed under the Apache License, Version 2.0. See LICENSE.txt for details.
- GitHub Issues: Report bugs and request features
- GitHub Discussions: Ask questions and share ideas
Built with β€οΈ by Salesforce