AI agent · Sales · 2026
AutomatizaLead
A WhatsApp sales agent that talks with AI but follows the business rules.
- Status
- Built, awaiting launch
- Context
- Client project · anonymized
- My role
- Built it on my own: requirements with the client, architecture, backend, AI agent, screens and tests.
- Stack
- Python
- FastAPI
- SQLAlchemy
- Alembic
- PostgreSQL
- WhatsApp Cloud API
- OpenRouter
- Pydantic
Overview
AutomatizaLead does the job of an SDR (sales development rep) on WhatsApp: it imports a list of companies, decides which ones are worth contacting, reaches out, holds the conversation, books the meeting and follows the deal until it closes. The client stays anonymous here.
Problem
Prospecting was manual and few messages turned into meetings. The gain wasn’t in sending more messages, but in talking to the right companies, replying quickly and never losing a meeting to a slow answer.
Approach
Before writing code, I wrote the rules with the client — ideal customer profile, conversation script, contact frequency, opt-out and scheduling — and the client approved them in writing. Then I built it in phases, each one delivering something that already worked.
How it works
Choosing companies
Imports the provider’s list, validates the data and scores each company, with the reason written down.
Outreach
Campaigns with A/B-tested messages that respect business hours and a daily sending limit.
AI agent
The AI reads the lead’s reply and picks the next step from the ones the system allows at that moment (a state machine). Before anything is sent, the code blocks prices, deadlines and legal opinions.
Scheduling and human handoff
The system offers three time slots and holds each one for 60 minutes. When the AI is unsure, the conversation goes to a person, with the reason and the draft.
- Data
- Code
- AI
- Person
- Outcome
- Company list (Data)Provider file
- Score and priority (Code)Editable rules
- Outreach (Code)WhatsApp, A/B test
- AI decision (AI)Allowed steps only
- Check (Code)Blocks what can’t be said
- Human handoff (Person)When the AI is unsure
- Meeting booked (Outcome)Slot offered by the system
Only one step is the AI. The rest is ordinary code that can be tested.
ALLOWED = {
"awaiting_reply": {"qualifying", "opted_out", "human"},
"qualifying": {"offering_slots", "human", "lost"},
"offering_slots": {"booked", "human"},
}
def apply_ai_decision(lead, decision):
# The AI proposes; the system decides.
if decision.next_state not in ALLOWED[lead.state]:
return hand_off(lead, reason="step_not_allowed")
# Prices, deadlines and legal advice are never sent.
if breaks_rules(decision.message):
return hand_off(lead, reason="rule", draft=decision.message)
return advance(lead, decision.next_state, decision.message)Key decisions
The system decides, the AI follows
The AI chooses from a list of allowed steps. It can’t invent steps, book meetings or write time slots.
Rules in code, not in the prompt
A prompt guarantees nothing. What must never be said is checked after the AI answers and before anything is sent.
When in doubt, a person
If the AI fails, answers in the wrong format or isn’t confident, the conversation goes to someone. No lead is left without an answer.
Result
Built and working in simulation mode, with nearly 400 automated tests. What’s missing doesn’t depend on the code: an approved official WhatsApp number, CRM access and the client’s legal sign-off.
What I took from it
In an AI project, most of the work isn’t the AI: it’s the rules, the permissions, the scheduling and what to do when something goes wrong.
Links
Private client project: no public demo or source code.