The lead email sequence

Two triggers, one date field: the n8n workflow behind our new-lead and old-lead email sequences

New leads get five emails over 14 days the moment they land in the CRM. Leads who go quiet for 90 days get three more. Both lanes run off the same timestamp. The full workflow is at the bottom of this page, ready to import, with nine problems from our own versions fixed.

Maksym BondarenkoSystems & Automation Engineering, Azuro AILast updated
2 triggers26 functional nodesImportable n8n JSON9 fixes over our own version

Most lead email setups are two unrelated automations. One welcomes new leads. Another, built months later by someone else, chases people who went cold. Neither knows the other exists, so a lead who replied last week can still get a "we haven't heard from you" email tomorrow.

Ours shares one CRM field between the two. The new-lead lane writes a timestamp when it enrolls someone. Our inbound email agent rewrites it every time a lead replies. The old-lead lane reads it once a month and only picks up people whose newest touch is more than 90 days old. A lead moves from new to old just by not hearing from us, and moves back out the moment they write in.

NEW LEADS                                  HubSpot contact.creation webhook
[webhook] -> [config] -> [split batch] -> [creations only] -> [get contact]
   -> [has email, not enrolled?] -> [Brevo: add to nurture list] -> [stamp CRM]
   -> [metrics] -> [automation_logs] -> [BetterStack]
                                  |
          writes  outreach_stage = "New",  last_activity_at = now
                                  |
        90 days with no reply and no logged activity in the CRM
                                  v
OLD LEADS                                  1st of the month, 07:00
[schedule] -> [config] -> [get all contacts] -> [select old leads] -> [any?]
   yes -> [Brevo bulk import] -> [stamp CRM] -> [metrics] -> [logs] -> [BetterStack]
   no  ----------------------------------------> [metrics: 0] -> [logs] -> ...

any API error, either lane  ->  [failure metrics] -> [logs: failed] -> [BetterStack]

n8n does the enrolling. The emails themselves live in two Brevo automations, each starting when a contact is added to a list. That split is deliberate. Copy and timing get edited in the email tool by whoever writes the emails, and the workflow never has to change when they do.


The two sequences

THE CADENCES WE CONFIGURE IN BREVO FOR EACH LIST

SequenceStarts whenEmailsSchedule
New lead nurtureContact created in the CRM5 over 14 daysDay 0 welcome, day 2 case study, day 5 value, day 7 objection, day 14 soft close
Old lead reactivationNo touch in 90 days3 over 14 daysDay 0 check-in, day 7 something new, day 14 final note

Two details from our own setup guide that matter more than any subject line. Set each automation's entry point to fire only once per contact, so a duplicate list-add can't restart someone's sequence. And make the reply-to a real inbox, because a reply is the whole point and a no-reply address throws it away.

The reactivation copy also has a rule we hold to: never mention the gap. "It's been 90 days" reads like a CRM wrote it, which is exactly what happened. "We haven't spoken in a while" does the same job.

The hinge: one timestamp, three writers

LAST_ACTIVITY_AT, A CUSTOM CONTACT PROPERTY STORED AS MILLISECONDS

Three things write it and one thing reads it. The new-lead lane writes it on enrollment. The old-lead lane writes it on reactivation. Our inbound email agent, a separate workflow, writes it on every email a lead sends us, using one HubSpot node that runs right after the message is parsed:

the node in our inbound email agent that resets the clock
HubSpot: create or update contact
email               {{ $json.senderEmail }}
last_activity_at    {{ new Date($now).getTime() }}

That node is why we don't need a reply webhook from the email platform. Anyone who replied in the last 90 days has a fresh timestamp, so the monthly sweep skips them on its own. If you don't run an email agent, any workflow that logs a real touch (a booked call, a form fill, a reply forwarded from your inbox) should write the same field.

Lane 1. New leads

WEBHOOK TRIGGER, ONE EXECUTION PER BATCH OF CRM EVENTS

  • Trigger: a HubSpot webhook subscribed to contact.creation. HubSpot batches events, so one request can carry several new contacts. A Split Out node turns the batch into one item per event before anything else runs.
  • Filter: only contact.creation events continue. Anything else that gets subscribed to the same URL later just stops here.
  • Get the contact, then gate it: it must have an email, and outreach_stage must still be empty. That's the same field this lane writes a moment later, so a webhook HubSpot retries can't enroll anyone twice.
  • Add to the Brevo nurture list. This call is what starts the five-email sequence.
  • Stamp the CRM: outreach_stage = "New" and last_activity_at = now.
  • Log one row for the whole batch, with clients_nurtured set to the number of leads enrolled.

Lane 2. Old leads

MONTHLY SCHEDULE, ONE BULK IMPORT PER RUN

On the 1st of each month at 07:00 the lane pulls every contact with nine properties, decides who counts as an old lead in a single Code node, and bulk-imports that set to the reactivation list in one API call. The selection rule is the part worth reading:

from the Select Old Leads node
if (!email) continue;
if (skipStages.has(prop(c, 'outreach_stage'))) continue;   // Reactivation, Booked
if (skipStatuses.has(prop(c, 'hs_lead_status'))) continue; // UNQUALIFIED
if (skipLifecycle.has(prop(c, 'lifecyclestage'))) continue; // customer, evangelist

// Newest known touch. last_activity_at only exists on contacts our own
// workflows have touched, so fall back to HubSpot's own dates.
const touches = ['last_activity_at', 'notes_last_updated', 'createdate']
  .map(k => parseInt(prop(c, k), 10))
  .filter(n => !Number.isNaN(n));
if (!touches.length || Math.max(...touches) >= cutoff) continue;

Every skip list lives in the Company Config node, so changing who gets reactivated is a config edit. Skipping "Reactivation" means each contact gets one reactivation pass. If they come back and go cold again, whatever records their return should clear the stage, and they become eligible again.

Contacts are stamped only after the bulk import succeeds. If Brevo rejects the import, nobody gets marked as reactivated without actually being in the sequence, and the failure goes to the failure log.


What we fixed on the way

FOUND BY READING OUR OWN TWO PRODUCTION WORKFLOWS SIDE BY SIDE

This page started as a merge of our Lead Nurturing and Reactivation workflows. Reading them line by line to write it up turned up nine problems. None of them throws an error you would notice. Most would just quietly enroll the wrong people, or fewer people than you think.

In our versionWhat that doesIn this one
Read only the first event in each HubSpot requestHubSpot batches events, so every new lead after the first in a batch is never enrolledSplit the batch first, one item per event
"Already nurturing?" gate checked lead status for "Nurturing"The same workflow writes "Bad Timing" to that field, so the gate can never match what it writes. It also overwrote every new lead's status on the way throughGate on outreach_stage being empty, the field the lane actually writes. Lead status is left alone
Old-lead exclusion compared lead status to "closed_lost"That isn't a default HubSpot lead status value (closed lost is a deal stage), so on a standard account it excludes nobodyConfig-driven skip lists for stage, lead status and lifecycle stage
Formatting step read firstname.value directlyHubSpot leaves empty properties out of the response. One contact with no first name throws, and the whole month's import goes with itOptional reads with empty-string defaults
Old leads required our own last_activity_atOnly contacts our workflows had touched had one, so anyone in the CRM before launch could never be reactivated. Our onboarding checklist didn't even list the propertyNewest of last_activity_at, HubSpot's last activity date and create date
Nothing marked a reactivated contactThe same contacts qualify again every single monthStamp outreach_stage = "Reactivation" and skip that stage
Empty month produced zero itemsEvery node after the filter skipped, the log included. A quiet month and a broken workflow looked the same on the dashboardSelection always returns one summary item, and a 0 gets logged
Monitoring call sat between the CRM update and the metricA logging-service hiccup meant the business row for that lead never got writtenBusiness log first, BetterStack last, and BetterStack can't fail the run
Logged emails_delivered on enrollmentJoining a list sends nothing. Brevo sends later, on its own scheduleLog clients_nurtured and clients_reactivated only
Why the empty month gets its own fix

In n8n, a node that returns zero items is not an error. Every node after it simply never runs. We learned how much that hurts on a client voice agent in September: a contact lookup that found nothing for brand-new callers returned zero rows, so the personalised greeting and the whole post-call wrap-up were silently skipped for every first-time caller. The node was even set to continue on error, which did nothing, because nothing had errored.

The monthly sweep has the same shape. A month where nobody qualifies is a perfectly good result, and it has to leave the same trace as a month where 200 did. So the contact fetch is set to always output data, and the selection node always returns exactly one item carrying the count, even when the count is zero.

Logging

THE SAME FOUR-NODE TAIL AS EVERY OTHER WORKFLOW WE RUN

Each lane ends in Company Config, Calculate Metrics, Send Logs, then BetterStack, writing one row per run to the same automation_logs table our other workflows use. Company Config is a Set node in raw mode, and its value has to be a JSON string rather than an object, or n8n throws "jsonOutput?.startsWith is not a function" at runtime. The time-saved model is the one we use everywhere: five minutes per new lead, two minutes per reactivated contact, times a $100/hour rate.

the table both lanes write to (Postgres / Supabase)
create table automation_logs (
  id             uuid primary key default gen_random_uuid(),
  customer_id    uuid,
  company_name   text,
  workflow_id    text,
  workflow_name  text,
  action_type    text,    -- "nurture" | "reactivation"
  status         text,    -- "success" | "failed"
  metrics        jsonb,   -- { clients_nurtured | clients_reactivated, time_saved, cost_savings }
  created_at     timestamptz default now()
);

Every node that calls HubSpot or Brevo routes its error output to one shared failure sink, which writes a failed row and names the step that broke. The two CRM-stamp nodes are the exception. They pass errors through as items, and the metrics node counts them, because a failed stamp shouldn't erase the record of an enrollment that already happened.

What it doesn't do

  • Send email. If a Brevo list exists but its automation isn't switched on, contacts pile up in it and receive nothing. Check that first when "nothing is happening".
  • Track opens, clicks or deliveries. Those come from the email platform's own events, which this workflow doesn't subscribe to.
  • Verify the webhook signature. HubSpot signs its requests. Until you check that signature, the unguessable path is the only protection, so pick a long one.
  • Scale past a modest CRM. The old-lead lane fetches every contact once a month. That's fine into the low thousands. Beyond that, swap the fetch for a CRM search filtered on the date.

The workflow

COPY, THEN PASTE STRAIGHT ONTO AN EMPTY N8N CANVAS

Every credential, tenant id, list id, webhook path and logging endpoint is a YOUR_ placeholder. A sticky note on the canvas repeats the setup list below. If you leave a list id as the placeholder, Brevo rejects the call, and you'll see it in the failure log rather than wondering why nobody got an email.

  • In HubSpot, create two contact properties: outreach_stage (single-line text) and last_activity_at (a number that holds a millisecond timestamp, since a date-only field rejects anything but midnight).
  • Subscribe your HubSpot app's webhook to contact.creation, pointed at the workflow's production URL.
  • In Brevo, create the two lists and their automations, then put the numeric list ids in both Company Config nodes.
  • Create automation_logs, reconnect the four credentials, set the BetterStack URL and your error workflow.
  • Test with one contact before the first monthly sweep runs against the whole CRM.
new-and-old-lead-email-sequence.json
{
  "name": "New & Old Lead Email Sequence",
  "nodes": [
    {
      "parameters": {
        "content": "## New & Old Lead Email Sequence\nTwo triggers, one date field.\n\n**Top lane (new leads):** HubSpot `contact.creation` webhook -> enroll in the Brevo nurture list -> stamp `outreach_stage` + `last_activity_at`.\n\n**Bottom lane (old leads):** runs on the 1st of each month at 07:00 -> finds contacts with no touch in `daysTillReengage` days -> bulk-imports them to the Brevo reactivation list -> stamps them so they are not picked again.\n\nn8n only enrolls. The emails themselves are two Brevo Automations with entry point *\"contact added to list\"*, set to **only once per contact**. If the list exists but the automation is not active, contacts pile up and receive nothing.\n\n### Before you activate\n1. HubSpot: create contact properties `outreach_stage` (single-line text) and `last_activity_at` (number, holds a millisecond timestamp).\n2. HubSpot app: webhook subscription `contact.creation` -> this workflow's production URL. Give the path something hard to guess.\n3. Brevo: create the two lists, put their numeric IDs in both Company Config nodes.\n4. Supabase: create `automation_logs` (schema on the page this came from).\n5. Reconnect the 4 credentials (HubSpot OAuth2, Brevo, Supabase, BetterStack bearer) and set the BetterStack URL.\n6. Settings -> Error Workflow: point it at yours.\n7. Test with ONE contact before you let the monthly sweep loose on the whole CRM.",
        "height": 620,
        "width": 620,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -720,
        160
      ],
      "id": "37fbc8a2-ab4f-48a4-97ae-3749dffe953f",
      "name": "Sticky: Read Me"
    },
    {
      "parameters": {
        "content": "### New leads\nHubSpot batches webhook events (several per POST), so split first. Only `contact.creation` passes. A contact is enrolled only if it has an email and `outreach_stage` is still empty, which is the same field this lane writes, so a retried webhook cannot enroll anyone twice.",
        "height": 460,
        "width": 2560,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -40,
        160
      ],
      "id": "9eb40965-8151-4ad8-a650-06a3aae93eb7",
      "name": "Sticky: New Leads"
    },
    {
      "parameters": {
        "content": "### Old leads\nLast touch = the newest of `last_activity_at` (written by this workflow and by an inbound-email agent when a lead replies), HubSpot's own last-activity date, and the create date. That fallback is what lets contacts that existed before this workflow get reactivated at all. `Select Old Leads` always returns exactly one summary item, so an empty month still writes a log row with 0 instead of silently stopping.",
        "height": 460,
        "width": 2560,
        "color": 6
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -40,
        680
      ],
      "id": "8cdf03cd-ec2e-40e4-af31-fadf7bb9aa25",
      "name": "Sticky: Old Leads"
    },
    {
      "parameters": {
        "content": "### Failures\nEvery node that calls an external API has its error output wired here. One shared sink, so it reads whichever Company Config actually ran (guarded, because referencing a node that did not run on this path throws).",
        "height": 300,
        "width": 1100,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -40,
        1200
      ],
      "id": "a52a887c-ad94-49e0-99db-35f22001463e",
      "name": "Sticky: Failures"
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "YOUR-UNGUESSABLE-PATH-new-lead",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        380
      ],
      "id": "97db84a0-a501-4429-b97b-31211252e880",
      "name": "New Lead (HubSpot Webhook)"
    },
    {
      "parameters": {
        "mode": "raw",
        "jsonOutput": "{\n  \"customerId\": \"YOUR_TENANT_UUID\",\n  \"companyName\": \"Your Company\",\n  \"workflowName\": \"Lead Email Sequence (New Leads)\",\n  \"actionType\": \"nurture\",\n  \"nurtureListId\": \"YOUR_BREVO_NURTURE_LIST_ID\",\n  \"nurtureStage\": \"New\",\n  \"minutesPerLead\": 5,\n  \"hourlyRate\": 100\n}\n",
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        240,
        380
      ],
      "id": "6718df42-0f76-4fe7-a118-bcc965836e2f",
      "name": "Company Config (New Leads)"
    },
    {
      "parameters": {
        "fieldToSplitOut": "body",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        480,
        380
      ],
      "id": "29422c95-d606-4def-99b2-80bea76ec797",
      "name": "Split HubSpot Events",
      "notes": "HubSpot sends events in batches. Reading only body[0] silently drops every other lead in the batch."
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "83bc45a5-51e6-431e-a8e7-327603c9c660",
              "leftValue": "={{ $json.subscriptionType }}",
              "rightValue": "contact.creation",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        720,
        380
      ],
      "id": "0d9f3600-3aa7-4198-b94b-3156382ecbd4",
      "name": "Only Contact Creations"
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "operation": "get",
        "contactId": {
          "__rl": true,
          "value": "={{ $json.objectId }}",
          "mode": "id"
        },
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2.2,
      "position": [
        960,
        380
      ],
      "id": "37452f33-5b8a-4621-8913-aed2c0845156",
      "name": "Get Contact",
      "credentials": {
        "hubspotOAuth2Api": {
          "id": "YOUR_HUBSPOT_CREDENTIAL_ID",
          "name": "HubSpot account"
        }
      },
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "b1e0e7f5-c702-4555-a775-2df66d8743a0",
              "leftValue": "={{ $json.properties.email?.value ?? '' }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            },
            {
              "id": "075dadd1-d1ac-4bcf-b867-5faff5539172",
              "leftValue": "={{ $json.properties.outreach_stage?.value ?? '' }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1200,
        380
      ],
      "id": "5c825a10-c51c-4199-b3b9-7ef7806d1ca2",
      "name": "Has Email & Not Enrolled?",
      "notes": "False branch is intentionally empty: no email, or already in a sequence. Nothing to do, nothing to log."
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.brevo.com/v3/contacts",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "sendInBlueApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "accept",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({\n  email: $json.properties.email.value,\n  attributes: {\n    FIRSTNAME: $json.properties.firstname?.value ?? '',\n    LASTNAME: $json.properties.lastname?.value ?? ''\n  },\n  listIds: [Number($('Company Config (New Leads)').first().json.nurtureListId)],\n  updateEnabled: true\n}) }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [
        1440,
        360
      ],
      "id": "1753b1f2-a57d-4924-9d2e-a9acdaa188c6",
      "name": "Add to Nurture List (Brevo)",
      "credentials": {
        "sendInBlueApi": {
          "id": "YOUR_BREVO_CREDENTIAL_ID",
          "name": "Brevo account"
        }
      },
      "onError": "continueErrorOutput",
      "notes": "Adding the contact to the list is what starts the Brevo nurture automation."
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "email": "={{ $('Get Contact').item.json.properties.email.value }}",
        "additionalFields": {
          "customPropertiesUi": {
            "customPropertiesValues": [
              {
                "property": "last_activity_at",
                "value": "={{ new Date($now).getTime() }}"
              },
              {
                "property": "outreach_stage",
                "value": "={{ $('Company Config (New Leads)').first().json.nurtureStage }}"
              }
            ]
          }
        },
        "options": {
          "resolveData": false
        }
      },
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2.2,
      "position": [
        1680,
        360
      ],
      "id": "15d715b1-60c7-4fd8-8484-a7e5fae429c7",
      "name": "Stamp Contact (New)",
      "credentials": {
        "hubspotOAuth2Api": {
          "id": "YOUR_HUBSPOT_CREDENTIAL_ID",
          "name": "HubSpot account"
        }
      },
      "onError": "continueRegularOutput",
      "notes": "Create-or-update by email. Writes the two fields both branches key on. Errors pass through as items so the metrics node can count them instead of aborting the run."
    },
    {
      "parameters": {
        "jsCode": "const config = $('Company Config (New Leads)').first().json;\nconst hourlyRate = config.hourlyRate || 100;\nconst rows = $input.all();\n\n// One execution can carry several new leads (HubSpot batches events).\nconst enrolled = rows.length;\nconst stampFailures = rows.filter(r => r.json.error).length;\nconst timeSaved = (config.minutesPerLead || 5) * enrolled;\n\n// Counts enrollments, not deliveries. Brevo sends the emails later.\nconst metrics = {\n  clients_nurtured: enrolled,\n  time_saved: timeSaved,\n  cost_savings: Math.round(timeSaved * (hourlyRate / 60))\n};\n\nreturn [{ json: { metrics, enrolled, stampFailures } }];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1920,
        360
      ],
      "id": "59141ccb-c488-4257-b187-7c8c82bd73d9",
      "name": "Calculate New-Lead Metrics"
    },
    {
      "parameters": {
        "tableId": "automation_logs",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "customer_id",
              "fieldValue": "={{ $('Company Config (New Leads)').first().json.customerId }}"
            },
            {
              "fieldId": "company_name",
              "fieldValue": "={{ $('Company Config (New Leads)').first().json.companyName }}"
            },
            {
              "fieldId": "workflow_id",
              "fieldValue": "={{ $workflow.id }}"
            },
            {
              "fieldId": "workflow_name",
              "fieldValue": "={{ $('Company Config (New Leads)').first().json.workflowName }}"
            },
            {
              "fieldId": "action_type",
              "fieldValue": "={{ $('Company Config (New Leads)').first().json.actionType }}"
            },
            {
              "fieldId": "status",
              "fieldValue": "success"
            },
            {
              "fieldId": "metrics",
              "fieldValue": "={{ $json.metrics }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        2160,
        360
      ],
      "id": "5e37ecaf-6ba8-45ad-8875-5e840205a019",
      "name": "Send Logs (New Leads)",
      "credentials": {
        "supabaseApi": {
          "id": "YOUR_SUPABASE_CREDENTIAL_ID",
          "name": "Supabase Logging"
        }
      }
    },
    {
      "parameters": {
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "requestMethod": "POST",
        "url": "https://YOUR_BETTERSTACK_INGEST_HOST/",
        "options": {},
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "message",
              "value": "=New leads enrolled: {{ $('Calculate New-Lead Metrics').first().json.enrolled }}\n    CRM stamp failures: {{ $('Calculate New-Lead Metrics').first().json.stampFailures }}\n    workflow_name: {{ $workflow.name }}\n    execution_id: {{ $execution.id }}\n    mode: {{ $execution.mode }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        2400,
        360
      ],
      "id": "1aad2f0c-af23-4dc6-88d3-7218ccb5a32e",
      "name": "Log to BetterStack (New Leads)",
      "credentials": {
        "httpBearerAuth": {
          "id": "YOUR_BETTERSTACK_CREDENTIAL_ID",
          "name": "BetterStack"
        }
      },
      "onError": "continueRegularOutput",
      "notes": "Operational log only. A BetterStack outage must never block the business log, so it runs last and cannot fail the execution."
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "months",
              "triggerAtDayOfMonth": 1,
              "triggerAtHour": 7
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        900
      ],
      "id": "cbe74feb-b9d1-4e54-aad3-6b17303a3ca1",
      "name": "Monthly Sweep (1st, 07:00)"
    },
    {
      "parameters": {
        "mode": "raw",
        "jsonOutput": "{\n  \"customerId\": \"YOUR_TENANT_UUID\",\n  \"companyName\": \"Your Company\",\n  \"workflowName\": \"Lead Email Sequence (Old Leads)\",\n  \"actionType\": \"reactivation\",\n  \"reactivationListId\": \"YOUR_BREVO_REACTIVATION_LIST_ID\",\n  \"reactivationStage\": \"Reactivation\",\n  \"daysTillReengage\": 90,\n  \"skipStages\": [\n    \"Reactivation\",\n    \"Booked\"\n  ],\n  \"skipLeadStatuses\": [\n    \"UNQUALIFIED\"\n  ],\n  \"skipLifecycleStages\": [\n    \"customer\",\n    \"evangelist\"\n  ],\n  \"minutesPerContact\": 2,\n  \"hourlyRate\": 100\n}\n",
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        240,
        900
      ],
      "id": "f98a0e44-b3e2-423f-8a71-52518e35531a",
      "name": "Company Config (Old Leads)"
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "operation": "getAll",
        "returnAll": true,
        "additionalFields": {
          "propertiesCollection": {
            "propertiesValues": {
              "properties": [
                "email",
                "firstname",
                "lastname",
                "hs_lead_status",
                "lifecyclestage",
                "outreach_stage",
                "last_activity_at",
                "notes_last_updated",
                "createdate"
              ],
              "propertyMode": "valueOnly"
            }
          }
        }
      },
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2.2,
      "position": [
        480,
        900
      ],
      "id": "cfb16b57-75b6-45dc-9ef1-9e1ff6318bde",
      "name": "Get All Contacts",
      "credentials": {
        "hubspotOAuth2Api": {
          "id": "YOUR_HUBSPOT_CREDENTIAL_ID",
          "name": "HubSpot account"
        }
      },
      "alwaysOutputData": true,
      "onError": "continueErrorOutput",
      "notes": "alwaysOutputData: an empty CRM still yields one (empty) item, so the run reaches the log instead of stopping here."
    },
    {
      "parameters": {
        "jsCode": "const config = $('Company Config (Old Leads)').first().json;\nconst cutoff = Date.now() - config.daysTillReengage * 24 * 60 * 60 * 1000;\nconst skipStages = new Set(config.skipStages || []);\nconst skipStatuses = new Set(config.skipLeadStatuses || []);\nconst skipLifecycle = new Set(config.skipLifecycleStages || []);\nconst prop = (c, key) => c.properties?.[key]?.value;\n\nconst all = $input.all().filter(i => i.json.properties); // drops the empty placeholder item\nconst contacts = [];\n\nfor (const { json: c } of all) {\n  const email = prop(c, 'email');\n  if (!email) continue;\n  if (skipStages.has(prop(c, 'outreach_stage'))) continue;\n  if (skipStatuses.has(prop(c, 'hs_lead_status'))) continue;\n  if (skipLifecycle.has(prop(c, 'lifecyclestage'))) continue;\n\n  // Newest known touch. last_activity_at only exists on contacts our own\n  // workflows have touched, so fall back to HubSpot's own dates.\n  const touches = ['last_activity_at', 'notes_last_updated', 'createdate']\n    .map(k => parseInt(prop(c, k), 10))\n    .filter(n => !Number.isNaN(n));\n  if (!touches.length || Math.max(...touches) >= cutoff) continue;\n\n  contacts.push({\n    email,\n    firstname: prop(c, 'firstname') || '',\n    lastname: prop(c, 'lastname') || ''\n  });\n}\n\n// Always exactly one item, even when nothing qualifies.\nreturn [{ json: { contacts, count: contacts.length, scanned: all.length } }];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        720,
        900
      ],
      "id": "214f68f8-b765-420f-a9ce-0bbfb9a54a63",
      "name": "Select Old Leads"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "ce8ad6b3-f7ab-4c9b-a1da-a84071723b38",
              "leftValue": "={{ $json.count }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        960,
        900
      ],
      "id": "e082d3a1-cd59-44da-baec-eabea3ac624f",
      "name": "Any Old Leads?"
    },
    {
      "parameters": {
        "jsCode": "const config = $('Company Config (Old Leads)').first().json;\nconst { contacts } = $input.first().json;\n\nreturn [{\n  json: {\n    listIds: [Number(config.reactivationListId)],\n    updateExistingContacts: true,\n    emptyContactsAttributes: false,\n    jsonBody: contacts.map(c => ({\n      email: c.email,\n      attributes: { FIRSTNAME: c.firstname, LASTNAME: c.lastname }\n    }))\n  }\n}];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1200,
        880
      ],
      "id": "5d2d60a8-d332-45cb-9e26-89d09ef7ecdd",
      "name": "Format for Brevo Import"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.brevo.com/v3/contacts/import",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "sendInBlueApi",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "accept",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json) }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [
        1440,
        880
      ],
      "id": "5e21ac23-ee2d-4744-91c3-a795d25b3b84",
      "name": "Add to Reactivation List (Brevo Import)",
      "credentials": {
        "sendInBlueApi": {
          "id": "YOUR_BREVO_CREDENTIAL_ID",
          "name": "Brevo account"
        }
      },
      "onError": "continueErrorOutput",
      "notes": "One bulk call for the whole batch. Brevo processes imports asynchronously and answers with a processId."
    },
    {
      "parameters": {
        "jsCode": "return $('Select Old Leads').first().json.contacts.map(c => ({ json: c }));"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1680,
        880
      ],
      "id": "d5e071d0-ac92-473f-8eac-8258dfd4a364",
      "name": "One Item per Contact",
      "notes": "Only reached after the import succeeded, so nobody is marked as reactivated without actually being enrolled."
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "email": "={{ $json.email }}",
        "additionalFields": {
          "customPropertiesUi": {
            "customPropertiesValues": [
              {
                "property": "last_activity_at",
                "value": "={{ new Date($now).getTime() }}"
              },
              {
                "property": "outreach_stage",
                "value": "={{ $('Company Config (Old Leads)').first().json.reactivationStage }}"
              }
            ]
          }
        },
        "options": {
          "resolveData": false
        }
      },
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2.2,
      "position": [
        1920,
        880
      ],
      "id": "0c07c666-3b00-4ca0-a327-cbe11e17a9bf",
      "name": "Stamp Contact (Reactivation)",
      "credentials": {
        "hubspotOAuth2Api": {
          "id": "YOUR_HUBSPOT_CREDENTIAL_ID",
          "name": "HubSpot account"
        }
      },
      "onError": "continueRegularOutput",
      "notes": "Create-or-update by email. Writes the two fields both branches key on. Errors pass through as items so the metrics node can count them instead of aborting the run."
    },
    {
      "parameters": {
        "jsCode": "const config = $('Company Config (Old Leads)').first().json;\nconst hourlyRate = config.hourlyRate || 100;\nconst { count, scanned } = $('Select Old Leads').first().json;\n\n// Reached from the stamp node (count > 0) or straight from the IF (count = 0).\nconst stampFailures = $input.all().filter(r => r.json.error).length;\nconst timeSaved = (config.minutesPerContact || 2) * count;\n\nconst metrics = {\n  clients_reactivated: count,\n  time_saved: timeSaved,\n  cost_savings: Math.round(timeSaved * (hourlyRate / 60))\n};\n\nreturn [{ json: { metrics, count, scanned, stampFailures } }];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2160,
        900
      ],
      "id": "7f0129fd-d13b-43fb-9ddc-20b39d33c966",
      "name": "Calculate Old-Lead Metrics"
    },
    {
      "parameters": {
        "tableId": "automation_logs",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "customer_id",
              "fieldValue": "={{ $('Company Config (Old Leads)').first().json.customerId }}"
            },
            {
              "fieldId": "company_name",
              "fieldValue": "={{ $('Company Config (Old Leads)').first().json.companyName }}"
            },
            {
              "fieldId": "workflow_id",
              "fieldValue": "={{ $workflow.id }}"
            },
            {
              "fieldId": "workflow_name",
              "fieldValue": "={{ $('Company Config (Old Leads)').first().json.workflowName }}"
            },
            {
              "fieldId": "action_type",
              "fieldValue": "={{ $('Company Config (Old Leads)').first().json.actionType }}"
            },
            {
              "fieldId": "status",
              "fieldValue": "success"
            },
            {
              "fieldId": "metrics",
              "fieldValue": "={{ $json.metrics }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        2400,
        900
      ],
      "id": "41d3f9fc-d4d8-4941-a84e-f62f419a1408",
      "name": "Send Logs (Old Leads)",
      "credentials": {
        "supabaseApi": {
          "id": "YOUR_SUPABASE_CREDENTIAL_ID",
          "name": "Supabase Logging"
        }
      }
    },
    {
      "parameters": {
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "requestMethod": "POST",
        "url": "https://YOUR_BETTERSTACK_INGEST_HOST/",
        "options": {},
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "message",
              "value": "=Old-lead sweep: {{ $('Calculate Old-Lead Metrics').first().json.count }} of {{ $('Calculate Old-Lead Metrics').first().json.scanned }} contacts enrolled in reactivation\n    CRM stamp failures: {{ $('Calculate Old-Lead Metrics').first().json.stampFailures }}\n    workflow_name: {{ $workflow.name }}\n    execution_id: {{ $execution.id }}\n    mode: {{ $execution.mode }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        2640,
        900
      ],
      "id": "290ced6b-108d-43ea-9d6d-05820eb6648c",
      "name": "Log to BetterStack (Old Leads)",
      "credentials": {
        "httpBearerAuth": {
          "id": "YOUR_BETTERSTACK_CREDENTIAL_ID",
          "name": "BetterStack"
        }
      },
      "onError": "continueRegularOutput",
      "notes": "Operational log only. A BetterStack outage must never block the business log, so it runs last and cannot fail the execution."
    },
    {
      "parameters": {
        "jsCode": "// Shared by both lanes. Referencing a node that did not run on this path\n// throws, so each lookup is guarded.\nconst tryConfig = (name) => { try { return $(name).first().json; } catch (e) { return null; } };\nconst config = tryConfig('Company Config (New Leads)') || tryConfig('Company Config (Old Leads)');\n\nconst rows = $input.all();\nconst err = rows[0]?.json?.error;\nconst errorMessage = typeof err === 'string' ? err : (err?.message || JSON.stringify(err) || 'unknown error');\n\nreturn [{\n  json: {\n    config,\n    failedStep: $prevNode.name,\n    failedItems: rows.length,\n    errorMessage,\n    metrics: { time_saved: 0, cost_savings: 0 }\n  }\n}];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        0,
        1320
      ],
      "id": "6e885e37-7a5b-4954-87f8-ad9d40a02a9a",
      "name": "Calculate Failure Metrics"
    },
    {
      "parameters": {
        "tableId": "automation_logs",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "customer_id",
              "fieldValue": "={{ $json.config.customerId }}"
            },
            {
              "fieldId": "company_name",
              "fieldValue": "={{ $json.config.companyName }}"
            },
            {
              "fieldId": "workflow_id",
              "fieldValue": "={{ $workflow.id }}"
            },
            {
              "fieldId": "workflow_name",
              "fieldValue": "={{ $json.config.workflowName }}"
            },
            {
              "fieldId": "action_type",
              "fieldValue": "={{ $json.config.actionType }}"
            },
            {
              "fieldId": "status",
              "fieldValue": "failed"
            },
            {
              "fieldId": "metrics",
              "fieldValue": "={{ $json.metrics }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.supabase",
      "typeVersion": 1,
      "position": [
        240,
        1320
      ],
      "id": "187018bf-21f3-45c9-88db-a8cba3e53116",
      "name": "Send Logs (Failure)",
      "credentials": {
        "supabaseApi": {
          "id": "YOUR_SUPABASE_CREDENTIAL_ID",
          "name": "Supabase Logging"
        }
      }
    },
    {
      "parameters": {
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "requestMethod": "POST",
        "url": "https://YOUR_BETTERSTACK_INGEST_HOST/",
        "options": {},
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "message",
              "value": "=FAILED at {{ $('Calculate Failure Metrics').first().json.failedStep }} ({{ $('Calculate Failure Metrics').first().json.failedItems }} item(s))\n    error: {{ $('Calculate Failure Metrics').first().json.errorMessage }}\n    workflow_name: {{ $workflow.name }}\n    execution_id: {{ $execution.id }}\n    mode: {{ $execution.mode }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        480,
        1320
      ],
      "id": "7338ff8b-902f-42ac-bf6e-ff91134470eb",
      "name": "Log to BetterStack (Failure)",
      "credentials": {
        "httpBearerAuth": {
          "id": "YOUR_BETTERSTACK_CREDENTIAL_ID",
          "name": "BetterStack"
        }
      },
      "onError": "continueRegularOutput",
      "notes": "Operational log only. A BetterStack outage must never block the business log, so it runs last and cannot fail the execution."
    }
  ],
  "pinData": {},
  "connections": {
    "New Lead (HubSpot Webhook)": {
      "main": [
        [
          {
            "node": "Company Config (New Leads)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Company Config (New Leads)": {
      "main": [
        [
          {
            "node": "Split HubSpot Events",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split HubSpot Events": {
      "main": [
        [
          {
            "node": "Only Contact Creations",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Only Contact Creations": {
      "main": [
        [
          {
            "node": "Get Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Contact": {
      "main": [
        [
          {
            "node": "Has Email & Not Enrolled?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Calculate Failure Metrics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Email & Not Enrolled?": {
      "main": [
        [
          {
            "node": "Add to Nurture List (Brevo)",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Add to Nurture List (Brevo)": {
      "main": [
        [
          {
            "node": "Stamp Contact (New)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Calculate Failure Metrics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Stamp Contact (New)": {
      "main": [
        [
          {
            "node": "Calculate New-Lead Metrics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate New-Lead Metrics": {
      "main": [
        [
          {
            "node": "Send Logs (New Leads)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Logs (New Leads)": {
      "main": [
        [
          {
            "node": "Log to BetterStack (New Leads)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Monthly Sweep (1st, 07:00)": {
      "main": [
        [
          {
            "node": "Company Config (Old Leads)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Company Config (Old Leads)": {
      "main": [
        [
          {
            "node": "Get All Contacts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get All Contacts": {
      "main": [
        [
          {
            "node": "Select Old Leads",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Calculate Failure Metrics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Select Old Leads": {
      "main": [
        [
          {
            "node": "Any Old Leads?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Any Old Leads?": {
      "main": [
        [
          {
            "node": "Format for Brevo Import",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Calculate Old-Lead Metrics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format for Brevo Import": {
      "main": [
        [
          {
            "node": "Add to Reactivation List (Brevo Import)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add to Reactivation List (Brevo Import)": {
      "main": [
        [
          {
            "node": "One Item per Contact",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Calculate Failure Metrics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "One Item per Contact": {
      "main": [
        [
          {
            "node": "Stamp Contact (Reactivation)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Stamp Contact (Reactivation)": {
      "main": [
        [
          {
            "node": "Calculate Old-Lead Metrics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate Old-Lead Metrics": {
      "main": [
        [
          {
            "node": "Send Logs (Old Leads)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Logs (Old Leads)": {
      "main": [
        [
          {
            "node": "Log to BetterStack (Old Leads)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate Failure Metrics": {
      "main": [
        [
          {
            "node": "Send Logs (Failure)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Logs (Failure)": {
      "main": [
        [
          {
            "node": "Log to BetterStack (Failure)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  }
}

We built this combined version for this page out of our two production workflows. It uses the same node types and API calls we run, but it hasn't run on our own instance in this exact form, so treat the one-contact test as mandatory.

Companion Claude Skill

Set it up with your assistant

The setup and adaptation steps as a Claude Skill. It walks your assistant through the CRM fields, the two email-tool automations, the placeholders, and a safe first test. It also covers what has to stay true if you swap HubSpot or Brevo for something else.

lead-email-sequence-n8n/SKILL.md
---
name: lead-email-sequence-n8n
description: Stand up (or adapt) a combined new-lead nurture + old-lead reactivation email sequence in n8n, driven by one CRM timestamp, from the importable "New & Old Lead Email Sequence" workflow.
version: 1.0.0
license: MIT
---

# New and old lead email sequence in n8n

Sets up one n8n workflow with two lanes. New leads are enrolled in a nurture
sequence the moment they are created in the CRM. Once a month, leads whose
newest touch is older than a threshold (default 90 days) are enrolled in a
reactivation sequence. Both lanes read and write the same two CRM fields, which
is what keeps them from stepping on each other.

## When to use

- "Set up an email sequence for new leads and for old / cold leads."
- "Import this lead email workflow into our n8n and make it work."
- "We use Pipedrive / ActiveCampaign / Mailchimp instead, adapt it."

Not for: writing the email copy itself, or one-off broadcast campaigns.

## How it works (keep these true when adapting)

1. **n8n enrolls, the email tool sends.** Each lane only adds contacts to a
   list. The email tool runs the actual sequence from a "contact added to
   list" automation. If that automation is off, contacts pile up in the list
   and receive nothing.
2. **One stage field gates enrollment.** `outreach_stage` must be empty for a
   new lead to be enrolled, and the lane writes it right after enrolling. The
   gate must check the same field the lane writes, or it never matches.
3. **One timestamp drives "old".** `last_activity_at` (milliseconds) is written
   on every enrollment AND by anything that records a real touch: an inbound
   email agent on every reply, a booking flow, a form handler. The old-lead
   lane uses the newest of that field, the CRM's own last-activity date, and
   the create date, so contacts that predate the workflow still qualify.
4. **Stamp only after the email tool accepted the enrollment.** Otherwise a
   failed import marks people as reactivated who never got an email.
5. **Every run logs, including empty ones.** The selection step always returns
   exactly one summary item, so a month with zero matches writes a 0 instead
   of silently skipping the log.

## Procedure

1. **CRM fields.** Create two contact properties:
   - `outreach_stage`: single-line text
   - `last_activity_at`: number (holds a millisecond timestamp). Don't use a
     date-only field. Those only accept midnight UTC and will reject "now".
2. **Email tool.** Create two lists and one automation per list, entry point
   "contact added to list", set to run **only once per contact**, with a real
   reply-to inbox. Cadence we use:
   - Nurture, 5 emails over 14 days: day 0 welcome, day 2 case study, day 5
     core value, day 7 objection handling, day 14 soft close.
   - Reactivation, 3 emails over 14 days: day 0 check-in, day 7 something
     new, day 14 final note. Never mention the gap length in the copy.
3. **Import the workflow** (paste the JSON onto an empty n8n canvas) and
   replace every `YOUR_*` placeholder:
   - Both Company Config nodes: `customerId` (your own UUID), `companyName`,
     the numeric list ids.
   - Credentials: HubSpot OAuth2, Brevo, Supabase, BetterStack bearer.
   - BetterStack URL, the webhook path (long and unguessable), and the
     workflow's Error Workflow setting.
   - Leave the Company Config value as a JSON **string**. An object there
     throws `jsonOutput?.startsWith is not a function` at runtime.
4. **Logging table.** Create `automation_logs` (id, customer_id uuid,
   company_name, workflow_id, workflow_name, action_type, status, metrics
   jsonb, created_at). If you don't want logging, delete the Send Logs and
   BetterStack nodes on all three paths. Don't leave them half-configured.
5. **CRM webhook.** Subscribe your CRM app to contact creation, pointed at
   the workflow's production URL.
6. **Test the new-lead lane** with one test contact. Confirm: list add in the
   email tool, `outreach_stage = New` and a fresh `last_activity_at` on the
   contact, one success row in `automation_logs`. Then re-send the same event
   and confirm nothing is enrolled twice.
7. **Test the old-lead lane safely.** Before the first real run, add a
   temporary line at the top of the Select Old Leads loop that skips every
   email except your test contact's, backdate that contact's
   `last_activity_at`, and execute the lane manually. Confirm the import, the
   `Reactivation` stamp and the log row, then remove the line.
8. Activate.

## Adapting to another CRM or email tool

- Replace the trigger with the CRM's "contact created" event. If it batches
  events, split the batch before anything else.
- Replace the contact fetch with whatever lists contacts with the five fields
  the selector needs (email, names, stage, lead/lifecycle status, dates). Past
  a few thousand contacts, use a server-side date filter instead of fetching
  everyone.
- Replace the two list-add calls. Bulk import for the monthly lane, single
  add for the new-lead lane.
- Keep rules 2 to 5 above exactly. They are the whole design.

## Pitfalls

- **Reading only the first webhook event.** Batched CRM webhooks carry
  several events per request. `body[0]` silently drops the rest.
- **Comparing against values your CRM doesn't use.** Check the real internal
  values of lead status and lifecycle stage in your account before filling
  the skip lists. A deal-stage value in a lead-status filter excludes nobody.
- **Reading optional properties without a default.** CRMs often omit empty
  properties from responses. One contact with no first name can throw and
  take the whole batch with it.
- **Treating enrollment as delivery.** Joining a list sends nothing. Log
  enrollments; get deliveries, opens and clicks from the email tool's events.
- **No exit on reply.** If nothing writes `last_activity_at` when a lead
  replies, the monthly sweep will email people you are already talking to.
- **An unverified public webhook.** Verify the CRM's request signature, or at
  least keep the path long and private.

## Verification

- [ ] Both CRM properties exist, `last_activity_at` is a number.
- [ ] Both email automations are active, once per contact, real reply-to.
- [ ] No `YOUR_` placeholder left anywhere in the workflow.
- [ ] New-lead test: enrolled once, stamped, logged; replay enrolls nobody.
- [ ] Old-lead test: only the test contact selected, imported, stamped,
      logged; temporary filter removed afterwards.
- [ ] An empty month logs a row with `clients_reactivated: 0`.
- [ ] Something in your stack writes `last_activity_at` when a lead replies.

Save it as lead-email-sequence-n8n/SKILL.md in your skills directory. Works in Claude Code, Claude Desktop, or any agent that reads SKILL.md files.

Questions about any of this?

Happy to talk through how this would map onto your CRM and email tool — no pitch, just answers.

Azuro AI · Built from our own production n8n workflows and engineering notes. Client names, tenant identifiers, credential IDs and endpoints have been removed. Every incident described is real and dated in our internal records.