The Problem
A 60-rider last-mile courier company in Lahore was assigning deliveries by spreadsheet. every morning, two dispatchers sat with the day's orders and manually grouped them into rider routes. Customer notifications were sent by hand from a single SIM. Exception handling (failed delivery, address change, RTO requests) lived in a WhatsApp group with 80+ messages a day that everyone scrolled past.
Cost per delivery was creeping up. Customer complaints about late or missing deliveries were the #1 churn driver. The owner had spent two years quoting six-figure logistics platforms that promised the world and would have eaten his margin.
What I Built
A purpose-built automation stack that fit the company's actual workflow:
- Morning dispatch optimiser: a Python service using OR-Tools (Google's optimisation library) that ingests the day's orders + rider availability + zone constraints and generates optimal routes in under 90 seconds. Replaces 3 hours of dispatcher work.
- Rider mobile flow: Telegram bot that pushes each rider their daily route, accepts proof-of-delivery photos, and updates order status in real time.
- Customer comms layer: Twilio-driven SMS at three checkpoints (picked up, out for delivery, delivered) plus a WhatsApp template for failed-delivery rescheduling.
- Exception triage: a Claude-powered classifier reads incoming WhatsApp queries, extracts the order number, looks up status, and either auto-replies or escalates to the right human.
- 01TriggerDay's orders ingested
All inbound orders + rider availability + zone constraints loaded into the dispatch service each morning.
- 02StepOR-Tools generates routes
Optimisation library produces optimal multi-stop routes across the 60-rider fleet.
3 hours → 90 seconds - 03StepTelegram bot pushes to riders
Each rider receives their daily route, captures proof-of-delivery photos, and updates order status in real time.
- 04StepCustomer SMS at 3 checkpoints
Twilio fires picked-up, out-for-delivery, and delivered messages. Failed deliveries trigger a WhatsApp rescheduling template.
- 05DecisionException triage
Inbound WhatsApp queries classified by Claude: order lookup, status reply, or escalation to the right human.
- 06OutputDay closed in dashboard
Performance per rider and per zone surfaces for the next morning's planning. PKR 142 → PKR 98 cost per delivery.
Outcome
Within 6 months, the company absorbed a 40% volume increase with the same headcount, dropped one dispatcher position into customer service, and re-priced their B2B contracts more competitively because their unit economics had improved. The owner's main feedback: "I stopped opening the dispatch WhatsApp group at 7am."