← Back to brief

reference smartlead hs email logging

memory · reference_smartlead_hs_email_logging.md

Problem (discovered 2026-04-29)

SmartLead campaigns send emails through 6 sender accounts:

Each campaign account is configured with a "BCC to CRM" address pointing at HubSpot's portal-generic BCC: 23273108@bcc.hubspot.com.

Result before fix: HubSpot received the BCC'd email but didn't recognize the @skyrungrandcounty.com From-address as Joseph's HS user (because Joseph's HS user only had joseph.bowens@skyrun.com registered). HS therefore logged each inbound BCC as a generic Note on the recipient's contact record, not as an Email engagement.

Downstream impact:

Fix (Path A — applied 2026-04-29)

Added 5 email aliases to Joseph's HS user profile at:
https://app.hubspot.com/settings/23273108/user-preferences/email

AliasStatus
joseph@skyrungrandcounty.com✓ added
bowensbo@skyrungrandcounty.com✓ added
bowens@skyrungrandcounty.com✓ added
josephbo@skyrungrandcounty.com✓ added
joseph.bowens@skyrungrandcounty.com✓ added
Now when HubSpot receives a BCC'd email from any of these senders, it matches the From-address to Joseph's user record (via aliases) and logs the email as an Email engagement on the recipient contact, attributed to Joseph.

No admin privileges required — every HS user can add aliases on their own profile.

Why Path A vs alternatives

Path A: one-time alias setup, zero ongoing maintenance, no admin needed, no warmup loss.

Verification methodology

For the NEXT SmartLead send (post-2026-04-29 fix):
1. Wait for any campaign send (campaigns fire weekdays 1pm MDT, ~22 emails/day across 6 senders)
2. Identify a recipient HS contact via the SmartLead activity log
3. Open the contact's timeline in HS
4. Confirm the engagement is "Email" (envelope icon) not "Note" (paperclip icon)
5. If still showing as Note → alias didn't propagate; re-check at /settings/23273108/user-preferences/email

Diagnostic correction (2026-04-29 afternoon)

Initial assumption was that SmartLead BCCs were creating Notes in HS. That was wrong. When the @skyrungrandcounty.com From-address wasn't recognized as a HS user (pre-Path-A), HubSpot silently dropped the BCC entirely — no Note, no Email, nothing was created. Verified by querying every engagement type portal-wide (notes/search, emails/search from @skyrungrandcounty.com) — all returned 0.

Meanwhile the @skyrun.com primary sender (joseph.bowens@skyrun.com) was always a recognized HS user, so its sends DID log correctly as Email engagements (145 of them as of 2026-04-29 morning).

So the real backfill task was: re-create the missing variant-sender sends as Email engagements.

Backfill executed (2026-04-29 afternoon)

Used HubSpot CRM v3 API via cookie auth in chrome_bridge (no admin/private app needed). For each lead in the 3 SmartLead campaigns, checked HS for an existing Email engagement matching the SL subject. If missing → created via POST /crm/v3/objects/emails with proper hs_email_headers (from/to), hubspot_owner_id=88361194 (Joseph), and association to the recipient contact.

Email-1 backfill — "Quick question about your Grand County property"

- 97 already had Email-1 logged (sent via joseph.bowens@skyrun.com primary) - 6 had no matching HS contact (skipped) - 72 missing → created, distributed evenly across the 5 newly-aliased variant senders

Email-2 backfill — "How we take care of homes in Grand County"

- 0 already logged (none of the 31 existing Email-2 in HS were for these leads) - 4 had no matching HS contact - 80 created

Net result

Known incomplete coverage

Email-2 backfill only covered 84 leads (the ones in my scraped data). Approximately 30-40 additional leads in HOT+WARM and SWITCH (beyond the 50-row scrape limit) likely received Email-2 from variant senders but weren't backfilled. To close that gap requires either:

Scripts

Located in /tmp/ — move to ~/Library/Application Support/SkyRun/ if reused:

Permanent Fix — Engagement-To-Contact Misrouting (2026-04-29 evening)

After the Email-1/2 backfills, audit revealed a deeper sync problem: 16 of 209 SL-enrolled leads (7.7%) had a SL email that didn't match the HS primary email of the lead's contact (looked up by lead_id via lead_source_notes). For 2 of those, HS auto-created dangling BCC_TO_CRM contacts when the primary @skyrun.com sender BCC'd HS — engagements landed on the dangling contact, not the legit lead's contact.

Diagnosis: When SmartLead BCCs HubSpot, HS matches by To-email against contact primary emails first, then hs_additional_emails. If neither matches, HS creates a NEW contact with that email, attributed to the sender (Joseph), source = BCC_TO_CRM. That new contact has no name, no lead_source_notes, no SoT linkage — and the engagement gets logged on it instead of the legit lead's contact.

Manual cleanup performed:

Permanent guardrails wired:

1. DQ Step 5H — SL↔HS email sync check (added to daily-data-quality-check/SKILL.md):
- Runs after the current-owner audit (5G)
- Calls ~/Library/Application Support/SkyRun/sl_hs_email_sync_check.sh which chains:
- sl_hs_email_audit.py — audit
- sl_align_emails.py — auto-add SL email as additional on legit contact
- sl_dangling_fix.py — re-associate engagements from BCC_TO_CRM contacts + delete
- Auto-fix at YELLOW severity (reversible, low-risk). Severity unchanged on pure auto-fix-success.

2. BV enrichment Step 7b-2.5 — SL email pre-flight (added to daily-beenverified-enrichment/SKILL.md):
- Before pushing a lead's email to SmartLead, verify HS contact (looked up by lead_id) recognizes the email as primary OR additional
- If not: PATCH hs_additional_emails to include it BEFORE the CSV push
- If email is on a DIFFERENT contact (uniqueness conflict): SKIP the SL push, log as sl_email_conflict (RED)
- If HS contact is missing: SKIP, log as sl_push_skipped: hs_contact_missing

3. Permanent scripts (moved to ~/Library/Application Support/SkyRun/):
- sl_hs_email_audit.py — audit
- sl_align_emails.py — auto-fix mismatches
- sl_dangling_fix.py — re-associate + delete dangling BCC contacts
- sl_hs_email_sync_check.sh — wrapper that runs all three + emits combined JSON for DQ
- sl_orphan_fix.py — backfill orphans by lead_id (one-shot, retained for reference)

Standing rule (HARDWIRED 2026-04-29):
> Every SmartLead email must associate to the lead's legit HS contact. The SL email field must equal HS primary email OR be in hs_additional_emails BEFORE the lead enters any SL campaign. Daily-DQ Step 5H is the daily safety net; BV Step 7b-2.5 is the prevention layer.

Final state after this session (2026-04-29 evening):

Watchdog (cron — post-fix monitoring)

Add to daily-data-quality-check:

Owner of this fix

Cross-references