Transforming email data into sales velocity — value delivered for JuxtMedia Sales Agent
Six features across 4 PRs + 1 hotfix — surfacing Gmail email activity data throughout the entire dashboard, transforming it from a daily briefing-only feature into a real-time sales velocity tool.
| Capability | Before | After |
|---|---|---|
| Lead Prioritization | Sort by score (static, never changes) | Sort by last activity (dynamic, real-time) |
| Email Visibility | Morning briefing only (daily) | Real-time on every lead + contacts view |
| Engagement Indicators | None | Color-coded badges on leads + contacts |
| Email Context | Switch to Gmail manually | Full email bodies with threaded history on lead detail page |
| Contact Overview | Per-lead only, no cross-lead view | Standalone cross-lead contacts view |
| Pipeline Automation | Manual stage changes only | Inbound email triggers stage suggestions |
| Briefing Accuracy | Missed early-stage email matches | All active stages tracked correctly |
The Leads table now surfaces real-time engagement signals. The most active leads automatically appear first, with email count badges showing engagement volume at a glance.
"Imported" column → "Last Activity" — Computed from the most recent timestamp across email activity, stage changes, research completions, and lead updates using SQL GREATEST() aggregation.
Email Count Badges — Green (1-5 emails), amber (6+ emails), hidden (0 emails). Visible next to every company name.
Default Sort — Changed from score DESC to last_activity DESC. Most active leads surface automatically.
Full email conversation history right on the lead page. No more switching to Gmail to review relationship context before outreach.
Email Activity Section — Collapsible section between Contacts and Research Findings on every lead detail page.
Full Email Bodies — Complete plain-text email content with per-email "Show full email" / "Show less" expand/collapse. Full subject lines displayed without truncation.
Thread Grouping — Emails grouped by thread_id, threads sorted newest-first, emails within threads sorted oldest-first (conversation order).
Direction Badges — Blue "Outbound" with arrow-right, purple "Inbound" with arrow-left.
State Persistence — Expand/collapse preference saved to localStorage, survives page refreshes.
Hotfix (Issue #19) — Gmail API initially fetched metadata-only (200-char snippets). Upgraded to full message fetch with recursive MIME body extraction. Backfilled 40/44 existing emails with complete content.
A unified view of all contacts across all leads with email traffic volume indicators. See who's actively communicating and who's gone quiet — without drilling into individual leads.
New /contacts Route — Standalone contacts table accessible from main navigation (between Leads and Briefing).
4-Tier Traffic Badges — Gray "—" (0 emails), blue (1-5), purple (6-15), green (16+). Counts both inbound and outbound.
Enrichment Status — Unlock icon for enriched contacts (with photos), lock icon for unenriched. Sort by traffic or enrichment.
When a queued or researched lead starts engaging via email, the system automatically detects it and suggests advancing them in the pipeline. No more manual monitoring.
Inbound Email Detection — Hourly Celery task scans leads in queued/researched stages for inbound email activity.
Stage Suggestion Component — Appears at the top of Lead Detail page with suggested stage, reason text, and Accept/Dismiss buttons.
Accept Flow — Updates lead stage to "contacted", sets next_contact_date based on stage cadence, logs full stage history with changed_by="system_suggestion".
Conservative Logic — Only triggers for early-stage leads with inbound (not outbound) emails. Suggests, never auto-advances.
The morning briefing now correctly categorizes all known-lead emails, regardless of pipeline stage.
The briefing's tracked_deals section only included leads in contacted or qualified stages. Leads in queued or researched stages with matched emails showed as "untracked" — even though they ARE tracked leads in the system.
Production Impact: 7 emails matched to 3 leads, but tracked_deals showed 0. All matched leads were in early stages.
Single-line change: broadened the stage filter from ['contacted', 'qualified'] to ['queued', 'researched', 'contacted', 'qualified']. Only closed leads are now excluded.
Phase 4 directly impacts three of the four variables in the sales velocity equation.
With email direction, timestamps, and thread data now fully surfaced, Phase 5 transforms email visibility into a coaching and optimization tool.
Average Response Time — Per-lead and overall response time to inbound emails
"Going Cold" Detection — Inbound emails with no outbound follow-up within 48 hours
Cadence Consistency — Regularity scoring of outbound follow-up patterns
Sales Velocity Metrics — Time from first email to stage progression
| Prerequisite | Status | Target |
|---|---|---|
| Phase 4 features stable | Deployed March 11 | 1-2 weeks usage |
| Email data accumulation | 44 emails ingested | 100+ emails (2-4 weeks) |
| Configuration feedback | Pending Adam's usage | Badge thresholds, sort preference |