Files
lead-engine-mvp/enrich.py
2026-01-30 11:00:44 +00:00

44 lines
1.3 KiB
Python

import json
from db import update_lead_status, get_leads
import sqlite3
def enrich_lead(lead):
# Mock Enrichment Logic
# In production, this would call the Company Explorer API
enrichment = {
'vertical': 'Unknown',
'score': 0,
'recommendation': 'Manual Review'
}
company = lead['company_name'].lower()
raw = lead['raw_body']
if 'küche' in company or 'einbau' in company:
enrichment['vertical'] = 'Manufacturing / Woodworking'
enrichment['score'] = 85
enrichment['recommendation'] = 'High Priority - Pitch Dust Control'
if 'shop' in company or 'roller' in company:
enrichment['vertical'] = 'Retail / Automotive'
enrichment['score'] = 60
enrichment['recommendation'] = 'Medium Priority - Pitch Showroom Cleanliness'
# Update DB
conn = sqlite3.connect('lead-engine/data/leads.db')
c = conn.cursor()
c.execute('UPDATE leads SET enrichment_data = ?, status = ? WHERE id = ?',
(json.dumps(enrichment), 'enriched', lead['id']))
conn.commit()
conn.close()
def run_enrichment():
leads = get_leads()
for lead in leads:
if lead['status'] == 'new':
enrich_lead(lead)
if __name__ == "__main__":
run_enrichment()