Deal Pipeline & AI-Powered Lead Scoring
Deal Pipeline & AI-Powered Lead Scoring
The SaaS Factory platform includes a fully autonomous deal pipeline with a built-in, deterministic lead scoring engine. From the moment a lead enters the system to the point a deal is closed, every step is tracked, scored, and automated — with no human sales team required.
Overview
The deal pipeline system consists of three core components:
- Lead management — capture, score, and qualify inbound prospects.
- Deal management — advance qualified leads through pipeline stages to close.
- Automation — Inngest events trigger downstream workflows at key lifecycle moments.
Lead Scoring Model
Every lead is automatically assigned a score out of 100 points using computeLeadScore(). The model is fully deterministic and transparent — no black-box ML. Scores are broken into four dimensions:
| Dimension | Max Points | What It Measures |
|---|---|---|
| Firmographic | 30 | Company size, industry presence, company-level signals |
| BANT | 25 | Budget, Authority, Need, and Timeline qualification |
| ICP Match | 25 | Title seniority, role relevance, and industry ICP alignment |
| Engagement | 20 | Lead source quality and engagement behaviour |
Rescoring
Scores can be recalculated at any time by calling the rescoreLead endpoint. This is useful after enriching a lead record with new data or after a qualification call updates BANT signals.
Aggregate Stats
Use getLeadStats to retrieve aggregate scoring statistics across your lead pool — useful for pipeline health monitoring and conversion rate analysis.
Deal Pipeline
Stage Management
Deals are created from qualified leads and progress through configurable pipeline stages. When a deal is created:
- Stage probability defaults are applied automatically based on the starting stage.
- Every subsequent stage change is recorded in the activity log, providing a full audit trail.
Pipeline Summary
The getPipelineSummary endpoint returns an aggregated view of all deals across stages — total value, count, and weighted pipeline value based on stage probabilities.
Kanban Dashboard
The DealPipelineDashboard component renders a live Kanban board view of the deal pipeline. It polls tRPC queries every 30 seconds to keep the board current without requiring a manual refresh.
API Reference (tRPC Router: deals)
Lead Endpoints
| Procedure | Description |
|---|---|
createLead | Create a new lead and trigger scoring |
listLeads | List all leads with optional filters |
getLead | Fetch a single lead by ID |
updateLead | Update lead fields (triggers rescore where relevant) |
rescoreLead | Recalculate the lead score on demand |
getLeadStats | Retrieve aggregate lead scoring statistics |
Deal Endpoints
| Procedure | Description |
|---|---|
createDeal | Create a deal from a lead; applies stage probability defaults |
listDeals | List all deals, optionally filtered by stage |
getDeal | Fetch a single deal by ID |
advanceDeal | Move a deal to the next pipeline stage; writes activity log |
updateDeal | Update deal fields |
addActivity | Manually add an activity entry to the deal log |
getPipelineSummary | Aggregate pipeline view across all stages |
Automation via Inngest
The following Inngest events are fired automatically and can be used to trigger downstream workflows:
| Event | Fired When |
|---|---|
leads/created | A new lead is added to the pipeline |
leads/converted | A lead is converted into a deal |
These events integrate with the platform's broader automation infrastructure. Example downstream workflows include:
- Triggering an onboarding sequence after conversion.
- Suppressing converted leads from marketing campaigns.
- Notifying customer health monitoring systems of new accounts.
Database Schema
Three tables back the deal pipeline:
leads— stores lead records, firmographic data, BANT signals, ICP fields, and computed scores.deals— stores deal records, associated lead, current stage, probability, and value.dealActivities— append-only activity log recording every stage change and manual activity entry.