AI-powered lead management system for marketing agencies. Automatically responds to leads, follows up, and tracks engagement.
Auto-Response - Sends personalized email within seconds of lead submission
Lead Tracking - All leads saved to database with status updates
Dashboard - Real-time view of all leads and metrics
Interest Scoring - Track lead engagement (0-100 score)
Follow-up Ready - System prepared for automated follow-up sequences
lead-conversion-system/
βββ main.py # FastAPI app - webhook, API endpoints, dashboard
βββ requirements.txt # Python dependencies
βββ render.yaml # Render deployment config (web + worker)
βββ Procfile # Alternative deployment config
βββ .env.example # Environment variables template
β
βββ integrations/ # External service integrations
β βββ supabase_client.py # Database operations
β βββ email.py # Email sending (Resend)
β βββ sms.py # SMS sending (Twilio)
β
βββ agents/ # AI Agent system (LangGraph)
β βββ orchestrator.py # Routes leads to appropriate agents
β βββ speed_to_lead.py # First response agent
β βββ follow_up_engine.py # Follow-up sequence agent
β βββ database_reactivation.py # Dead lead reactivation
β βββ scoring.py # Interest score tracking
β βββ scheduler.py # Background job scheduler
β βββ __main__.py # Worker entry point
β
βββ dashboard/ # Frontend UI
β βββ crm-dashboard.html # Full CRM dashboard
β
βββ scripts/ # Utility scripts
β βββ setup_database.sql # Database schema
β βββ setup_test_client.py # Create test client
β
βββ supabase/
βββ schema.sql # Complete database schema
Service
Free Tier
Purpose
Render
750 hrs/mo
Python API hosting
Supabase
500MB
PostgreSQL database
Google Gemini
15 RPM
AI responses
Resend
100/day
Email sending
Twilio
$15 trial
SMS (optional)
Service
Key Name
Purpose
Supabase
SUPABASE_URL
Database connection
Supabase
SUPABASE_SERVICE_ROLE_KEY
Admin database access
Google Gemini
GEMINI_API_KEY
AI response generation
Resend
RESEND_API_KEY
Email sending
Twilio
TWILIO_ACCOUNT_SID
SMS (optional)
Twilio
TWILIO_AUTH_TOKEN
SMS auth (optional)
Twilio
TWILIO_PHONE_NUMBER
SMS from number (optional)
Endpoint
Method
Description
/webhook/new-lead
POST
Receive new lead β save + send email
/leads
GET
Get all leads
/leads/{id}/followup
POST
Manually trigger follow-up
Endpoint
Method
Description
/health
GET
Health check
/test-email
GET
Test email sending
/dashboard
GET
CRM dashboard UI
/
GET
Root page
π Webhook Payload Format
{
"client_id" : " YOUR_CLIENT_ID" ,
"name" : " John Doe" ,
"email" : " john@example.com" ,
"phone" : " +1234567890" ,
"source" : " website" ,
"message" : " I'm interested in your services"
}
client_id - Your client/agency ID (UUID)
name - Lead's name
email - Lead's email address
message - Lead's message
phone - Lead's phone number
source - Where lead came from (default: "website")
Column
Type
Description
id
UUID
Primary key
agency_name
TEXT
Agency name
email
TEXT
Contact email
config
JSONB
Settings
Column
Type
Description
id
UUID
Primary key
client_id
UUID
Foreign key to clients
name
TEXT
Lead's name
email
TEXT
Lead's email
phone
TEXT
Lead's phone
source
TEXT
Where lead came from
original_message
TEXT
Lead's message
status
TEXT
new, contacted, nurturing, dead, booked, won, lost
interest_score
INT
0-100 engagement score
follow_up_count
INT
Number of follow-ups sent
last_contact
TIMESTAMPTZ
Last interaction timestamp
created_at
TIMESTAMPTZ
Record creation time
updated_at
TIMESTAMPTZ
Last update time
Column
Type
Description
id
UUID
Primary key
lead_id
UUID
Foreign key to leads
role
TEXT
user, assistant
content
TEXT
Message content
channel
TEXT
email, sms, chat
strategy
TEXT
Follow-up strategy used
Column
Type
Description
id
UUID
Primary key
lead_id
UUID
Foreign key to leads
event_type
TEXT
Type of event
metadata
JSONB
Additional data
Push to GitHub
Connect repo to Render
Add environment variables
Deploy!
See deploy.md for detailed instructions.
00814277-181b-47a1-94e5-e04827edaa2f
curl -X POST https://lead-conversion-system.onrender.com/webhook/new-lead \
-H " Content-Type: application/json" \
-d ' {
"client_id": "00814277-181b-47a1-94e5-e04827edaa2f",
"name": "Test Lead",
"email": "test@example.com",
"message": "Hello!"
}'
1. Lead Submits Form
β
2. POST /webhook/new-lead
β
3. Lead Saved to Database (Supabase)
β
4. Status Updated: "new" β "contacted"
β
5. Auto-Email Sent (Resend)
β
6. Lead Appears in Dashboard
Check RESEND_API_KEY is set in Render environment
Check Resend dashboard for sent emails
Check spam folder
Verify database tables exist (run setup_database.sql)
Check RLS policies are disabled or allow inserts
Verify SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY are correct
Leads not showing in dashboard?
Refresh the page
Check browser console for errors
Verify /leads endpoint returns data
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LEAD CONVERSION SYSTEM β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β Webhook β β Chat β β Dashboard β β
β β (Leads) β β API β β UI β β
β ββββββββ¬βββββββ ββββββββ¬βββββββ ββββββββ¬βββββββ β
β β β β β
β βββββββββββββββββΌββββββββββββββββ β
β βΌ β
β βββββββββββββββββββββββ β
β β SUPABASE β β
β β (PostgreSQL) β β
β βββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
MIT License - Use freely!
β Star this repo if it helps you!