Problem: AI projects often start with whatever task looks most interesting, and nobody can later say whether the business earned anything from them. Result of this article: a small script that takes one week of funnel counts, finds the step where the most people drop out and estimates what that drop costs per month. Stack: plain Python 3.10+ (tested on 3.15.2), no external packages. Boundaries: the numbers in the example are invented for teaching; the script estimates, it does not forecast, and it assumes the leaking step is fixable
Where this comes from
One clinic I helped with process design and automation was losing customers after its ads. People wrote in, but nobody processed their messages quickly, so many never reached a booking. The ads were working; the loss was one step later. I started with incoming requests, then we built a reception bot that answers instantly in every channel, takes people to a booking and reserves time in the clinic's calendar. That started bringing in money straight away
Today the clinic runs a team of 6 agents on the owner's server. The client chatbot covers about 114 price items and 48 services and answers only from the clinic's documents. All of it grew from that first step: finding the leak
The script below is a teaching version of the counting that comes before any of that. It is not code from the clinic's system
Input, processing, output
Input: counts for one ordinary week at five steps (requests, replied, booked, visited, paid) and an average order value
Processing: for each pair of neighbouring steps, the script computes how many people were lost and what share that is. It picks the step with the most people lost. To price that step it takes the people who did get through it, checks what share of them eventually paid, applies that share to the lost people and multiplies by the average order and four weeks
Output: one line per step with counts and losses, the biggest drop, and its estimated monthly cost
The pricing choice matters. Using the share of payers among people who passed the leaking step, rather than among people who booked, avoids pretending that everyone lost at the first reply would have booked
The example
from dataclasses import dataclass
@dataclass
class Week:
requests: int
replied: int
booked: int
visited: int
paid: int
STEPS = ["requests", "replied", "booked", "visited", "paid"]
def drops(w: Week):
counts = [getattr(w, s) for s in STEPS]
out = []
for (a, b), (na, nb) in zip(zip(STEPS, STEPS[1:]), zip(counts, counts[1:])):
lost = na - nb
out.append((f"{a} -> {b}", na, nb, lost, lost / na if na else 0.0))
return out
def monthly_loss(lost_per_week: int, passed: int, w: Week, avg_order: float) -> float:
# of the people who did pass the leaking step, this share went on to pay
after = w.paid / passed if passed else 0.0
return lost_per_week * after * avg_order * 4
if __name__ == "__main__":
week = Week(requests=50, replied=28, booked=20, visited=17, paid=15)
rows = drops(week)
for step, a, b, lost, share in rows:
print(f"{step:20} {a:3} -> {b:3} lost {lost:3} ({share:.0%})")
worst = max(rows, key=lambda r: r[3])
print("biggest drop:", worst[0])
print(f"cost of that drop: {monthly_loss(worst[3], worst[2], week, 120.0):.0f} per month at average order 120")
Output, exactly as it printed when I ran it:
requests -> replied 50 -> 28 lost 22 (44%)
replied -> booked 28 -> 20 lost 8 (29%)
booked -> visited 20 -> 17 lost 3 (15%)
visited -> paid 17 -> 15 lost 2 (12%)
biggest drop: requests -> replied
cost of that drop: 5657 per month at average order 120
Reading the result
In the invented week, the reply step loses 22 of 50 people. Every later step loses fewer. That makes a fast first reply the obvious first automation, and the monthly estimate gives a ceiling for what is worth spending on it
This is the same pattern the clinic showed: plenty of requests, a large gap before the first reply, and a business that could not see where the rest went
Design notes
Count, do not estimate. The input must come from real conversations, the call log and the calendar for one ordinary week. Gut feeling almost always underestimates losses, because a lost customer is invisible
Rank by people lost, then sanity check by share. A step that loses few people at a high percentage can matter more when traffic grows; keep both numbers in the output
Map symptoms to the cheapest fix. Slow replies call for a fast first response and contact capture. Requests lost between channels call for one inbox. Bookings that do not turn up call for reminders. A bot that answers from the business's documents and takes people to a booking takes me about 2–3 weeks to build, including testing on real client questions
Repeat the count after launch. The same script on a week after the change tells you whether the drop shrank. If it did not, the leak was somewhere else
Errors and trade-offs
Missing data is a finding. If you cannot count one of the steps at all, nobody is watching that part of the funnel, and that is the first thing to fix
Not every leak is an automation problem. Losses after the visit are about service and price. Few requests at the top is about marketing. The script will still flag them; your job is to recognise when a bot will not help
Weekly noise is real. One unusual week can move the biggest drop. Count two weeks if the business is seasonal
How to reproduce the check
- Save the example as
funnel.py - Run
python3 funnel.pywith Python 3.10 or newer - Compare the output with the block above
- Replace the counts in
Week(...)and the average order with one week of your own data and run it again
For the business side of the same idea, including the questions that find the gap, see AI implementation: start with lost revenue
This article was created with the help of AI.



Top comments (0)