I built this project to explore a simple lead-management workflow for small businesses. It accepts an inquiry, classifies the message using keyword rules, assigns a score, and stores the lead so its follow-up status can be tracked.
The API uses FastAPI and SQLite. The current intent classification and scoring are rule-based; there is no trained machine-learning model in this version.
- Receive a lead through
POST /webhook/lead. - Classify the message as
pricing,booking,support, orgeneral. - Calculate a simple lead score from the detected intent and the presence of the word "urgent".
- Store lead details, intent, score, source, and status in SQLite.
- List leads with
GET /leads. - Update a lead's follow-up status with
PATCH /leads/{lead_id}. - View lead counts and intent totals with
GET /summary. - Serve the browser interface at
/ui.
- Python
- FastAPI and Pydantic
- SQLite
- HTML, CSS, and JavaScript interface
On Windows PowerShell:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -r requirements.txt
uvicorn app.main:app --reload --port 8101Open:
- Interface: http://127.0.0.1:8101/ui
- API documentation: http://127.0.0.1:8101/docs
POST /webhook/lead
{
"name": "Aarav",
"phone": "+910000000000",
"message": "Need a booking this weekend",
"source": "whatsapp"
}The response includes the new lead ID, detected intent, score, and initial status.
- Intent detection uses keyword matching.
- Lead scores are fixed rule-based values, not calibrated probabilities.
- The API accepts a WhatsApp-style source label but does not connect to the WhatsApp Business API.
- Follow-up status values are currently accepted as strings without a strict allowed-value list.
- Tests and deployment have not been verified.
- Add input validation and explicit lead-status transitions.
- Add tests for intent classification and score calculation.
- Integrate a real messaging provider through its official API.
- Add authentication and role-based access before multi-user use.
Afzal Hussain · @Afzu01