See llms.txt for all machine-readable content.

Back to Templates

Find and approve Apollo B2B cold email leads with OpenAI and Gmail

Quick overview

Pulls B2B leads from Apollo or Google Sheets, verifies and qualifies them with Hunter and rule checks, researches each company website, drafts a cold email with OpenAI, emails the draft to a reviewer for one-click approval before optionally sending via Gmail and logging outcomes in Google Sheets (and HubSpot).

How it works

  1. Runs on a weekday schedule or manual start, and also handles unsubscribe link clicks via a GET webhook.
  2. Reads the Pipeline and Suppression tabs in Google Sheets, then pulls new leads from Apollo (search + bulk enrichment) or from a Leads tab.
  3. Normalizes and deduplicates leads against existing Pipeline entries and the Suppression list, optionally verifies email deliverability via the Hunter Email Verifier API, and records disqualified leads as Skipped in the Pipeline tab.
  4. For each qualified lead, fetches the company homepage, uses an OpenAI-powered agent to research the site (optionally reading up to two more on-domain pages and selecting an offer from the Google Sheets Offers tab), and keeps only facts whose quotes are found in the scraped website text.
  5. Uses OpenAI to draft a short plain-text cold email from the validated facts, then runs rule-based quality checks and rewrites the draft up to the configured limit or marks it as Needs review/Failed.
  6. Saves each lead’s research and draft status to the Google Sheets Pipeline tab and optionally upserts the contact into HubSpot.
  7. For drafts marked Awaiting approval, emails the reviewer via Gmail with Approve/Reject links, waits for a click (or timeout), then re-checks Suppression and—if sending is enabled—sends the final email via Gmail with a signed one-click unsubscribe link.
  8. When the unsubscribe webhook is called with a valid signature, appends the email/domain to the Suppression tab in Google Sheets and responds with a confirmation message.

Setup

  1. Create a Google Sheets document with Pipeline, Suppression, and Offers tabs (and a Leads tab if you use lead_source = "sheet"), and paste the sheet URL into the Settings.
  2. Add credentials for Google Sheets, OpenAI, Gmail, Apollo (HTTP Header Auth using x-api-key), and Hunter (HTTP Query Auth using api_key), plus HubSpot (App Token) if hubspot_sync is enabled.
  3. Update all YOUR_ values in the Settings (company/offer text, reviewer_email, lead_source and Apollo search filters, and link_secret for signing unsubscribe links).
  4. If you use Apollo, confirm your search criteria and max_leads_per_run to control enrichment credit usage.
  5. Keep send_enabled set to false for initial testing, then set it to true when you are ready to send approved emails from Gmail.
  6. Copy the production unsubscribe webhook URL and ensure your workflow base URL is reachable so recipients can click the unsubscribe link successfully.