Skip to content
← back to projects
2026·shipped·Sole developer

AI Lead Agent

Replies to every new lead within a minute, asks the qualifying questions, sends qualified leads the booking link and follows up until they book or opt out. The team can take over any conversation.

PythonFastAPIReactSQLAlchemyLLM tool calling
Lead agent dashboard: time to first reply, share of leads answered within a minute, and the pipeline by status, filled with demo data

Pipeline

1
Lead arrives
Form, webhook, SMS, email, Telegram
↓
2
Agent replies
One question at a time
↓
3
Code scores
Rules from a TOML profile
↓
4
Book or nurture
Link added by code
↓
5
CRM sync
HubSpot or GoHighLevel

Highlights

  • The model writes the replies; plain code scores the answers and decides the outcome, so qualification is predictable and testable.
  • Opt-out words are caught before the model sees the message, and follow-ups wait out quiet hours in the lead's time zone.
  • Lead messages are treated as data: the agent's only tools are recording answers and asking for a person, so it cannot book, cancel or quote prices.
  • Signed webhooks (HMAC-SHA256, Twilio signatures), no database transaction held open during a model call, and a holding reply if the model is down.

The problem#

Service businesses lose leads to whoever answers first. A form filled in at 9 pm usually waits until the next morning, and by then the lead has called a competitor. The agent replies in seconds and keeps the conversation going until the lead books or is politely closed.

How it decides#

The language model and plain code each do the part they are good at.

  • The model talks. It writes short replies in the business’s voice, answers questions from the business profile, and records the lead’s answers through a tool generated from that profile.
  • Code decides. A scoring module turns the recorded answers into an outcome: keep qualifying, qualified (booking link added), nurture, or not a fit. The outcome never depends on the model’s judgement.
  • One file per business. The description, rules (“never quote prices”), questions, scoring and follow-up schedule live in a TOML profile.

I chose this split over letting the model decide qualification because the business needs to know why a lead was or wasn’t sent the booking link, and tests need a fixed answer.

Risks and how they are handled#

RiskHandling
Messaging people who didn’t askConsent is required for form and webhook leads, and the consent wording is stored with each lead.
Ignoring “STOP”Opt-out words are caught before the model, confirmed once, and permanent.
Messages at 3 amFollow-ups wait for the end of quiet hours in the lead’s time zone, even after downtime.
Prompt injectionLead messages are data; the agent has no tool that books, cancels or quotes.
The model is downA holding reply goes out within seconds and the AI pauses for a person.

Status and limits#

This is a portfolio build for a fictional solar and roofing company, not a deployment with a paying client. Twilio SMS and GoHighLevel are tested against fakes only, because Twilio’s trial isn’t available in Ethiopia and GoHighLevel has no free plan. The dashboard numbers in the screenshot come from seeded demo data.

The 2-minute demo shows a lead qualified on Telegram, a person taking over, and a campaign bringing old leads back.

Write-ups