Skip to content

akshcreatesstuff/Lead-Intelligence

Repository files navigation

Lead Intelligence Platform

Problem Statement

Sales teams struggle with:

  • Leads coming from multiple sources with no unified view
  • Duplicated contact data polluting the CRM
  • Missed follow-ups due to no intelligent prioritization
  • CRM data sitting idle — not used for analytics or AI

This platform solves it by building a real-time, AI-powered lead management system that syncs Salesforce CRM data with Google services, scores leads automatically, and triggers smart follow-up actions.


High-Level Architecture

Salesforce Lead Created
        │
        ▼
Platform Event Published
        │
        ▼
Queueable Apex (async)
        │
        ▼ REST callout (OAuth2 / Named Credential)
Google Cloud Function
        │
        ├──► BigQuery (store lead data)
        │
        └──► Vertex AI (score lead)
                │
                ▼
        Callback → Salesforce REST Endpoint
                │
                ├──► Update AI_Score__c
                ├──► Auto-create Task
                └──► Google Calendar Event + Gmail Draft

Tech Stack

Salesforce

  • Apex (Queueable, Batchable, REST)
  • Platform Events
  • Named Credentials (OAuth2)
  • Custom Metadata (config)
  • Lightning Web Components (dashboard)
  • Custom Logging Framework

Google Cloud

  • Cloud Functions (HTTP triggered)
  • BigQuery (data warehouse)
  • Vertex AI (lead scoring)
  • Google Calendar API
  • Gmail API

Project Structure

/salesforce
  /classes          → Apex classes
  /triggers         → Apex triggers
  /objects          → Custom object metadata
  /lwc              → Lightning Web Components
  /customMetadata   → Config records

/google-cloud
  /functions        → Cloud Function source code
  /bigquery         → Schema definitions
  /vertex           → AI model config

/docs
  /diagrams         → Architecture, sequence, ER diagrams
  /decisions        → Engineering decision records

Custom Fields on Lead Object

Field Label API Name Type Purpose
AI Score AI_Score__c Number Score returned by Vertex AI (0–100)
Sync Status Sync_Status__c Picklist Pending / Synced / Failed
Duplicate Flag Duplicate_Flag__c Checkbox Flagged by deduplication engine
External ID External_Id__c Text Idempotency key for external systems
Retry Count Retry_Count__c Number Tracks callout retry attempts
Last Sync Timestamp Last_Sync_Timestamp__c DateTime When last synced to Google Cloud

Key Engineering Decisions

Why Queueable Apex over @future?

  • Queueable supports chaining (job A → job B → job C)
  • Supports complex object types as parameters
  • Better error handling and monitoring via AsyncApexJob

Why Platform Events?

  • Decouples trigger logic from external integration
  • Survives transaction rollbacks (events are published even if DML fails)
  • Enables microservice-style architecture inside Salesforce

Governor Limit Strategy

  • All SOQL queries use Maps for O(1) lookups
  • No SOQL or DML inside loops
  • Bulk-safe: all code processes List not single records
  • Callouts batched and chunked to respect limits

Idempotency

  • Each outbound request carries a unique correlation_id
  • Prevents duplicate processing if retried

Sprint Plan

Week Focus
Week 1 Salesforce core — data model, trigger framework, async pipeline, logging
Week 2 Google Cloud — Cloud Function, BigQuery, simulated AI scoring
Week 3 Intelligence — dedup engine, Google Workspace, retry strategy
Week 4 UI, documentation, demo, polish

Setup Instructions

(Will be updated as each phase is completed)

  1. Deploy Salesforce metadata using SF CLI
  2. Configure Named Credential with Google Cloud OAuth2
  3. Deploy Cloud Function to GCP
  4. Update Custom Metadata with live endpoint URL
  5. Assign permission sets to users

About

Grades leads in SF using bigquery & vertexAI and creates the google calendar event for follow-ups

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors