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.

AspectRule-Based DunningAI-Powered Dunning
Retry timingFixed intervals (Day 1, 3, 5, 7…)Predicted optimal window per customer
CommunicationSame email template for allPersonalized tone, channel, and content
Final actionSame for all customersRisk-scored: retain high-value, cancel low-engagement
Recovery rate30–50% industry average50–70% with AI optimization
LearningStatic rules, manual tuningContinuously 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:

FeatureSourceWhy It Matters
payment_method_typeSubscriptionCard vs mandate vs wallet recovery rates differ
issuer_bankPayment gatewaySome banks have higher decline rates
card_typePayment gatewayCredit cards recover better than debit
failure_reasonGateway error codeInsufficient funds vs expired card have different recovery paths
previous_failure_countDunning historyRepeat failures predict lower recovery
customer_lifetime_valueBilling dataHigh-CLV customers are more likely to recover
subscription_amountSubscriptionLower amounts recover more easily
customer_countryAccountRegional payment behavior patterns
account_ageAccountOlder accounts have higher loyalty
days_since_last_loginProduct usageActive 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 ProbabilityStrategy
> 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 PatternAI Action
Salary credited on 1st of monthRetry on 2nd
Bank declines after 10 PMRetry at 10 AM
Weekend payments always failRetry on Monday
Previous success after 48 hoursWait 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:

InputEffect on Message
Customer segment (enterprise, SMB, consumer)Formal vs casual tone
Failure reasonSpecific guidance (e.g., β€œyour card expired” vs β€œinsufficient funds”)
Invoice amountUrgency calibration
Account age and CLVLoyalty acknowledgment
Previous dunning interactionsAvoid repeating the same message
Dunning stageEscalating 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:

SignalWeightInterpretation
Login frequency (last 30 days)HighActive users want to keep their subscription
Feature usage depthHighDeep usage = high switching cost
Support ticket historyMediumRecent tickets may indicate dissatisfaction
Account ageMediumLonger tenure = higher recovery likelihood
Payment historyHighHistory of on-time payments = likely temporary issue
Team size / seats usedMediumMore users = harder to churn

Risk-based dunning actions:

Customer Risk ProfileDunning Strategy
High-value, high-engagementExtended grace period, personal outreach from CSM, offer payment plan
High-value, low-engagementEscalate to manual review, proactive CSM call
Medium-value, high-engagementStandard dunning with friendly tone, offer temporary discount
Medium-value, low-engagementAccelerated dunning, shorter grace period
Low-value, low-engagementStandard 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:

SignalChannel Decision
High email open rateContinue with email
Low email open rate, high SMS click rateSwitch to SMS
WhatsApp business account linkedUse WhatsApp for reminders
Enterprise account with Slack integrationSend in-app notification via Slack
No engagement on any channelEscalate 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:

ScenarioAI 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 DetectedAI 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 XRoute payments through alternate gateway
Spike in failures every month-endStagger billing dates across the month
High failure rate for annual plansOffer 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:

SegmentCharacteristicsDunning Strategy
Loyal PayersLong tenure, rarely fails, high CLVGentle reminder, extended grace, never cancel without manual review
Occasional DefaultersModerate tenure, fails 1–2x per yearStandard dunning, payment update nudge
Chronic DefaultersFrequent failures, often recovers lateAggressive retry, shorter grace period, require backup payment method
At-Risk ChurnersDeclining usage, recent failuresProactive outreach, retention offer, CSM escalation
New Customers< 3 months, first failureExtra-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 improve

Metrics tracked per strategy:

MetricPurpose
Recovery rate by retry timeOptimize retry scheduling
Recovery rate by message toneOptimize communication style
Recovery rate by channelOptimize channel selection
Recovery rate by offer typeOptimize negotiation strategy
Time to recovery by segmentOptimize 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:

SignalPreventive Action
Card expires within 30 daysSend proactive card update reminder
Customer’s payment amount increased significantlySend advance notice of upcoming charge
Customer usage dropped 50%+ this monthProactive retention outreach before next billing
Bank associated with high decline ratesPre-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 ServiceAI Dunning Integration
subscription-serviceSubscription status, plan details, usage data
billing-serviceInvoice data, payment history, CLV calculation
payment-serviceGateway error codes, retry execution, payment method data
notification-serviceAI-generated message delivery across channels
camunda-setupDeploys the Camunda BPMN/DMN definitions (with AI decision points) on startup
reporting-serviceDunning analytics, recovery metrics, A/B test results
facadeAPI gateway for AI dunning configuration and status

Job Queues (BullMQ)

QueuePurpose
ai-dunning-predictionRun recovery prediction model on new dunning cases
ai-retry-schedulerSchedule optimized retry times
ai-communication-generatorGenerate personalized dunning messages via LLM
ai-dunning-outcomeRecord outcomes and trigger model retraining
ai-churn-preventionProcess pre-dunning preventive actions

Database Schema

dunning_ai_cases

Extends the base dunning case with AI-specific data.

ColumnTypeDescription
idUUIDPrimary key
invoice_idUUIDFK to invoice
customer_idUUIDFK to account
tenant_idUUIDFK to tenant
failure_reasonVARCHARGateway failure reason code
recovery_probabilityDECIMALAI-predicted recovery probability (0–1)
confidence_scoreDECIMALModel confidence in the prediction (0–1)
customer_segmentVARCHARAI-assigned segment (loyal_payer, at_risk, etc.)
recommended_strategyVARCHARAI-recommended strategy
statusVARCHARactive, recovered, exhausted, stopped
created_atTIMESTAMPCase creation time
updated_atTIMESTAMPLast update time

dunning_ai_actions

Tracks every AI-driven action taken during a dunning case.

ColumnTypeDescription
idUUIDPrimary key
case_idUUIDFK to dunning_ai_cases
action_typeVARCHARretry, email, sms, whatsapp, offer, escalation
channelVARCHARCommunication channel used
scheduled_atTIMESTAMPWhen the action was scheduled
executed_atTIMESTAMPWhen the action was executed
statusVARCHARpending, executed, skipped, failed
ai_reasoningTEXTWhy the AI chose this action
metadataJSONBAction-specific data (message content, offer details, etc.)

dunning_ai_outcomes

Records the outcome of each action for model training.

ColumnTypeDescription
idUUIDPrimary key
case_idUUIDFK to dunning_ai_cases
action_idUUIDFK to dunning_ai_actions
retry_timeTIMESTAMPWhen retry was attempted
retry_resultVARCHARsuccess, failed, skipped
communication_typeVARCHARChannel used
communication_openedBOOLEANWhether the message was opened
communication_clickedBOOLEANWhether the payment link was clicked
payment_recoveredBOOLEANWhether payment was ultimately recovered
recovery_amountDECIMALAmount recovered
recovery_latency_hoursINTEGERHours from dunning start to recovery

dunning_ai_model_metrics

Tracks model performance over time.

ColumnTypeDescription
idUUIDPrimary key
tenant_idUUIDFK to tenant
model_versionVARCHARModel version identifier
metric_nameVARCHARaccuracy, precision, recall, recovery_rate
metric_valueDECIMALMetric value
sample_sizeINTEGERNumber of cases in evaluation
evaluated_atTIMESTAMPWhen the metric was calculated

Configuration

AI dunning is configured via Settings > Dunning > AI Settings in the BillHive dashboard.

AI Dunning Settings

SettingOptionsDefaultDescription
Enable AI DunningOn / OffOffMaster toggle for AI-powered dunning
AI ModeFull / Assist / ShadowShadowFull: AI controls all decisions. Assist: AI recommends, human approves. Shadow: AI runs in parallel with rule-based for comparison.
LLM ProviderClaude / OpenAIClaudeLLM used for communication generation
Max Discount Authority0–50%20%Maximum discount the AI negotiation agent can offer
Discount Duration1–3 billing cycles1 cycleHow long an AI-offered discount applies
A/B Test Split0–100%50%Percentage of dunning cases routed to AI vs rule-based
Churn PreventionOn / OffOffEnable predictive pre-dunning actions
Channels EnabledEmail, SMS, WhatsApp, In-AppEmail, SMSWhich 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:

FieldRule
modefull, assist, or shadow
llmProviderclaude or openai
negotiation.maxDiscountPercent0–50
negotiation.discountDurationCycles1–3
abTestSplit0–100
enabledChannelsArray 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

MetricDescription
AI Recovery Rate% of AI-managed dunning cases that recovered payment
Rule-Based Recovery Rate% of rule-based cases that recovered (for comparison)
Recovery LiftDifference between AI and rule-based recovery rates
Average Recovery TimeMean hours from failure to recovery
Revenue RecoveredTotal revenue recovered by AI dunning
Churn PreventedSubscriptions saved by AI intervention
Channel PerformanceRecovery rate breakdown by communication channel
Model AccuracyPrediction accuracy of the recovery model
Negotiation Success Rate% of AI negotiations that resulted in payment
Discount CostTotal revenue impact of AI-offered discounts

Webhook Events

EventTrigger
ai_dunning.prediction_madeRecovery probability calculated for a new case
ai_dunning.strategy_selectedAI selected a dunning strategy
ai_dunning.retry_optimizedAI scheduled an optimized retry time
ai_dunning.message_generatedAI generated a personalized message
ai_dunning.offer_madeAI negotiation agent made an offer
ai_dunning.offer_acceptedCustomer accepted an AI offer
ai_dunning.recoveredAI dunning successfully recovered payment
ai_dunning.exhaustedAI 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.

PlatformDunning ApproachAI Capabilities
StripeBasic retry rules, Smart Retries (ML timing only)Limited to retry timing
ChargebeeSmart Dunning with ML retry optimizationML retry timing, no personalized communication
RecurlyRevenue Optimization EngineStatistical retry optimization
ZuoraConfigurable retry rulesNo ML/AI
BillHiveFull AI dunning enginePredictive recovery, personalized communication, AI negotiation, churn prevention, self-learning