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:
- Schema — Database tables for prospects, deals, stages, and scoring
- Revenue Agent — AI logic that scores leads and automates stage transitions
- 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.
| Column | Type | Description |
|---|---|---|
id | uuid | Primary key |
email | text | Contact email |
lead_score | integer | AI-calculated score (0–100) |
score_updated_at | timestamp | When the score was last recalculated |
created_at | timestamp | When the prospect was created |
pipeline_stages
Defines the ordered stages a deal moves through.
| Column | Type | Description |
|---|---|---|
id | uuid | Primary key |
name | text | Stage label (e.g. "Qualified", "Demo Scheduled") |
order | integer | Position in the funnel |
score_threshold | integer | Minimum lead score required to enter this stage |
deals
Links a prospect to a pipeline stage and tracks deal velocity.
| Column | Type | Description |
|---|---|---|
id | uuid | Primary key |
prospect_id | uuid | Foreign key → prospects |
stage_id | uuid | Foreign key → pipeline_stages |
velocity_days | integer | Days spent in the current stage |
stage_entered_at | timestamp | When the deal entered the current stage |
stage_history | jsonb | Ordered 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
- Changelog — Full release history
- Revenue & Subscriptions — Existing billing and subscription documentation