AI-Powered Dunning
BillHiveβs AI Dunning Engine replaces one-size-fits-all retry schedules with personalized, adaptive recovery strategies. Instead of following the same timeline for every customer, the system predicts the best recovery action for each individual case β when to retry, how to communicate, and what offer to make.
Why AI Dunning
Traditional rule-based dunning applies the same schedule to every customer. AI-driven dunning treats each failed payment as a unique recovery opportunity.
| Aspect | Rule-Based Dunning | AI-Powered Dunning |
|---|---|---|
| Retry timing | Fixed intervals (Day 1, 3, 5, 7β¦) | Predicted optimal window per customer |
| Communication | Same email template for all | Personalized tone, channel, and content |
| Final action | Same for all customers | Risk-scored: retain high-value, cancel low-engagement |
| Recovery rate | 30β50% industry average | 50β70% with AI optimization |
| Learning | Static rules, manual tuning | Continuously learns from outcomes |
AI Components
BillHiveβs AI dunning system consists of 10 interconnected components that work together to maximize payment recovery.
1. Payment Recovery Prediction
When a payment fails, the AI model predicts the probability that the payment will be recovered. This score drives all downstream decisions.
Input features:
| Feature | Source | Why It Matters |
|---|---|---|
payment_method_type | Subscription | Card vs mandate vs wallet recovery rates differ |
issuer_bank | Payment gateway | Some banks have higher decline rates |
card_type | Payment gateway | Credit cards recover better than debit |
failure_reason | Gateway error code | Insufficient funds vs expired card have different recovery paths |
previous_failure_count | Dunning history | Repeat failures predict lower recovery |
customer_lifetime_value | Billing data | High-CLV customers are more likely to recover |
subscription_amount | Subscription | Lower amounts recover more easily |
customer_country | Account | Regional payment behavior patterns |
account_age | Account | Older accounts have higher loyalty |
days_since_last_login | Product usage | Active users are more likely to pay |
Output:
{
"recovery_probability": 0.82,
"confidence": 0.91,
"recommended_strategy": "retry_soon",
"estimated_recovery_days": 3
}Decision matrix:
| Recovery Probability | Strategy |
|---|---|
| > 80% | Retry soon β high chance of success |
| 50β80% | Send reminder first, then retry |
| 20β50% | Ask customer to update payment method |
| < 20% | Offer grace period or payment plan |
2. Smart Retry Scheduler
Instead of retrying on fixed days, the AI predicts the optimal retry window for each customer based on historical patterns.
How it works:
- Analyzes past payment success patterns by day of week and time of day
- Detects salary cycle patterns (e.g., payments succeed around the 1st and 15th)
- Identifies bank-specific decline windows (e.g., some banks decline more at night)
- Avoids retrying during known low-success windows
Example optimizations:
| Customer Pattern | AI Action |
|---|---|
| Salary credited on 1st of month | Retry on 2nd |
| Bank declines after 10 PM | Retry at 10 AM |
| Weekend payments always fail | Retry on Monday |
| Previous success after 48 hours | Wait 48 hours before first retry |
Impact: Smart retry timing alone can improve recovery rates by 10β20% compared to fixed schedules.
3. AI Communication Generator
Instead of static email templates, the AI generates personalized dunning messages tailored to the customer context.
Personalization inputs:
| Input | Effect on Message |
|---|---|
| Customer segment (enterprise, SMB, consumer) | Formal vs casual tone |
| Failure reason | Specific guidance (e.g., βyour card expiredβ vs βinsufficient fundsβ) |
| Invoice amount | Urgency calibration |
| Account age and CLV | Loyalty acknowledgment |
| Previous dunning interactions | Avoid repeating the same message |
| Dunning stage | Escalating urgency |
Example β Friendly tone for a startup customer:
Hi John,
Looks like your payment of $299 didnβt go through β this sometimes happens when cards hit their limit.
You can update your card here: [Update Payment Method]
Weβll retry automatically tomorrow. No action needed if your card is fine β it might just be a temporary hold.
Example β Formal tone for an enterprise customer:
Dear Finance Team,
Invoice #INV-2024-1847 for $12,500.00 was not processed successfully. The payment gateway reported: card expired.
Please update your payment method at your earliest convenience: [Update Payment Method]
Your subscription services remain active during the grace period. If you need to arrange alternative payment terms, please contact your account manager.
4. Customer Behavior Scoring
AI continuously scores each customerβs likelihood to churn vs recover, using product engagement signals alongside payment data.
Scoring signals:
| Signal | Weight | Interpretation |
|---|---|---|
| Login frequency (last 30 days) | High | Active users want to keep their subscription |
| Feature usage depth | High | Deep usage = high switching cost |
| Support ticket history | Medium | Recent tickets may indicate dissatisfaction |
| Account age | Medium | Longer tenure = higher recovery likelihood |
| Payment history | High | History of on-time payments = likely temporary issue |
| Team size / seats used | Medium | More users = harder to churn |
Risk-based dunning actions:
| Customer Risk Profile | Dunning Strategy |
|---|---|
| High-value, high-engagement | Extended grace period, personal outreach from CSM, offer payment plan |
| High-value, low-engagement | Escalate to manual review, proactive CSM call |
| Medium-value, high-engagement | Standard dunning with friendly tone, offer temporary discount |
| Medium-value, low-engagement | Accelerated dunning, shorter grace period |
| Low-value, low-engagement | Standard dunning, cancel at period end |
5. Channel Optimizer
AI determines the best communication channel for each customer based on historical engagement data.
Channel selection logic:
| Signal | Channel Decision |
|---|---|
| High email open rate | Continue with email |
| Low email open rate, high SMS click rate | Switch to SMS |
| WhatsApp business account linked | Use WhatsApp for reminders |
| Enterprise account with Slack integration | Send in-app notification via Slack |
| No engagement on any channel | Escalate to phone call (manual) |
Learning loop: The system tracks open rates, click rates, and payment conversions per channel per customer segment, and shifts channel allocation toward higher-performing channels over time.
6. AI Negotiation Agent
An automated conversational agent that handles real-time payment recovery conversations with customers.
Capabilities:
| Scenario | AI Response |
|---|---|
| βI canβt pay right nowβ | Offer to pause subscription for 2 weeks |
| βThe amount is too highβ | Offer a temporary discount or downgrade path |
| βI want to cancelβ | Offer a reduced plan or usage-based pricing |
| βIβll pay next weekβ | Set expected payment date, pause retries |
| βMy card was stolenβ | Guide to payment method update page |
Guardrails:
- Maximum discount authority: configurable per tenant (e.g., up to 20% for 1 billing cycle)
- Escalation to human agent when confidence is low or customer is frustrated
- All offers are logged and tracked for revenue impact analysis
- Configurable offer policies per plan tier
7. Root Cause Analysis
AI analyzes failure patterns across all dunning cases to identify systemic issues and recommend preventive actions.
Pattern detection examples:
| Pattern Detected | AI Recommendation |
|---|---|
| 32% of failures are βinsufficient fundsβ | Enable retry timing around salary cycles |
| 24% of failures are βexpired cardβ | Enable card updater service (network tokenization) |
| 18% are bank-specific declines from Bank X | Route payments through alternate gateway |
| Spike in failures every month-end | Stagger billing dates across the month |
| High failure rate for annual plans | Offer monthly billing as fallback before cancellation |
Actionable outputs:
- Monthly dunning health report with top failure reasons
- Gateway performance comparison (which gateway recovers better)
- Payment method recommendations (e.g., βEnable UPI Autopay to reduce failures by 15%β)
- Billing date optimization suggestions
8. Customer Segmentation
AI automatically clusters customers into segments with distinct dunning strategies, rather than applying one strategy to all.
Auto-generated segments:
| Segment | Characteristics | Dunning Strategy |
|---|---|---|
| Loyal Payers | Long tenure, rarely fails, high CLV | Gentle reminder, extended grace, never cancel without manual review |
| Occasional Defaulters | Moderate tenure, fails 1β2x per year | Standard dunning, payment update nudge |
| Chronic Defaulters | Frequent failures, often recovers late | Aggressive retry, shorter grace period, require backup payment method |
| At-Risk Churners | Declining usage, recent failures | Proactive outreach, retention offer, CSM escalation |
| New Customers | < 3 months, first failure | Extra-gentle messaging, onboarding support link |
Segments are dynamic β customers move between segments as their behavior changes.
9. Self-Learning Engine
The dunning system continuously improves by learning from every recovery attempt.
Feedback loop:
Payment Fails
β AI predicts recovery strategy
β Strategy executes (retry, email, offer)
β Outcome recorded (recovered / not recovered)
β Model retrained on new outcome data
β Future predictions improveMetrics tracked per strategy:
| Metric | Purpose |
|---|---|
| Recovery rate by retry time | Optimize retry scheduling |
| Recovery rate by message tone | Optimize communication style |
| Recovery rate by channel | Optimize channel selection |
| Recovery rate by offer type | Optimize negotiation strategy |
| Time to recovery by segment | Optimize dunning duration per segment |
A/B testing framework:
- Automatically split dunning cases into control (rule-based) and treatment (AI) groups
- Compare recovery rates, time-to-recovery, and customer satisfaction
- Gradually shift traffic to winning strategies
- Configurable experiment duration and sample size
10. Predictive Churn Prevention
Goes beyond reactive dunning by predicting payment failures before they happen and taking preventive action.
Pre-dunning signals:
| Signal | Preventive Action |
|---|---|
| Card expires within 30 days | Send proactive card update reminder |
| Customerβs payment amount increased significantly | Send advance notice of upcoming charge |
| Customer usage dropped 50%+ this month | Proactive retention outreach before next billing |
| Bank associated with high decline rates | Pre-authorize a small amount before the actual charge |
| Previous failure pattern (fails every Q4) | Schedule early retry window for Q4 billing |
Architecture
System Overview
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Payment Fails β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AI Dunning Orchestrator β
β βββββββββββββββ ββββββββββββββββ βββββββββββββββββ β
β β Recovery β β Behavior β β Segmentation β β
β β Predictor β β Scorer β β Engine β β
β ββββββββ¬βββββββ ββββββββ¬ββββββββ ββββββββ¬βββββββββ β
β ββββββββββββββββββΌββββββββββββββββββ β
β βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Strategy Decision Engine β β
β ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββΌββββββββββββββββββ
βΌ βΌ βΌ
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββββββ
β Smart Retry β β Channel β β Communication β
β Scheduler β β Optimizer β β Generator (LLM) β
ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββ¬ββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Execution Layer β
β Payment Retry API β Notification Engine β Chatbot β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Outcome Tracking & Learning β
β Recovery logged β Model retrained β Strategies updated β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββIntegration with Existing BillHive Services
| BillHive Service | AI Dunning Integration |
|---|---|
| subscription-service | Subscription status, plan details, usage data |
| billing-service | Invoice data, payment history, CLV calculation |
| payment-service | Gateway error codes, retry execution, payment method data |
| notification-service | AI-generated message delivery across channels |
| camunda-setup | Deploys the Camunda BPMN/DMN definitions (with AI decision points) on startup |
| reporting-service | Dunning analytics, recovery metrics, A/B test results |
| facade | API gateway for AI dunning configuration and status |
Job Queues (BullMQ)
| Queue | Purpose |
|---|---|
ai-dunning-prediction | Run recovery prediction model on new dunning cases |
ai-retry-scheduler | Schedule optimized retry times |
ai-communication-generator | Generate personalized dunning messages via LLM |
ai-dunning-outcome | Record outcomes and trigger model retraining |
ai-churn-prevention | Process pre-dunning preventive actions |
Database Schema
dunning_ai_cases
Extends the base dunning case with AI-specific data.
| Column | Type | Description |
|---|---|---|
id | UUID | Primary key |
invoice_id | UUID | FK to invoice |
customer_id | UUID | FK to account |
tenant_id | UUID | FK to tenant |
failure_reason | VARCHAR | Gateway failure reason code |
recovery_probability | DECIMAL | AI-predicted recovery probability (0β1) |
confidence_score | DECIMAL | Model confidence in the prediction (0β1) |
customer_segment | VARCHAR | AI-assigned segment (loyal_payer, at_risk, etc.) |
recommended_strategy | VARCHAR | AI-recommended strategy |
status | VARCHAR | active, recovered, exhausted, stopped |
created_at | TIMESTAMP | Case creation time |
updated_at | TIMESTAMP | Last update time |
dunning_ai_actions
Tracks every AI-driven action taken during a dunning case.
| Column | Type | Description |
|---|---|---|
id | UUID | Primary key |
case_id | UUID | FK to dunning_ai_cases |
action_type | VARCHAR | retry, email, sms, whatsapp, offer, escalation |
channel | VARCHAR | Communication channel used |
scheduled_at | TIMESTAMP | When the action was scheduled |
executed_at | TIMESTAMP | When the action was executed |
status | VARCHAR | pending, executed, skipped, failed |
ai_reasoning | TEXT | Why the AI chose this action |
metadata | JSONB | Action-specific data (message content, offer details, etc.) |
dunning_ai_outcomes
Records the outcome of each action for model training.
| Column | Type | Description |
|---|---|---|
id | UUID | Primary key |
case_id | UUID | FK to dunning_ai_cases |
action_id | UUID | FK to dunning_ai_actions |
retry_time | TIMESTAMP | When retry was attempted |
retry_result | VARCHAR | success, failed, skipped |
communication_type | VARCHAR | Channel used |
communication_opened | BOOLEAN | Whether the message was opened |
communication_clicked | BOOLEAN | Whether the payment link was clicked |
payment_recovered | BOOLEAN | Whether payment was ultimately recovered |
recovery_amount | DECIMAL | Amount recovered |
recovery_latency_hours | INTEGER | Hours from dunning start to recovery |
dunning_ai_model_metrics
Tracks model performance over time.
| Column | Type | Description |
|---|---|---|
id | UUID | Primary key |
tenant_id | UUID | FK to tenant |
model_version | VARCHAR | Model version identifier |
metric_name | VARCHAR | accuracy, precision, recall, recovery_rate |
metric_value | DECIMAL | Metric value |
sample_size | INTEGER | Number of cases in evaluation |
evaluated_at | TIMESTAMP | When the metric was calculated |
Configuration
AI dunning is configured via Settings > Dunning > AI Settings in the BillHive dashboard.
AI Dunning Settings
| Setting | Options | Default | Description |
|---|---|---|---|
| Enable AI Dunning | On / Off | Off | Master toggle for AI-powered dunning |
| AI Mode | Full / Assist / Shadow | Shadow | Full: AI controls all decisions. Assist: AI recommends, human approves. Shadow: AI runs in parallel with rule-based for comparison. |
| LLM Provider | Claude / OpenAI | Claude | LLM used for communication generation |
| Max Discount Authority | 0β50% | 20% | Maximum discount the AI negotiation agent can offer |
| Discount Duration | 1β3 billing cycles | 1 cycle | How long an AI-offered discount applies |
| A/B Test Split | 0β100% | 50% | Percentage of dunning cases routed to AI vs rule-based |
| Churn Prevention | On / Off | Off | Enable predictive pre-dunning actions |
| Channels Enabled | Email, SMS, WhatsApp, In-App | Email, SMS | Which channels the AI can use |
AI Dunning Configuration API
GET /dunning-config/ai
Retrieve the AI dunning configuration for the tenant.
Response:
{
"enabled": false,
"mode": "shadow",
"llmProvider": "claude",
"negotiation": {
"maxDiscountPercent": 20,
"discountDurationCycles": 1
},
"abTestSplit": 50,
"churnPreventionEnabled": false,
"enabledChannels": ["email", "sms"]
}PUT /dunning-config/ai
Update the AI dunning configuration.
Validation rules:
| Field | Rule |
|---|---|
mode | full, assist, or shadow |
llmProvider | claude or openai |
negotiation.maxDiscountPercent | 0β50 |
negotiation.discountDurationCycles | 1β3 |
abTestSplit | 0β100 |
enabledChannels | Array containing one or more of: email, sms, whatsapp, in_app |
Rollout Strategy
AI dunning should be rolled out gradually to minimize risk and build confidence.
Phase 1: Shadow Mode (Weeks 1β4)
- AI runs alongside rule-based dunning but does not execute actions
- AI predictions and recommendations are logged for comparison
- Compare AI-recommended retry times vs actual retry results
- No customer impact
Phase 2: Assist Mode (Weeks 5β8)
- AI recommends actions; human reviews and approves
- Start with smart retry timing only (lowest risk)
- Add AI-generated communications after validating retry timing
- Measure recovery rate delta vs rule-based
Phase 3: Full Mode β Retry & Communication (Weeks 9β16)
- AI controls retry scheduling and message generation
- A/B test with 50% AI, 50% rule-based
- Track: recovery rate, time-to-recovery, customer satisfaction
- Expand to all enabled channels
Phase 4: Full Mode β Negotiation & Prevention (Week 17+)
- Enable AI negotiation agent for self-serve interactions
- Enable predictive churn prevention
- Expand A/B test to 80% AI
- Continuous model retraining on outcome data
Metrics & Reporting
AI Dunning Dashboard
| Metric | Description |
|---|---|
| AI Recovery Rate | % of AI-managed dunning cases that recovered payment |
| Rule-Based Recovery Rate | % of rule-based cases that recovered (for comparison) |
| Recovery Lift | Difference between AI and rule-based recovery rates |
| Average Recovery Time | Mean hours from failure to recovery |
| Revenue Recovered | Total revenue recovered by AI dunning |
| Churn Prevented | Subscriptions saved by AI intervention |
| Channel Performance | Recovery rate breakdown by communication channel |
| Model Accuracy | Prediction accuracy of the recovery model |
| Negotiation Success Rate | % of AI negotiations that resulted in payment |
| Discount Cost | Total revenue impact of AI-offered discounts |
Webhook Events
| Event | Trigger |
|---|---|
ai_dunning.prediction_made | Recovery probability calculated for a new case |
ai_dunning.strategy_selected | AI selected a dunning strategy |
ai_dunning.retry_optimized | AI scheduled an optimized retry time |
ai_dunning.message_generated | AI generated a personalized message |
ai_dunning.offer_made | AI negotiation agent made an offer |
ai_dunning.offer_accepted | Customer accepted an AI offer |
ai_dunning.recovered | AI dunning successfully recovered payment |
ai_dunning.exhausted | AI dunning exhausted all strategies |
Competitive Advantage
Most billing platforms still use rule-based dunning. BillHiveβs AI dunning positions the platform ahead of major competitors.
| Platform | Dunning Approach | AI Capabilities |
|---|---|---|
| Stripe | Basic retry rules, Smart Retries (ML timing only) | Limited to retry timing |
| Chargebee | Smart Dunning with ML retry optimization | ML retry timing, no personalized communication |
| Recurly | Revenue Optimization Engine | Statistical retry optimization |
| Zuora | Configurable retry rules | No ML/AI |
| BillHive | Full AI dunning engine | Predictive recovery, personalized communication, AI negotiation, churn prevention, self-learning |
Related Topics
- Dunning Overview β How BillHive dunning works today
- Configure Dunning β Rule-based dunning configuration
- Pending Features β Planned enhancements roadmap