kritwish.
  • Work
  • Systems
  • Playbook
  • Career

kritwish mondal, gtm engineer · diagrams sanitized: no customer data, no secrets

← Clean Data

Production

Suppression engine

  • Salesforce
  • Apex
  • HubSpot
  • lemlist
Incident
Sync loop marks 150 leads Lost
Action
Restore from field history · delete 741 bad records · cut the loop
After
150 of 150 restored
Guard
Design change: the loop can't recur

The problem

There was no single answer to "may we contact this person?". Each tool kept its own idea:

  • The sequencer (lemlist) never wrote unsubscribes or bounces back to Salesforce. All 11 of its bounces had no bounce or opt-out on the Salesforce record.
  • HubSpot only syncs qualified contacts, so most contacts never received Salesforce's flags at all.
  • No shared rule kept customers, people with an open deal, or people a rep was already working out of cold campaigns.

The goal: one rule set in Salesforce that every tool reads before sending. I designed the rules with a teammate, then built the engine, sync and backfill, and ran the production steps myself.

Constraints

  • Opt-outs are legal records. An unsubscribe or a "don't contact me" stays permanent unless the person opts back in. Everything else, like a cool-off after a lost deal, must expire on its own.
  • No webhooks from the sequencer. Unsubscribes and bounces had to be polled from its API every hour.
  • Bad dates in the data. A bulk stage clean-up had stamped 1,987 lost leads with the same September date. Counting the 90-day cool-off from that date would have held back 2,289 leads. Counting from the last real conversation instead held back 13.
  • Contacts have no stage. So I stamp touch dates on contacts from rep calls, emails, meetings and replies; "a rep is working them" means a touch in the last 180 days.

How it works

  1. Every signal becomes a Salesforce field first: rep checkboxes, call outcomes, the hourly sequencer pull, HubSpot unsubscribes and the account's stage. No rule reads another tool directly.
  2. One method holds every rule. On every lead or contact save, it checks 13 rules: 8 for Do Not Contact (such as customer, open deal, competitor, asked not to, cool-off after Lost), 3 for email and 2 for calls.
  3. It writes three flags plus the why. Do Not Contact, Do Not Email and Do Not Call, a list of every rule that matched, and an end date for timed holds. A kill switch turns every flag off at once.
  4. Changes cascade. When an account becomes a customer or opens a deal, its leads and contacts are recomputed. A nightly job recomputes everything and releases expired holds.
  5. Every tool reads the flags. HubSpot has three segments, each with HubSpot-native backup conditions so unsynced contacts are covered too. Sequencer imports skip anyone on Do Not Contact. Salesforce has a list view for each list.

Rep checkboxes, call outcomes, sequencer unsubscribes and bounces, HubSpot unsubscribes and account stage all land as Salesforce fields; one compute method turns them into three suppression flags that HubSpot segments, sequencer imports and Salesforce list views read.

One rule set, many readers

Receipts

  • Backfill at go-live (30 October 2026): 1,247 leads and 4,704 contacts suppressed.
  • HubSpot segments on day one: 4,788 Do Not Contact, 1,060 email-only, 0 call-only.
  • Tests in a sandbox: Apex 16/16 and end-to-end 42/42 at build, then 28/28 and 44/44 after the follow-up fixes.

What broke, and what I changed

On 4 November, the sequencer's built-in Salesforce field mapping was switched on, set so that Salesforce overwrites the sequencer. It turned every Salesforce suppression into a sequencer unsubscribe: 573 values. My hourly sync pulled them back into Salesforce as real opt-outs and Do Not Contact ticks: a loop. The stage flows reacted and moved 150 leads to Lost.

I removed the mapping that afternoon and paused my sync the next morning. Then I worked in this order:

  • Restored all 150 leads from Salesforce field history: status, lost reason and stage date. 150 of 150 succeeded.
  • Re-subscribed people in the sequencer whose unsubscribe came from the loop.
  • Deleted 741 bad suppression records, so stored signals could not re-apply the opt-outs.

The first restore did not hold. Within minutes, 101 leads went Lost again. The HubSpot connector had copied the loop's opt-out onto 215 records and wrote it back to Salesforce seconds after I cleared it. HubSpot's API can't re-subscribe someone opted out of everything, so I did it in bulk in the HubSpot UI, then reset the 101 statuses after a 5-lead pilot. The final check showed 101 of 101 on the right status, and 0 of the loop's leads or contacts still flagged.

I also changed the design so this can't happen again:

  • Salesforce never unsubscribes anyone in the sequencer. A test now fails if the code makes any unsubscribe call.
  • Suppression is data-only. It writes only its own five fields. It never changes a lead's stage or writes to another tool.
  • Sequencer unsubscribes become timed markers. They suppress for 180 days but never tick the permanent opt-out fields. Opt-outs from a rep, a call result or HubSpot stay permanent.
  • Meeting Booked is protected. An email opt-out or a bounce no longer moves it. Do Not Contact can only move it to Engaged Lost, and a validation rule enforces that.
  • The opt-out fields now have field history, and a "Meeting Booked mismatch" report shows any drift.

Honest negative

The restore covered the fields Salesforce tracks. Other changes the Lost move caused, such as follow-up tasks it closed, were not tracked and were not restored.

What I'd do next

  • Turn on the verifier rule. The undeliverable-email rule is built but off until it is checked against real sends.
  • Wire the hot-accounts engine to the flags, so suppressed people are skipped before any enrichment spend, as the design planned.

Want systems like these at your org?

Message me on LinkedIn