{
  "name": "Clean a lead list and sort it by sendability with ListVetted",
  "nodes": [
    {
      "parameters": {
        "content": "## Clean a lead list and sort it by sendability\n\nTakes every new row from a Google Sheet, sends them to ListVetted in one bulk request (up to 10,000 addresses), waits for ListVetted's finished-notification, then sorts each lead into **Ready to send**, **Needs a look** or **Suppressed** tabs, marks the original rows, and posts a summary to Slack.\n\n**Who it is for:** sales teams doing cold outreach, marketing teams before a newsletter, agencies and recruiters importing contact lists, event organisers cleaning registrations.\n\n**What makes it different:** no polling. The workflow pauses on a Wait node and ListVetted resumes it by webhook the moment the list is done. Role addresses (info@, sales@) are valid but rarely reply, so they go to review instead of Ready.",
        "height": 400,
        "width": 520
      },
      "id": "a1",
      "name": "Overview note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -120,
        -140
      ]
    },
    {
      "parameters": {
        "content": "## Setup (about 10 minutes)\n\n1. Create a free account at listvetted.com and an API key (250 free credits).\n2. In n8n create a **Header Auth** credential: Name `X-API-Key`, Value = your key. Select it in both ListVetted nodes (**Submit list**, **Get results**).\n3. Connect Google Sheets in every Google Sheets node, and Slack in the two Slack nodes (or delete them).\n4. In your spreadsheet create four tabs:\n   - `Leads` with columns `Email`, `Status`, `Reason`, `Route` (add any other columns you like)\n   - `Ready`, `Review`, `Suppressed` with columns `Email`, `Status`, `Reason`, `Role address`, `Free provider`, `Typo suggestion`, `Checked at`\n5. Open **Settings** and enter your spreadsheet ID, tab names and Slack channel.\n6. Run it manually, or activate the workflow to run every weekday at 8am.\n\n**Cost:** one credit per address. Unknown results are refunded automatically. Rows that already have a Status are skipped, so re-running never pays twice.\n\n**Tip:** duplicate addresses are checked once, and only the first matching row in Leads gets marked, so remove duplicate rows to keep the sheet tidy.",
        "height": 470,
        "width": 520
      },
      "id": "a2",
      "name": "Setup note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -120,
        300
      ]
    },
    {
      "parameters": {
        "content": "## How leads are sorted\n\n- **Ready:** status valid and not a role address\n- **Review:** risky, unknown, or a valid role address (info@, sales@...)\n- **Suppressed:** invalid (typo, disposable, no such mailbox)\n\nEach original row also gets Status, Reason and Route so you can filter in the source tab.",
        "height": 230,
        "width": 420
      },
      "id": "a3",
      "name": "Routing note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        2000,
        -140
      ]
    },
    {
      "parameters": {},
      "id": "b1",
      "name": "Run manually",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        460,
        60
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 8 * * 1-5"
            }
          ]
        }
      },
      "id": "b2",
      "name": "Every weekday at 8am",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        460,
        240
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "s1",
              "name": "spreadsheet_id",
              "value": "PASTE_YOUR_SPREADSHEET_ID_HERE",
              "type": "string"
            },
            {
              "id": "s2",
              "name": "leads_tab",
              "value": "Leads",
              "type": "string"
            },
            {
              "id": "s3",
              "name": "ready_tab",
              "value": "Ready",
              "type": "string"
            },
            {
              "id": "s4",
              "name": "review_tab",
              "value": "Review",
              "type": "string"
            },
            {
              "id": "s5",
              "name": "suppressed_tab",
              "value": "Suppressed",
              "type": "string"
            },
            {
              "id": "s6",
              "name": "slack_channel",
              "value": "leads",
              "type": "string"
            },
            {
              "id": "s7",
              "name": "list_name",
              "value": "n8n lead check",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "b3",
      "name": "Settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        700,
        140
      ]
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Settings').first().json.spreadsheet_id }}"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('Settings').first().json.leads_tab }}"
        },
        "options": {}
      },
      "id": "b4",
      "name": "Read leads",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        920,
        140
      ]
    },
    {
      "parameters": {
        "jsCode": "const MAX = 10000;\nconst seen = new Set();\nconst emails = [];\nfor (const item of $input.all()) {\n  const email = String(item.json.Email || '').trim();\n  const checked = String(item.json.Status || '').trim();\n  const key = email.toLowerCase();\n  if (!email || checked || seen.has(key)) continue;\n  seen.add(key);\n  emails.push(email);\n}\nreturn [{ json: { emails: emails.slice(0, MAX), found: emails.length, over_limit: Math.max(0, emails.length - MAX) } }];"
      },
      "id": "b5",
      "name": "Collect unchecked emails",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1140,
        140
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $json.emails.length }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "b6",
      "name": "Any new leads?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1360,
        140
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.listvetted.com/v1/lists",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { \"name\": $('Settings').first().json.list_name + ' ' + $now.toFormat('yyyy-LL-dd HH:mm'), \"emails\": $json.emails, \"webhook_url\": $execution.resumeUrl } }}",
        "options": {
          "timeout": 120000
        },
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "id": "b7",
      "name": "Submit list",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1580,
        60
      ],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "e1",
              "name": "text",
              "value": "={{ 'ListVetted could not start the check: ' + ($json.error && $json.error.message ? $json.error.message : 'unknown error') + ' (402 means no credits left: add credits at app.listvetted.com/buy).' }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "b8",
      "name": "Explain error",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1800,
        260
      ]
    },
    {
      "parameters": {
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('Settings').first().json.slack_channel }}"
        },
        "text": "={{ $json.text }}",
        "otherOptions": {}
      },
      "id": "b9",
      "name": "Report error",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        2020,
        260
      ]
    },
    {
      "parameters": {
        "resume": "webhook",
        "httpMethod": "POST",
        "limitWaitTime": true,
        "limitType": "afterTimeInterval",
        "resumeAmount": 2,
        "resumeUnit": "hours",
        "options": {}
      },
      "id": "b10",
      "name": "Wait for ListVetted",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1800,
        60
      ],
      "webhookId": "7d2f0c84-3b1e-4a65-9c1d-2e8f5a6b7c90"
    },
    {
      "parameters": {
        "url": "={{ 'https://api.listvetted.com/v1/lists/' + $('Submit list').item.json.id + '/results' }}",
        "options": {
          "timeout": 120000
        },
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "id": "b11",
      "name": "Get results",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2020,
        60
      ]
    },
    {
      "parameters": {
        "fieldToSplitOut": "results",
        "options": {}
      },
      "id": "b12",
      "name": "One item per lead",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        2240,
        0
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "r1",
              "name": "route",
              "value": "={{ ($json.status === 'valid' && $json.role !== true) ? 'Ready' : ($json.status === 'invalid' ? 'Suppressed' : 'Review') }}",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "id": "b13",
      "name": "Decide route",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        2460,
        0
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "w1",
                    "leftValue": "={{ $json.route }}",
                    "rightValue": "Ready",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Ready"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "w2",
                    "leftValue": "={{ $json.route }}",
                    "rightValue": "Suppressed",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Suppressed"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra",
          "renameFallbackOutput": "Review"
        }
      },
      "id": "b14",
      "name": "Route lead",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        2680,
        -80
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Settings').first().json.spreadsheet_id }}"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('Settings').first().json.ready_tab }}"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Email": "={{ $json.email }}",
            "Status": "={{ $json.status }}",
            "Reason": "={{ $json.explanation }}",
            "Role address": "={{ $json.role ? 'yes' : 'no' }}",
            "Free provider": "={{ $json.free ? 'yes' : 'no' }}",
            "Typo suggestion": "={{ $json.typo_suggestion }}",
            "Checked at": "={{ $now.toFormat('yyyy-LL-dd HH:mm') }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Email",
              "displayName": "Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Reason",
              "displayName": "Reason",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Role address",
              "displayName": "Role address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Free provider",
              "displayName": "Free provider",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Typo suggestion",
              "displayName": "Typo suggestion",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Checked at",
              "displayName": "Checked at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {}
      },
      "id": "b15",
      "name": "Add to Ready tab",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        2920,
        -200
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Settings').first().json.spreadsheet_id }}"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('Settings').first().json.suppressed_tab }}"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Email": "={{ $json.email }}",
            "Status": "={{ $json.status }}",
            "Reason": "={{ $json.explanation }}",
            "Role address": "={{ $json.role ? 'yes' : 'no' }}",
            "Free provider": "={{ $json.free ? 'yes' : 'no' }}",
            "Typo suggestion": "={{ $json.typo_suggestion }}",
            "Checked at": "={{ $now.toFormat('yyyy-LL-dd HH:mm') }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Email",
              "displayName": "Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Reason",
              "displayName": "Reason",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Role address",
              "displayName": "Role address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Free provider",
              "displayName": "Free provider",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Typo suggestion",
              "displayName": "Typo suggestion",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Checked at",
              "displayName": "Checked at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {}
      },
      "id": "b16",
      "name": "Add to Suppressed tab",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        2920,
        -40
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Settings').first().json.spreadsheet_id }}"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('Settings').first().json.review_tab }}"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Email": "={{ $json.email }}",
            "Status": "={{ $json.status }}",
            "Reason": "={{ $json.explanation }}",
            "Role address": "={{ $json.role ? 'yes' : 'no' }}",
            "Free provider": "={{ $json.free ? 'yes' : 'no' }}",
            "Typo suggestion": "={{ $json.typo_suggestion }}",
            "Checked at": "={{ $now.toFormat('yyyy-LL-dd HH:mm') }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Email",
              "displayName": "Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Reason",
              "displayName": "Reason",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Role address",
              "displayName": "Role address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Free provider",
              "displayName": "Free provider",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Typo suggestion",
              "displayName": "Typo suggestion",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Checked at",
              "displayName": "Checked at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {}
      },
      "id": "b17",
      "name": "Add to Review tab",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        2920,
        120
      ]
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Settings').first().json.spreadsheet_id }}"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('Settings').first().json.leads_tab }}"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Email": "={{ $json.email }}",
            "Status": "={{ $json.status }}",
            "Reason": "={{ $json.explanation }}",
            "Route": "={{ $json.route }}"
          },
          "matchingColumns": [
            "Email"
          ],
          "schema": [
            {
              "id": "Email",
              "displayName": "Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Reason",
              "displayName": "Reason",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Route",
              "displayName": "Route",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {}
      },
      "id": "b18",
      "name": "Mark lead as checked",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        2680,
        200
      ]
    },
    {
      "parameters": {
        "jsCode": "const rows = $('Get results').first().json.results || [];\nconst meta = $('Get results').first().json;\nconst route = r => (r.status === 'valid' && r.role !== true) ? 'ready' : (r.status === 'invalid' ? 'suppressed' : 'review');\nconst n = { ready: 0, review: 0, suppressed: 0 };\nfor (const r of rows) n[route(r)]++;\nconst refunded = meta.refunded || 0;\nconst text = `ListVetted finished checking ${rows.length} leads.\\n` +\n  `Ready to send: ${n.ready}\\nNeeds a look (risky, unknown or role address): ${n.review}\\nSuppressed (invalid): ${n.suppressed}` +\n  (refunded ? `\\nCredits refunded for unchecked addresses: ${refunded}` : '');\nreturn [{ json: { text, ...n } }];"
      },
      "id": "b19",
      "name": "Build summary",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2240,
        200
      ]
    },
    {
      "parameters": {
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('Settings').first().json.slack_channel }}"
        },
        "text": "={{ $json.text }}",
        "otherOptions": {}
      },
      "id": "b20",
      "name": "Post summary",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        2460,
        300
      ]
    }
  ],
  "connections": {
    "Run manually": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every weekday at 8am": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings": {
      "main": [
        [
          {
            "node": "Read leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read leads": {
      "main": [
        [
          {
            "node": "Collect unchecked emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Collect unchecked emails": {
      "main": [
        [
          {
            "node": "Any new leads?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Any new leads?": {
      "main": [
        [
          {
            "node": "Submit list",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Submit list": {
      "main": [
        [
          {
            "node": "Wait for ListVetted",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Explain error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Explain error": {
      "main": [
        [
          {
            "node": "Report error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for ListVetted": {
      "main": [
        [
          {
            "node": "Get results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get results": {
      "main": [
        [
          {
            "node": "One item per lead",
            "type": "main",
            "index": 0
          },
          {
            "node": "Build summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "One item per lead": {
      "main": [
        [
          {
            "node": "Decide route",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Decide route": {
      "main": [
        [
          {
            "node": "Route lead",
            "type": "main",
            "index": 0
          },
          {
            "node": "Mark lead as checked",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route lead": {
      "main": [
        [
          {
            "node": "Add to Ready tab",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Add to Suppressed tab",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Add to Review tab",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build summary": {
      "main": [
        [
          {
            "node": "Post summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  }
}