All Docs
FeaturesSaaS FactoryUpdated February 19, 2026

AI-Powered Deal Pipeline & Lead Scoring

AI-Powered Deal Pipeline & Lead Scoring

Available since: v1.0.2

The SaaS Factory platform now includes a fully automated deal pipeline and AI-powered lead scoring system under the Sales & Revenue section. This eliminates the need for a human sales team by autonomously tracking prospects, scoring leads, and progressing deals through pipeline stages.


Overview

The deal pipeline and lead scoring system consists of three coordinated layers:

  1. Schema — Database tables for prospects, deals, stages, and scoring
  2. Revenue Agent — AI logic that scores leads and automates stage transitions
  3. Pipeline UI — Surfaces deal status and lead scores in the Sales & Revenue dashboard

Database Schema

The following tables were added to billing-schema.ts in v1.0.2:

prospects

Represents an inbound or outbound lead before they become a paying customer.

ColumnTypeDescription
iduuidPrimary key
emailtextContact email
lead_scoreintegerAI-calculated score (0–100)
score_updated_attimestampWhen the score was last recalculated
created_attimestampWhen the prospect was created

pipeline_stages

Defines the ordered stages a deal moves through.

ColumnTypeDescription
iduuidPrimary key
nametextStage label (e.g. "Qualified", "Demo Scheduled")
orderintegerPosition in the funnel
score_thresholdintegerMinimum lead score required to enter this stage

deals

Links a prospect to a pipeline stage and tracks deal velocity.

ColumnTypeDescription
iduuidPrimary key
prospect_iduuidForeign key → prospects
stage_iduuidForeign key → pipeline_stages
velocity_daysintegerDays spent in the current stage
stage_entered_attimestampWhen the deal entered the current stage
stage_historyjsonbOrdered log of all previous stage transitions

AI Lead Scoring

The revenue agent scores each prospect on a 0–100 scale using the following signals:

  • Usage signals — Activity and engagement patterns from the product
  • Subscription tier fit — How well the prospect's profile matches available plans
  • Engagement data — Email opens, page visits, and support interactions

Scores are recalculated automatically whenever a relevant signal changes. The updated score is written back to prospects.lead_score and a lead.scored event is emitted to Inngest.

Score Thresholds

Each pipeline_stage has a score_threshold. When a prospect's score crosses a threshold, the revenue agent automatically creates or advances the corresponding deal record to the matching stage. This transition is recorded in deals.stage_history with a timestamp.


Revenue Agent: Lead Lifecycle Automation

Prior to v1.0.2, the revenue agent only produced monetization suggestions. It now participates in the full lead lifecycle:

Prospect created
     │
     ▼
Revenue agent scores lead (0–100)
     │
     ▼
Score meets stage threshold?
  ├── Yes → Advance deal to next stage
  │         Emit deal.stage_advanced event to Inngest
  └── No  → Re-evaluate on next signal change

Inngest workflows downstream of deal.stage_advanced can trigger additional automation such as outreach sequences, notifications, or CRM updates.


Pipeline UI

The Sales & Revenue dashboard now includes:

  • Pipeline board — Kanban-style view of all active deals grouped by stage
  • Lead score column — Visible on each deal card, color-coded by score range
  • Deal velocity indicator — Flags deals that have been in a stage longer than the stage average
  • Prospect list — Filterable table of all prospects with scores and current stage

Migration

If you are upgrading from v1.0.1 or earlier, run the database migration before deploying:

# Apply the new pipeline schema tables
npx drizzle-kit push

Existing customers and subscriptions data is not modified. The new tables are additive only.


Related