← Back to Blog
AI & Automation May 5, 2026 1 min read 4 views

Using GPT-4 to Automate Lead Qualification in Django

# Using GPT-4 to Automate Lead Qualification in Django My client's agency was drowning in leads — 200/day, most of which were garbage. The sales team was spending 3 hours every morning manually sorting them. I built an AI pipeline to fix that. ## The Architecture ``` Lead submitted → Django view → Celery task → GPT-4 scoring → CRM update → Alert if high-value ``` ## The Scoring Task ```python @shared_task def qualify_lead(lead_id): lead = Lead.objects.get(pk=lead_id) prompt = f""" Score this lead 0-100 and categorise as HOT/WARM/COLD. Name: {lead.name} Message: {lead.message} Package interest: {lead.package} Respond with JSON: {{"score": 85, "category": "HOT", "reason": "..."}} """ response = openai.chat.completions.create( model="gpt-4", messages=[{"role": "user", "content": prompt}], response_format={"type": "json_object"} ) data = json.loads(response.choices[0].message.content) lead.notes = f"AI Score: {data['score']} ({data['category']}) — {data['reason']}" lead.save() ``` ## Results After 30 Days - Manual review time: 3hrs → 20min/day - Conversion rate: 8% → 23% - Revenue attributed: +$12,000/month

Have a project in mind?

Let's build something together.

💬 Get In Touch