An AI-powered invoice recovery platform that automatically detects overdue invoices, assesses risk using machine learning, and executes multi-channel recovery actions via Razorpay payment links.
Live Demo: invonotify.vercel.app Live Demo: YouTube
- Overview
- Key Features
- Quick Start
- Architecture
- Tech Stack
- Environment Variables
- Demo Setup
- AI Recovery System
- Dashboard Pages
- API Reference
- Razorpay Integration
- Testing
- Deployment
- License
InvoNotify solves the ₹50,000 crore problem of unpaid B2B invoices. Instead of manual collection teams chasing payments, an AI agent autonomously:
- Detects overdue invoices
- Scores risk using ML (11 features)
- Decides the best action and channel
- Executes via email, WhatsApp, or Razorpay payment links
- Learns from outcomes to improve
Demo Credentials:
- Email:
razorpay@invo-notify.test - Password:
razorpay
- ML risk scoring with 11 weighted features
- LLM-powered decision agent (GPT-4o-mini)
- 9 policy guardrails (no harassment, opt-outs, business hours)
- Explainable decisions with feature contributions
- Email — Gmail SMTP with branded templates
- WhatsApp — Meta Cloud API (free within 24h window)
- Razorpay Payment Links — One-click checkout
- CIBIL credit score integration
- Payment history analysis
- Promise-to-pay tracking
- Automated reminder scheduling
- Real-time recovery funnel
- Baseline vs AI comparison (85% vs 18%)
- Strategy effectiveness tracking
- Full audit trail
# Clone and install
git clone https://github.com/HEETMEHTA18/InvoNotify.git
cd InvoNotify
pnpm install
# Setup database
npx prisma generate
npx prisma migrate deploy
# Seed demo data
pnpm ai:seed
# Start dev server
pnpm devOpen http://localhost:3000 and login with razorpay / razorpay.
See proposed.md for full architecture diagrams and system design.
Overdue Invoice → ML Risk Scoring → Decision Agent → Policy Engine → Execute Action
↓
┌──────────────────────┤
↓ ↓
Email WhatsApp
↓ ↓
Payment Link ←──────────────┘
↓
Razorpay Checkout
↓
Webhook → Case Closed
| Layer | Technology |
|---|---|
| Frontend | Next.js 16, React 19, Tailwind CSS |
| Backend | Next.js API Routes |
| Database | PostgreSQL (Neon) + Prisma ORM |
| Auth | NextAuth v5 |
| Payments | Razorpay Test Mode |
| Gmail SMTP (nodemailer) | |
| Meta Cloud API | |
| ML | Logistic Regression (custom) |
| LLM | GPT-4o-mini |
| Hosting | Vercel |
Create .env in repository root:
DATABASE_URL="postgresql://..."
DIRECT_URL="postgresql://..."
AUTH_SECRET="your-secret"
NEXTAUTH_SECRET="your-secret"RAZORPAY_KEY_ID="rzp_test_..."
RAZORPAY_KEY_SECRET="..."
RAZORPAY_WEBHOOK_SECRET="..."GMAIL_USER="your-email@gmail.com"
GMAIL_APP_PASSWORD="your-app-password"OPENAI_API_KEY="sk-..."CRON_SECRET="long-random-secret"# Reset and seed 9 customers, 15 invoices
pnpm ai:seed
# Run AI sweep (safe demo mode)
curl -X POST http://localhost:3000/api/ai/recovery \
-H "Content-Type: application/json" \
-d '{"dryRun": true}'| Customer | CIBIL | Risk | Demonstrates |
|---|---|---|---|
| Acme Traders | 720 | LOW | Gentle reminder |
| Beta Industries | 580 | HIGH | Human approval required |
| Gamma Retail | 810 | LOW | Excellent payer |
| Delta Logistics | 620 | HIGH | Chronic late payer |
| Epsilon Foods | 700 | MEDIUM | Payment link |
| Zeta Pharma | 690 | BLOCKED | Opted out |
| Omega Constructions | 750 | VIP | Human handled |
| Kappa Textiles | 660 | STOP | Below cost floor |
| Sigma Electronics | 540 | CRITICAL | Escalate immediately |
11 features scored via logistic regression:
{
amountDue, // 0.15 weight
daysOverdue, // 0.20 weight
customerAgeDays, // 0.05 weight
previousInvoiceCount,// 0.08 weight
previousLatePayments,// 0.18 weight
averagePaymentDelayDays, // 0.12 weight
paymentSuccessRate, // 0.10 weight
previousReminders, // 0.05 weight
isVipExempt, // 0.02 weight
cibilScore, // 0.03 weight
humanEngaged // 0.02 weight
}| Score | Level | Action |
|---|---|---|
| ≥ 0.85 | CRITICAL | Escalate to human |
| ≥ 0.70 | HIGH | Aggressive follow-up |
| ≥ 0.40 | MEDIUM | Payment link + reminders |
| < 0.40 | LOW | Gentle nudge |
9 guardrails prevent:
- Contacting opted-out customers
- Harassment (frequency caps)
- Contacting outside business hours
- Auto-sending large amounts (requires approval)
- Chasing invoices below cost floor
| Route | Description |
|---|---|
/dashboard |
Main KPIs and metrics |
/dashboard/invoices |
Invoice list + create |
/dashboard/recovery |
AI recovery war room |
/dashboard/recovery/analytics |
Funnel + baseline comparison |
/dashboard/diagnosis |
ML failure classification |
/dashboard/credit-scores |
CIBIL score dashboard |
/dashboard/promises |
Promise-to-pay tracking |
/dashboard/whatsapp |
WhatsApp channel config |
/dashboard/customers |
Customer management |
/dashboard/settings |
Merchant settings |
POST /api/invoices— Create invoiceGET /api/invoices— List invoicesPOST /api/payments— Record paymentPOST /api/invoices/[id]/send— Send invoice email
GET /api/ai/recovery— List recovery casesPOST /api/ai/recovery— Run AI sweepPOST /api/ai/recovery/[id]/approve— Approve action
POST /api/v1/recovery-cases/[id]/diagnose— ML diagnosisPOST /api/v1/recovery-cases/[id]/score— Risk scoringPOST /api/v1/recovery-cases/[id]/promises— Create promisePOST /api/v1/promises/reminders— Process remindersPOST /api/v1/credit-score— Fetch credit scores
GET/POST /api/webhooks/razorpay— Razorpay payment events
- AI creates payment link via
POST /payment_links - Link URL included in email + WhatsApp
- Customer clicks → Razorpay checkout
- Payment succeeds → Webhook fires
- Invoice marked as paid → Case closed
// GET handler (callback_method: "get")
GET /api/webhooks/razorpay?razorpay_payment_id=...&razorpay_payment_link_status=paid
// POST handler (webhook events)
POST /api/webhooks/razorpay# AI unit tests (15 tests)
pnpm ai:unit
# Full test suite (42 tests)
npx tsx --test tests/ai/agent/decision-agent.test.ts tests/ai/policy/engine.test.ts
# TypeScript check
npx tsc --noEmit# Push to GitHub
git push origin main
# Vercel auto-deploys from main branchSet in Vercel Dashboard → Settings → Environment Variables:
DATABASE_URLRAZORPAY_KEY_IDRAZORPAY_KEY_SECRETGMAIL_USERGMAIL_APP_PASSWORDCRON_SECRET
- CI: Runs tests on every push
- Recovery Sweep: Cron job every 6 hours
app/ Next.js pages and API routes
├── dashboard/ Dashboard pages
│ ├── credit-scores/ CIBIL score dashboard
│ ├── diagnosis/ ML failure diagnosis
│ ├── invoices/ Invoice management
│ ├── promises/ Promise-to-pay
│ ├── recovery/ AI recovery + analytics
│ └── whatsapp/ WhatsApp channel
├── invoice/ Public invoice pages
└── api/ Backend API routes
├── ai/ AI recovery endpoints
├── v1/ v1 API endpoints
└── webhooks/ Webhook handlers
lib/ Shared utilities
├── ai/ AI engine (ML, decisions, policies)
├── razorpay.ts Razorpay integration
├── whatsapp.ts WhatsApp Cloud API
├── credit-bureau.ts Credit score fetching
└── mail-service.ts Email + WhatsApp delivery
components/ React components
├── customers/ CIBIL meter gauge
├── recovery/ Recovery case components
└── ui/ Base UI primitives
- Architecture & System Design →
- PRD.md — Product requirements
- DEMO_SCRIPT.md — 5-minute demo script
- DEMO_VIDEO_PIPELINE.md — Video creation guide
Developed for Razorpay Hackathon. All rights reserved.