An intelligent Salesforce agent that combines schema discovery, dynamic action routing, input validation, and knowledge-grounded responses for enterprise-grade AI automation.
- Auto-discovers org metadata (objects, fields, relationships)
- FLS/sharing-aware data operations with governance
- Portable across different Salesforce orgs
- Smart Goal Analysis: Automatically routes requests based on keywords
- "reserve inventory" →
InventoryReserveaction - "update opportunity" →
UpdateOpportunityStageaction
- "reserve inventory" →
- Extensible Framework: Easy to add new routing rules
- Preflight Validation: Verifies all required inputs before database operations
- Type Safety: Validates numeric fields, required vs optional fields
- Error Prevention: Blocks invalid data from reaching the database
- Clear Messaging: Provides specific error messages for validation failures
- Data Library Integration: Uses Salesforce Knowledge for RAG
- Fallback Mechanisms: Apex-based knowledge retrieval when Data Library unavailable
- Citations & Attribution: Source tracking for grounded responses
The agent supports dynamic DOMAIN actions that are automatically routed based on user goals:
- Trigger: Goals containing "inventory", "stock", or "reserve"
- Function: Creates high-priority Tasks to represent inventory reservations
- Fields:
Product2Id(required),Quantity(required, numeric > 0),AccountId(optional) - Validation: Checkpoint guard ensures all inputs are valid before database operations
- Trigger: All other goals (default routing)
- Function: Updates Opportunity stage with FLS/sharing compliance
- Fields:
Id(required),StageName(required) - Validation: Standard Salesforce validation + guardrails
The project includes reusable prompt templates for consistent agent behavior:
- Purpose: Intelligent lead qualification with dynamic schema discovery
- Features: Picklist-aware status updates, task creation, FLS compliance
- Use Case: Sales automation, lead scoring workflows
- Purpose: E-commerce product recommendations with inventory awareness
- Features: Price filtering, stock checking, knowledge-grounded suggestions
- Use Case: Customer service, personalized shopping assistance
- Purpose: Financial loan eligibility assessment with compliance
- Features: PII protection, risk assessment, automated decision workflows
- Use Case: Financial services, loan processing automation
- Purpose: Real-time inventory verification and stock management
- Features: Dynamic catalog checking, stock level monitoring, automated alerts
- Use Case: E-commerce, supply chain management
- 🔍 Schema-Aware: No hard-coded field names or SOQL
- 🛡️ Governed: FLS and sharing rule compliance + checkpoint validation
- 📚 Knowledge-Integrated: Works with Data Libraries and Knowledge articles
- 🔄 Portable: Adapts to different org configurations
- 📋 Structured Output: JSON blueprints for safe, auditable operations
- ⚡ Intelligent Routing: Automatic action selection based on goal analysis
- Salesforce CLI installed (
sf) - Dev Hub access for scratch orgs
- Git for version control
# Clone the repository
git clone https://github.com/dentity007/Agentforce-Data-Aware-Agent.git
cd agentforce-data-aware
# Authenticate with Dev Hub
sf org login web --alias devhub --set-default-dev-hub
# Create scratch org
sf org create scratch --definition-file config/project-scratch-def.json --alias agent-data-aware --set-default --duration-days 7 --wait 10
# Deploy and setup
sf project deploy start --ignore-conflicts --wait 30
sf org assign permset --name GenAIAgentPermission
sf org openTry these example goals to see intelligent routing in action:
"Reserve 5 units of inventory for product ABC123"
→ Automatically routes to InventoryReserve action
→ Validates Quantity > 0, creates Task
"Update the opportunity stage to Closed Won"
→ Routes to UpdateOpportunityStage action
→ Updates Opportunity with governance
This project includes a scaffolding script for common development tasks:
# Make the script executable (one-time setup)
chmod +x scripts/scaffold.sh
# Setup development environment
./scripts/scaffold.sh setup dev
# Create new components
./scripts/scaffold.sh create class MyNewClass
./scripts/scaffold.sh create trigger MyTrigger Account
./scripts/scaffold.sh create lwc myComponent
# Deploy and test
./scripts/scaffold.sh deploy
./scripts/scaffold.sh test# Authenticate
sf org login web --alias devhub --set-default-dev-hub
# Create scratch org
sf org create scratch --definition-file config/project-scratch-def.json --alias agent-data-aware --set-default --duration-days 7 --wait 10
# Deploy and setup
sf project deploy start --ignore-conflicts --wait 30
sf org assign permset --name GenAIAgentPermission
sf org open
# Test intelligent routing
# "Reserve 5 units of inventory for product ABC" → InventoryReserve action
# "Update opportunity stage to Closed Won" → UpdateOpportunityStage actionThis project maintains 100% test pass rate with comprehensive coverage across all components:
# Run all tests (40+ Apex classes, 8 dedicated test suites)
sf apex run test --result-format human --code-coverage --wait 30
# Run specific test suites
sf apex run test --tests InventoryReserveTests --result-format human --wait 10
sf apex run test --tests PlannerRouteTests --result-format human --wait 10
sf apex run test --tests OrchestratorCheckpointGuardTests --result-format human --wait 10
sf apex run test --tests AgentLeadActionTests,AgentQueryTests,AgentSchemaTests --result-format human --wait 10
# Run with coverage requirements
sf apex run test --result-format human --code-coverage --coverage-threshold 75 --wait 30- InventoryReserveTests (3 tests): Task creation, input validation, optional fields
- PlannerRouteTests (2 tests): Intelligent routing for inventory vs opportunity goals
- OrchestratorCheckpointGuardTests (3 tests): Input validation before database operations
- AgentLeadActionTests: Lead qualification workflows
- AgentQueryTests: Safe SOQL execution with FLS/sharing
- AgentSchemaTests: Dynamic schema discovery
- MetadataDiscoveryTests: Object/field metadata operations
- PlannerAndOrchestratorTests: End-to-end orchestration
- PrivacyGuardTests: PII redaction and data protection
- SchemaSlicerTests: Metadata slicing and filtering
- ✅ Checkpoint Guards: Input validation prevents invalid database operations
- ✅ FLS Compliance: All operations respect field-level security
- ✅ Sharing Rules: Data access follows org sharing configuration
- ✅ Error Handling: Comprehensive error messages and graceful failures
- Intelligent Routing:
Planner(goal analysis),ActionOrchestrator(checkpoint guards) - Schema Discovery:
MetadataDiscovery,SchemaSlicer,OrgSchemaBootstrap - Data Operations:
SOQLBuilder,SafeQueryApex,DataCloudQueryApex - Security & Governance:
FLS,PrivacyGuard,JSONUtil - DOMAIN Actions:
InvocableActionFactory,DomainActionRegistry - Business Logic:
LeadQualificationAction,LeadScoreService,FollowUpApex - Knowledge Integration:
KnowledgeRetrieverApex(RAG fallback) - Testing: Comprehensive test suite with 8 test classes (100% pass rate)
- Data Operations:
ExecuteSOQL,FindFields,FindObjects,FindRelationshipPath - AI Actions:
QueryDataCloud,RunFlow,TriggerFollowUpAction,UpdateLeadStatusAction - Business Logic:
CheckInventoryAction,DiscoverMetadataAction,RetrieveKnowledgeSnippets
- LeadQualification: Sales automation with schema awareness
- PersonalShoppingRecommendation: E-commerce with inventory checking
- LoanEligibility: Financial services with PII protection
- InventoryCheck: Supply chain management
- DataAwarePrompt: General-purpose data operations
- Master Roadmap: Complete project summary, architecture, and roadmap
- One-Pager: Executive summary of capabilities and value proposition
- LLM I/O Contract: Technical specification for AI model interfaces
- Team Playbook: Complete setup and operations
- Solution Architecture: Technical deep-dive
- Quick Start: Executive summary
- Conversation Demo: Sample bot interactions
- Session Guide: Technical implementation details
- Data Library Setup: Configure Agentforce Data Libraries
- Planner Instructions: Knowledge integration guidelines
- Knowledge Integration Guide: Complete technical implementation
- Knowledge Addon README: Complete addon documentation
- Prompt Templates Guide: Reusable schema-aware templates
- Lead Qualification Template: Sales automation
- Shopping Recommendation Template: E-commerce assistance
# Run all tests (40+ Apex classes, 8 dedicated test suites, 100% pass rate)
sf apex run test --result-format human --code-coverage --wait 30
# Run specific test suites
sf apex run test --tests InventoryReserveTests,PlannerRouteTests,OrchestratorCheckpointGuardTests --result-format human --wait 10
sf apex run test --tests AgentLeadActionTests,AgentQueryTests,AgentSchemaTests --result-format human --wait 10
sf apex run test --tests MetadataDiscoveryTests,PlannerAndOrchestratorTests,PrivacyGuardTests,SchemaSlicerTests --result-format human --wait 10
# Run with coverage requirements
sf apex run test --result-format human --code-coverage --coverage-threshold 75 --wait 30This project uses semantic versioning with automated release management:
- Conventional Commits: Version bumps based on commit message prefixes:
feat:→ Minor version bump (1.0.0 → 1.1.0)fix:→ Patch version bump (1.0.0 → 1.0.1)BREAKING CHANGE:→ Major version bump (1.0.0 → 2.0.0)
- Automated Process: GitHub Actions automatically creates releases on pushes to
main/master - Changelog Generation: Release notes are automatically generated from commit messages
- Make Changes: Commit with conventional commit format
- Push to Main: Triggers automated release workflow
- Automatic Release: Version bump, tag creation, and GitHub release
- Changelog Update: Release notes added to CHANGELOG.md
git commit -m "feat: add intelligent inventory routing"
git commit -m "fix: resolve checkpoint guard validation bug"
git commit -m "feat: implement knowledge-grounded responses
BREAKING CHANGE: updated action interface"- Fork the repository
- Create a feature branch
- Make changes and add tests
- Submit a pull request
This project is licensed under the MIT License.
See CHANGELOG.md for detailed version history and updates.
- Check documentation in
docs/folder - Review GitHub Actions workflow logs
- Open issues for bugs or feature requests