Stop cold emails to anyone with a live deal in Pipedrive

By General Input

Every night at 2am, pull the contacts on your open and won deals and block them from your cold outreach before the next send goes out.

Integrations

  • Mailshake
  • Pipedrive
  • Google Sheets

Type

Deterministic Code

Categories

  • Sales
  • Operations

Build me a code workflow on a cron trigger that runs every day at 2am and stops my cold outreach from ever hitting someone my company is already in conversation with. It should read my CRM for people we have live or closed business with, pull them out of any cold sequence they are currently in, block them from future campaigns, and log every address it protected.

Step one, build the protected list from Pipedrive. Use List Deals filtered to open and won deals only. Deal records carry the linked person, so collect the person's name and email address along with the deal name and the deal status for each one. If a deal's linked person email is not present on the deal record itself, resolve it with Get Person using the deal's linked person ID. Skip deals with no linked person or no email address on that person. Normalize every address to lowercase and dedupe, keeping the deal name and status of the first deal each address came from, so one person appearing on three deals is protected once rather than three times.

Step two, pause anyone already mid-sequence. Call Mailshake List Campaigns and keep the active ones. For each active campaign, call List Recipients and page all the way through using the nextToken in the response, since perPage caps at 100. Compare each recipient's email address against the protected list, matching the full address case-insensitively. Never match on domain alone, because protecting one contact at a company must not silently protect everyone else there. For every recipient that matches, call Pause Recipient for that recipient on that campaign, and remember that this address was paused and which campaign it was in. If a single pause call fails, log it and carry on with the rest rather than aborting the run.

Step three, block future adds. Pass the whole deduped protected list to Mailshake Unsubscribe Addresses in one pass. This list is team-wide and blocks those addresses from being added to any future campaign.

Both step two and step three are required, so please do not collapse them into one. Unsubscribing only blocks addresses from being added to future campaigns; it does not stop an email that is already scheduled to send to someone currently in a sequence. Pausing handles the people already mid-sequence. Skipping either one leaves a real hole. Also worth knowing when you build it: recipient pause changes can take up to five minutes to show on the send calendar, so do not treat an immediate read-back as the confirmation that a pause landed.

Step four, write the audit log. Use Google Sheets Append Values to add one row per protected address to an audit tab I will point you at. Columns are the run date, the email address, the deal name, the deal status of open or won, and whether the person was paused mid-sequence as a yes or no. Always append below the existing rows and never clear or overwrite the tab, because the point of the sheet is a running record of who was protected and why. If the tab is empty on the first run, write a header row before the data.

A few rules to bake in. All email matching is case-insensitive on the full address. If the protected list comes back empty on a given night, skip the unsubscribe call and write nothing to the sheet rather than sending an empty request. Respect the pagination and rate limits on both sides, since a large CRM plus several active campaigns can mean a lot of calls in one run. Make the Pipedrive deal filter easy for me to edit at the top of the workflow, because the unsubscribe is team-wide and hard to walk back, so I want to be deliberate about who lands on the protected list.

Related prompts

Explore more prompts
Call overdue Xero customers with an AI collections agentLocal listing health board for every location you manageLet support send one-off Loops emails without an engineeriMessage campaign console with pre-flight checks and delivery boardLinkedIn Ads budget pacing dashboard for every client accountFront desk appointment confirmation board for the next 3 daysGive your team Looker numbers without buying more seatsBuild audience segments from product usage and push to LoopsTurn the people who engage with your posts into Pipedrive leadsApprove Lusha enrichment field by field before HubSpot saves it