import json from db import update_lead_status, get_leads, DB_PATH 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(DB_PATH) 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()