{
  "name": "Verifly - Clean a Google Sheet column",
  "nodes": [
    {
      "parameters": {
        "content": "## Clean a Google Sheet\nSheet needs columns: email, verifly_result, verifly_reason.\n1. Pick your Google Sheets credential + document in both Sheets nodes.\n2. Set env VERIFLY_API_KEY.\n3. Run. Rows already having verifly_result are skipped.\n1 credit per deliverable/undeliverable; catch-all & unknown free.",
        "height": 260,
        "width": 380
      },
      "id": "note",
      "name": "Read me",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {},
      "id": "t",
      "name": "Run manually",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        320
      ]
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Sheet1"
        },
        "options": {}
      },
      "id": "r",
      "name": "Read rows",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        220,
        320
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "f1",
              "leftValue": "={{ $json.verifly_result }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              }
            },
            {
              "id": "f2",
              "leftValue": "={{ $json.email }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "f",
      "name": "Only unchecked rows",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2,
      "position": [
        440,
        320
      ]
    },
    {
      "parameters": {
        "url": "=https://verifly.email/api/v1/verify",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "email",
              "value": "={{ $json.email.trim() }}"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $env.VERIFLY_API_KEY }}"
            }
          ]
        },
        "options": {
          "batching": {
            "batch": {
              "batchSize": 5,
              "batchInterval": 1000
            }
          },
          "response": {
            "response": {
              "neverError": true
            }
          }
        }
      },
      "id": "v",
      "name": "Verifly verify",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        320
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1",
              "name": "email",
              "value": "={{ $('Only unchecked rows').item.json.email }}",
              "type": "string"
            },
            {
              "id": "a2",
              "name": "verifly_result",
              "value": "={{ $json.result || ($json.error && $json.error.code) || 'error' }}",
              "type": "string"
            },
            {
              "id": "a3",
              "name": "verifly_reason",
              "value": "={{ $json.reason || '' }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "m",
      "name": "Map result",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        880,
        320
      ]
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Sheet1"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [
            "email"
          ]
        },
        "options": {}
      },
      "id": "u",
      "name": "Write back",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1100,
        320
      ]
    }
  ],
  "connections": {
    "Run manually": {
      "main": [
        [
          {
            "node": "Read rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read rows": {
      "main": [
        [
          {
            "node": "Only unchecked rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Only unchecked rows": {
      "main": [
        [
          {
            "node": "Verifly verify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Verifly verify": {
      "main": [
        [
          {
            "node": "Map result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map result": {
      "main": [
        [
          {
            "node": "Write back",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {}
}