A complete single-agent revenue engine for life and health insurance agents. Built with Node.js / TypeScript + Prisma + PostgreSQL.
- Lead Management: Track prospects from initial contact to closed sale
- Activity Logging: Record all interactions with automatic lead scoring
- Policy Management: Manage applications, underwriting, and issued policies
- Commission Tracking: Automatic commission calculation and payment tracking
- Dynamic Lead Scoring: AI-inspired scoring algorithm that prioritizes hot leads
- Automation Triggers: Built-in workflows for common scenarios
- CLI-First Interface: Operate entirely from the command line
- Production-Ready: Modular architecture ready to scale to multi-agent SaaS
- Node.js 18+
- PostgreSQL 15+ (or use Docker)
-
Clone and navigate to the project:
cd insurance-revenue-engine -
Start PostgreSQL (Docker - recommended):
docker-compose up -d
-
Install dependencies:
npm install
-
Set up database:
cp .env.example .env npm run db:setup
-
View dashboard:
npm run dev dashboard:overview
# Add a new lead
npm run dev lead:add "John" "Doe" "555-1234" "john@example.com"
# List all leads
npm run dev lead:list
# Filter leads by status
npm run dev lead:list -- --status QUALIFIED
# View hot leads (score >= 70)
npm run dev lead:hot
# Search leads
npm run dev lead:search "John"
# Show lead details
npm run dev lead:show <leadId>
# Update lead status
npm run dev lead:update-status <leadId> QUALIFIED
# Update intent level
npm run dev lead:update-intent <leadId> HOT# Log an activity
npm run dev activity:log <leadId> CALL_OUTBOUND INTERESTED --title "Initial call"
# List activities for a lead
npm run dev activity:list <leadId>
# List all recent activities
npm run dev activity:list
# View activity statistics
npm run dev activity:stats <leadId>
npm run dev activity:stats# Add a policy
npm run dev policy:add <leadId> "Protective Life" TERM_LIFE 500000 800
# List all policies
npm run dev policy:list
# Filter by status
npm run dev policy:list -- --status ISSUED
# Show policy details
npm run dev policy:show <policyId>
# Update policy status (e.g., mark as issued)
npm run dev policy:update-status <policyId> ISSUED# View all commissions
npm run dev commission:view
# View pending commissions only
npm run dev commission:view -- --status PENDING
# Mark commission as paid
npm run dev commission:pay <policyId>
# View commission summary
npm run dev commission:summary# List campaigns
npm run dev campaign:list
# Create a campaign
npm run dev campaign:create "Follow-up Sequence" --description "Automated follow-up"
# Run a campaign
npm run dev campaign:run "Follow-up Sequence"# View full dashboard
npm run dev dashboard:overview
# View lead score distribution
npm run dev dashboard:scoresFollow this complete walkthrough to test the system with real scenarios:
npm run dev dashboard:overviewYou'll see the default agent (Sarah Mitchell) with 10 sample leads, activities, policies, and commissions.
npm run dev lead:listNote the various lead statuses (NEW, QUALIFIED, PROPOSAL, APPLICATION, UNDERWRITING, PLACED) and intent levels.
npm run dev lead:hotThese are leads with scores >= 70. They should be your priority for follow-up.
npm run dev lead:add "Jane" "Smith" "555-9999" "jane.smith@email.com" --source "Website" --intent "WARM"Watch for:
- β Lead creation confirmation
- π§ Simulated welcome message (email)
- π Automatic score calculation
Use the lead ID from the previous step:
# Log an outbound call
npm run dev activity:log <leadId> CALL_OUTBOUND LEFT_MESSAGE --title "Initial call"
# Log a follow-up
npm run dev activity:log <leadId> CALL_INBOUND INTERESTED --title "Client called back"
# Schedule a meeting
npm run dev activity:log <leadId> MEETING_SCHEDULED --title "Meeting scheduled for Friday"Watch for:
- β Activity logged confirmation
- π Score updates with each activity
- π€ Automation triggers firing
npm run dev lead:show <leadId>Note how the score increased based on activities logged.
npm run dev policy:add <leadId> "Protective Life" TERM_LIFE 500000 600Watch for:
- β Policy created confirmation
- π Activity logged automatically
- π° Commission calculated
- π Lead status updated to APPLICATION
# First, get the policy ID from the previous output or list
npm run dev policy:list
# Mark as issued
npm run dev policy:update-status <policyId> ISSUEDWatch for:
- β Policy status updated
- π° Commission created and displayed
- π Lead status updated to PLACED
- π§ Congratulations message simulated
npm run dev commission:summaryYou'll see:
- Pending commissions
- Paid commissions
- Total amounts
- Detailed breakdown by policy
npm run dev commission:pay <policyId>npm run dev dashboard:overviewSee how your new lead, activities, policy, and commission are all reflected.
The scoring system considers multiple factors:
-
Intent Level
- HOT: +50 points
- WARM: +30 points
- COLD: +10 points
- UNKNOWN: 0 points
- NONE: -10 points
-
Lead Status
- NEW: 0 points
- CONTACTED: +5 points
- ENGAGED: +15 points
- QUALIFIED: +30 points
- PROPOSAL: +45 points
- APPLICATION: +60 points
- UNDERWRITING: +75 points
- PLACED: +100 points
- NOT_PLACED: -20 points
- NOT_INTERESTED: -30 points
- UNRESPONSIVE: -10 points
- LOST: -20 points
-
Activity Points
- MEETING_COMPLETED: +20 points
- APPLICATION_SENT: +40 points
- PROPOSAL_SENT: +15 points
- CALL_INBOUND: +10 points
- CALL_OUTBOUND: +5 points
- TEXT_RECEIVED: +8 points
- EMAIL_RECEIVED: +7 points
- And more...
-
Outcome Modifiers
- SOLD: +50 points
- INTERESTED: +15 points
- POSITIVE: +10 points
- NOT_INTERESTED: -15 points
- NO_ANSWER: -2 points
-
Time Decay
- No activity for 30 days: -5 points
- No activity for 60 days: -10 points
- No activity for 90 days: -20 points
Score Range: 0-100
Score Categories:
- π₯ Hot (70-100): Immediate follow-up required
- π‘οΈ Warm (40-69): Engage within 24-48 hours
- βοΈ Cold (10-39): nurture with periodic touches
- π€ Inactive (0-9): Consider re-engagement campaign
Default commission rates (configurable):
| Product Type | First Year | Renewal |
|---|---|---|
| Term Life | 90% | 0% |
| Whole Life | 55% | 3.5% |
| Universal Life | 55% | 3.5% |
| Final Expense | 60% | 3% |
| IUL | 50% | 2.5% |
| Health ACA | 4% | 4% |
| Medicare Supplement | 25% | 2.5% |
| Medicare Advantage | 30% | 0% |
Commission payments are typically scheduled 21 days after policy issue.
The system automatically triggers actions on:
- Lead Created: Welcome message, task creation
- Status Changed: Follow-up actions based on new status
- Activity Logged: Score update, potential follow-up tasks
- Policy Created: Commission calculation, activity logging
- Policy Issued: Congratulations message, final confirmation
- Score Changed: Hot lead alerts when score crosses threshold
All automations are logged to console with timestamp and context.
- Agent: Insurance agent (single-agent mode uses ID "1")
- Lead: Prospective clients with scoring
- Policy: Issued/applying policies
- Activity: All lead interactions
- Commission: Earnings tracking
- Campaign: Automated workflows
- Agent β Leads (1:N)
- Agent β Policies (1:N)
- Agent β Activities (1:N)
- Lead β Activities (1:N)
- Lead β Policies (1:N)
- Policy β Commissions (1:N)
insurance-revenue-engine/
βββ prisma/
β βββ schema.prisma # Database schema
β βββ seed.ts # Seed data script
βββ src/
β βββ cli/
β β βββ index.ts # CLI entry point
β β βββ commands/ # Command modules
β β βββ lead.ts
β β βββ activity.ts
β β βββ policy.ts
β β βββ commission.ts
β β βββ campaign.ts
β β βββ dashboard.ts
β βββ services/ # Business logic
β β βββ LeadService.ts
β β βββ ActivityService.ts
β β βββ PolicyService.ts
β β βββ CommissionService.ts
β β βββ ScoringService.ts
β β βββ AutomationService.ts
β βββ utils/
β βββ prisma.ts # Prisma client
β βββ logger.ts # Logging utility
βββ .env # Environment variables
βββ .env.example
βββ docker-compose.yml # PostgreSQL container
βββ package.json
βββ tsconfig.json
Edit src/services/CommissionService.ts:
export const DEFAULT_COMMISSION_RATES: Record<ProductType, number> = {
TERM_LIFE: 0.90, // Change to your rate
// ... other products
};Edit src/services/ScoringService.ts:
export const SCORING_CONFIG = {
INTENT_HOT: 50, // Adjust weights
STATUS_QUALIFIED: 30,
// ... other configurations
};Edit src/services/AutomationService.ts or create new campaigns via CLI.
# Generate Prisma client
npm run db:generate
# Run migrations
npm run db:migrate
# Push schema changes (development only)
npm run db:push
# View data in Prisma Studio
npm run db:studio
# Reset database (WARNING: deletes all data)
npm run db:reset
# Re-seed database
npm run db:seed# Build TypeScript
npm run build
# Run compiled CLI
npm start <command>
# Run in development mode
npm run dev <command>The modular architecture makes it easy to scale:
- Authentication: Add user login/registration
- Multi-Tenant: Each agent has isolated data
- Web Dashboard: React/Vue frontend
- API Layer: REST/GraphQL endpoints
- Real Integrations:
- Twilio for SMS
- SendGrid/Mailgun for email
- Insurance carrier APIs
- Advanced Features:
- Document generation
- E-signature integration
- Reporting and analytics
- Mobile apps
MIT
For issues, questions, or contributions, please refer to the project repository.
Built for independent insurance agents who need to start using today.