Stop cold emails to anyone with a live deal in Pipedrive
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.
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.
What does this prompt do?
- Runs every night at 2am and pulls the people attached to your open and won deals, so anyone your team is already talking to counts as protected.
- Immediately pauses those people if they are already partway through a cold email sequence, so the next scheduled send never reaches them.
- Adds every protected address to your team-wide unsubscribe list, so nobody can drop them into a future campaign by mistake.
- Appends one row per protected address to a running audit tab with the date, the deal it came from, the deal status, and whether the person was stopped mid-sequence.
What do I need to use this?
- A Pipedrive account where deals have people attached to them with email addresses
- A Mailshake account that holds the campaigns you send cold outreach from
- A Google Sheet to use as the audit log, with a tab set aside for the running record
- A quick look at which deals should count as protected before you switch it on
How can I customize it?
- Change when it runs. Nightly at 2am is the default, but hourly works if you send high volume and want a tighter net.
- Widen or narrow what counts as protected. Open and won deals are the default; you can limit it to certain pipelines, stages, or deal owners, or add recently lost deals if you want a cooling-off period.
- Add columns to the audit tab, like the deal owner, deal value, or which campaign the person was pulled out of.
FAQs
Why does it both pause people and unsubscribe them?
Will this unsubscribe people I might want to email later?
How does it decide two email addresses are the same person?
What happens if someone is in more than one campaign?
Does it overwrite the audit sheet each night?
Related templates
Every weekday at 10am, an AI voice agent phones your most overdue Xero accounts, logs what each customer promised, and reports back to finance in Slack.
See every Google Maps listing you manage on one screen, ranked worst first, with an audit button that writes the fix list for you.
Your team picks a template, finds the customer, checks they are safe to email, then sends it, with every send logged where the whole team can see it.
Build every text campaign in one screen: check who is actually reachable, see a realistic send plan, then watch delivery land row by row.
See every LinkedIn ad account's spend against the budget you committed to, catch overspend early, and rebalance without rebuilding a spreadsheet.
Open one board every morning, see every upcoming appointment with its confirmation status, and text the clients who have not replied yet.
Stop cold emailing your own customers.
Let your CRM decide who is off limits every night, before the next outreach batch goes out.