Case Study
AI Inbox Automation & Lead Routing Engine
A Python bot that monitors a shared inbox 24/7, classifies emails with AI, routes leads to sales via round-robin, and logs every decision to a spreadsheet.
Key Result
100% lead capture rate
The Challenge
Leads falling through the cracks in a shared inbox. Inconsistent triage, no routing logic, no audit trail
The Outcome
100% lead capture rate with automated classification, CRM integration, and equitable sales distribution
The inbox nobody wanted to manage
The client receives a steady stream of emails to a shared company inbox. Inquiries, quote requests, vendor promotions, newsletters, spam. All mixed together. Someone had to check it, sort through it, figure out who should handle each message, and try to respond before the lead went cold.
Things slipped through. A quote request would sit unread for two days. A lead would get forwarded to a salesperson who was already overloaded while another sat idle. Nobody tracked which salesperson received the last lead, so distribution was uneven. There was no audit trail. If a customer said “I emailed you last week,” nobody could quickly verify what happened.
Understanding the workflow before automating it
We started by mapping every type of email the inbox receives and every decision that gets made. When does a message need a human? When can it be handled automatically? What information needs to be captured from a lead? Who should receive it?
Only after documenting the complete decision tree did we design the system.
System Architecture
Ingest
Email arrives via API
Classify
AI categorizes by type
Route
Round-robin to sales
Draft
AI generates reply
Log
Every decision recorded
Alert
Slack notifies assignee
Ingest
Email arrives via API
Classify
AI categorizes by type
Route
Round-robin to sales
Draft
AI generates reply
Log
Every decision recorded
Alert
Slack notifies assignee
A six-stage pipeline
The bot runs a structured pipeline on every new email:
Fetch. Pull unread messages from the inbox via email API.
Pre-filter. Check sender against known lists. Internal emails from the company’s own domain are skipped automatically. Known marketing domains go straight to classification.
Classify. An AI classifier reads the email and categorizes it: spam, newsletter, lead, accounting inquiry, or uncertain. Each classification includes a confidence score. If confidence falls below 70%, the message is labeled for human review. The system never deletes something it is not sure about.
Act. Based on classification:
- Spam and newsletters get trashed on the next run
- Leads get a draft auto-reply (short, uses the sender’s first name) and are assigned to a salesperson via round-robin
- Accounting inquiries get labeled and left for manual handling
- Uncertain messages get flagged for human review
Log. Every email, every classification, every action is logged to a shared spreadsheet. Complete audit trail.
Cleanup. Processed messages are archived. The inbox stays clean.
Round-robin that actually works
Lead routing was a key requirement. The client has a distributed sales team across multiple roles. The round-robin system distributes leads equitably:
- Default leads rotate through the inside sales pool, with field sales CC’d for visibility
- Multilingual leads route to the appropriate language-matched pool
- Technical RFQs route to the engineering team with field sales CC’d
- The round-robin state persists between runs. It does not reset
The system also checks whether a salesperson is already participating in the email thread. If someone already replied, the bot skips that thread instead of creating a duplicate assignment.
CRM integration
Every qualified lead automatically creates a CRM record. The system checks by email address first. No duplicates. Lead source, initial message, and assigned salesperson are all captured.
Draft replies, not autonomous sends
A critical design decision: the bot drafts replies but does not send them. Every auto-reply sits in the drafts folder for human review before going out. This gives the sales team control over what the customer actually sees, while still generating a response within minutes instead of hours.
Results
Zero missed leads. Every inquiry gets classified, routed, and logged. Nothing sits unread for days.
Equitable distribution. Round-robin ensures no salesperson is overloaded while another sits idle. Persistent state means the rotation is truly even over time.
Complete audit trail. Every email, action, and routing decision is logged. “Did we respond to that customer?” is now a searchable question.
Multilingual support. Non-English leads automatically route to language-matched salespeople. No manual detection required.
Human in the loop. Draft replies preserve human oversight. The AI handles triage and routing; humans handle relationships.
Engagement model: built, deployed, running. We built the bot, deployed it to the client’s environment, and it processes emails daily in production. The client owns and operates the system.