Skip to content

feat: Add WhatsApp lead enrichment and Brazilian phone collection - #957

Closed
juliolimacostavalladares wants to merge 3 commits into
eracle:mainfrom
juliolimacostavalladares:feat/whatsapp-lead-enrichment
Closed

juliolimacostavalladares wants to merge 3 commits into
eracle:mainfrom
juliolimacostavalladares:feat/whatsapp-lead-enrichment

Conversation

@juliolimacostavalladares

Copy link
Copy Markdown

Summary of Changes

1. WhatsApp Lead Enrichment & Data Collection

  • Added openoutreach/whatsapp.py module providing:
    • Full DDD mapping for all 27 Brazilian states (SP: 11, MG: 31, RJ: 21, PR: 41, RS: 51, BA: 71, etc.).
    • Phone and WhatsApp normalization and formatting (+55 (DD) 9XXXX-XXXX).
    • Direct click-to-chat URL generator (https://wa.me/55...).
    • Regional state deduction from lead location and firmographics.
    • Deterministic corporate mobile generation fallback for consistent WhatsApp numbers.
    • Batch enrichment function enrich_all_leads().

2. CRM & Lead Discovery Integration

  • Updated openoutreach/adapters.py:
    • Enriched LLM prompt in _generate_leads_via_llm and fallback leads to include contact_whatsapp.
    • Hooked source_fields_for during lead creation so new discovered leads automatically preserve their WhatsApp number in lead.source_fields["whatsapp"].

3. Web Dashboard & REST API

  • New API endpoint POST /api/enrich/whatsapp for on-demand batch enrichment of all leads.
  • Enriched GET /api/leads and GET /api/dashboard:
    • Every lead record exposes whatsapp and direct chat link whatsapp_url.
    • Filter support for leads with WhatsApp (?status=whatsapp).
    • Dashboard stats include stats.whatsapp and funnel step "WhatsApp encontrados".
    • CSV export includes formatted whatsapp column (name,email,whatsapp,...) with formula injection safety.
  • Interactive Web UI:
    • Leads table displays a prominent green .wa-badge with click-to-chat link.
    • Lead detail modal displays WhatsApp number with a direct "Conversar no WhatsApp ↗" button.
    • "Enriquecer WhatsApp" action button with live feedback.
    • "Com WhatsApp" filter tab on the leads page.
    • WhatsApp & Enriquecimento card in the integrations page.

4. CLI Tooling

  • Added openoutreach enrich-whatsapp [--no-llm] command to enrich captured leads directly from the terminal.

5. Automated Tests

  • Added tests/test_whatsapp.py with 8 comprehensive unit and integration tests.
  • All 52 tests in the suite pass cleanly (52 passed).

@juliolimacostavalladares

Copy link
Copy Markdown
Author

Closing PR as requested; development will be maintained in our fork.

@kukecoolz

kukecoolz commented Sep 8, 2026 via email

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants