Skip to main content

Reinforcement-Learned Retry Timing

Smart Retry uses reinforcement learning to optimize when failed payments are retried. Instead of using static retry schedules, Recurso learns from every payment attempt to find the optimal retry timing for each customer context. Traditional dunning retries payments on fixed intervals regardless of context. Smart Retry considers:
  • Payment method (card, UPI, bank transfer)
  • Failure reason (insufficient funds, expired card, network error)
  • Invoice amount (small, medium, large, enterprise)
  • Customer tenure (new, established, veteran)
  • Day of week and currency
Smart Retry works alongside Dunning Campaigns to handle the retry timing, while campaigns manage customer communication.

How It Works

Bandit Algorithms

Smart Retry implements three multi-armed bandit algorithms. Each treats retry intervals as “arms” and learns which interval works best for a given context.

Algorithm Comparison

Epsilon-Greedy (Default)

The default algorithm uses epsilon-greedy with a decaying exploration rate:
  • Base epsilon: 0.1 (10% exploration)
  • Decay formula: epsilon / (1 + 0.001 * totalDecisions)
  • Early on, the system explores more; as it gathers data, it increasingly exploits the best-known strategy
Epsilon-greedy is the recommended starting algorithm. It balances exploration and exploitation well for most payment volumes.

Thompson Sampling

Uses Bayesian probability distributions to model uncertainty. Actions with less data have wider distributions, naturally encouraging exploration where knowledge is limited.

UCB1 (Upper Confidence Bound)

Selects the action with the highest upper confidence bound, calculated as:
Actions tried fewer times get a larger confidence bonus, ensuring underexplored intervals are tested.

Context Keys

Every retry decision is made within a context. The context key captures the relevant dimensions of a payment situation:

Context Dimensions

Amount Buckets

Customer Age Categories

Example context key:
This represents a failed card payment in USD for a medium-sized invoice (1010-100), on a Wednesday, from an established customer, due to insufficient funds.

Retry Actions

Smart Retry selects from four possible retry intervals (dunning actions):
Each invoice is limited to a maximum of 10 retry attempts. After 10 failed retries, the invoice transitions to a terminal failed state and requires manual intervention.

Outcome Tracking

Every retry outcome is recorded and used to update the algorithm’s weights.

Weight Updates

Weights are updated using an incremental averaging formula:
  • Reward = 1.0 for successful payment
  • Reward = 0.0 for failed payment
Each weight record tracks:
Weights are cached with a 5-minute TTL for performance. Changes from recent outcomes may take up to 5 minutes to influence new retry decisions.

API Reference

View Dunning Overview

Retrieve high-level analytics for your smart retry performance.

View Dunning Weights

Inspect the learned weights for specific contexts.

How the System Learns

1

Payment fails

A subscription payment attempt fails. The system captures the failure context: currency, error code, payment method, amount bucket, day of week, and customer age.
2

Context key is built

The dimensions are combined into a context key like INR:insufficient_funds:upi:small:5:new.
3

Algorithm selects action

The configured bandit algorithm looks up weights for this context key and selects a retry interval. With epsilon-greedy, it picks the best-known interval 90% of the time and explores a random interval 10% of the time.
4

Retry is scheduled

The payment retry is scheduled according to the selected interval (1h, 24h, 3d, or 7d).
5

Outcome is recorded

After the retry attempt, the result is recorded as a DunningHistory entry with a reward of 1.0 (success) or 0.0 (failure).
6

Weights are updated

The incremental average formula updates the weight for the context-action pair, improving future decisions.

Webhooks

Integration with Dunning Campaigns

Smart Retry handles the when to retry, while Dunning Campaigns handle what to communicate. They work together:

Best Practices

Start with Epsilon-Greedy

The default algorithm works well for most payment volumes and converges to good strategies quickly.

Let It Learn

Allow at least 500-1000 retry attempts before evaluating algorithm performance. Early results will be noisy.

Monitor Recovery Rates

Check the dunning overview regularly to track recovery rates by context and identify underperforming segments.

Combine with Campaigns

Pair smart retry with dunning campaigns for both automated retries and customer communication.
Fixed schedules ignore context. A network error might resolve in minutes, while insufficient funds might need days. Smart Retry adapts to each situation, increasing recovery rates by 15-30% compared to static schedules.
The system begins making informed decisions after approximately 100 retry attempts per context key. With the exploration mechanism, it continues to improve over time even as payment patterns change.
Yes. If a customer updates their payment method, you can trigger an immediate retry through the invoice API regardless of the smart retry schedule.
When a context key has no historical data, the algorithm explores uniformly across all retry intervals. As outcomes are recorded, it quickly converges on the best strategy for that context.

Next steps

Dunning campaigns

The messaging side of recovery

Set up dunning

Configure retries and emails together