
The problem
Win-back campaigns are the throughput-limited side of customer retention. The marketing team has a fixed weekly capacity for outreach emails, calls, or discount offers. The question is always: of the thousand lapsed or lapsing customers, which 100 should we focus on this week to maximise recovered revenue?
Most teams answer this by sorting on recency (most-recently-lapsed first) or on historical value (highest-spending customers first). Both are partial answers. The better answer is the conditional probability that outreach succeeds × the expected revenue if it does — the predicted recoverable revenue. Sorting by that puts the highest-leverage cases at the top.
How it works
Three predictions compose. The demo's Retention view lists the active customers Aito rates more likely than not to stop ordering, the most spend at stake first. For each, _recommend over past win-back emails picks candidate products for the customer's own pets, _predict responded gives the calibrated chance they order after that email, and _estimate the order value if they do; the offer is the product with the highest chance × value minus the €0.50 email cost. Beside it, each of the shop's actions is scored with _predict purchased_30d against doing nothing in the same context, times the estimated order value, net of its cost.
The system updates as the campaign runs. Every send and its outcome become rows, so the next prediction for similar customers reflects them without a retraining step. Mature deployments track per-cohort ROI: which segments respond best to which outreach type.
{
"from": "winback_campaigns",
"where": {
"customer_id": "CUST-02011",
"customer_staple_category": "aquarium/aquarium",
"recency_bucket": "0-90d",
"product_sku.pet_type": {
"$or": [
"aquarium"
]
}
},
"recommend": "product_sku",
"goal": {
"responded": true
},
"limit": 3
}For the full architecture, see the technology overview. For the broader narrative across multiple use cases, read The Predictive Application. For the whole picture, see predictive e-commerce.
See it live
This use case runs in the 🛒 E-commerce demo today. Click through to the live application and inspect the queries that produce the result.
Build it with Claude Code
Paste this prompt into Claude Code, or another coding agent, in your own codebase. It runs Aito locally from the Docker image, reads the API docs written for agents, and follows a working reference implementation.
Add win-back ranking to this codebase using Aito, a predictive database. The feature: rank our customers who are likely to stop ordering by the spend at stake, each with the offer most likely to bring them back after its cost, from our orders and past win-back campaigns. 1. Run Aito locally: `docker pull ghcr.io/aitohq/aito`, then follow https://aito.ai/docker/ to start it with your own API keys (keep them in the environment, never in code). 2. Read https://aito.ai/docs/api/llms.txt for the v2 query shapes before writing any query. 3. Read the use-case guide: https://aito.ai/use-cases/win-back-ranking/ 4. Use this reference implementation as the pattern (schema, data load and queries): https://github.com/AitoDotAI/aito-ecommerce-demo/blob/main/src/retention_service.py and https://github.com/AitoDotAI/aito-ecommerce-demo/blob/main/src/churn_risk.py and https://github.com/AitoDotAI/aito-ecommerce-demo/blob/main/src/winback_offer.py 5. Find the matching tables in this codebase, design the Aito schema for them (links between tables where we have foreign keys), and load a sample. 6. Measure before wiring the UI: hold out recent rows and report how often the item actually chosen is in the top 3, against the order we show today. 7. In the UI, show the ranking as suggestions, with the reasons where the query gives them. Nothing is applied without the user. Ask me before changing anything outside the new feature.
Frequently asked
How is this different from churn-ranked outreach?
Churn-ranked outreach decides who to reach; win-back ranking decides what to send them and what it is worth. In the demo both sit on the Retention view: the at-risk list is the churn ranking, and each row's action is the win-back offer. For customers who have already lapsed, the same queries run with a later recency bucket.
What defines "lapsed" for this prediction?
Application-level decision based on the typical purchase cadence. The demo counts a customer as gone after 90 days without an order, and scores the risk that an order is the last for three months. For SaaS, account-cancellation or downgrade. The prediction works on any binary outcome once the team defines it.
Does this work for win-back from cancelled subscriptions?
Yes. Replace "will_return" with "will_reactivate"; the conditional probability is the same shape. Predict reactivation probability conditioned on the reason for cancellation, the time since cancellation, and the customer's pre-cancellation patterns.
Can the system recommend the optimal win-back offer per customer?
Yes. The demo scores each of the shop's actions (email, 10 % discount, €5 and €10 vouchers, personalised ad, apology and €5 credit) with _predict purchased_30d in the customer's context, against doing nothing, and ranks them by what they add after their cost. Different customers get different best actions: in the demo's data, 12 of the 20 listed customers get a personalised ad and 3 a €10 voucher.
How does this handle customers who lapsed for service or quality reasons?
If the lapse cause is in the data (support tickets, returns, NPS scores), the prediction conditions on it; the demo's action context includes an open issue such as a late delivery or a low rating. Customers who lapsed due to product issues may respond better to product-update outreach, and those who lapsed due to price to discount offers. The conditional probability captures this when the signal is available.


