{
  "name": "Enrich a Google Sheet of names and companies with verified work emails using PeopleSearch.im",
  "nodes": [
    {
      "parameters": {},
      "id": "a1",
      "name": "When clicking 'Execute workflow'",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "options": {}
      },
      "id": "a2",
      "name": "Read contacts from the sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $json.Email }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      },
      "id": "a3",
      "name": "Only rows without an email",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        440,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://peoplesearch.im/api/v1/tools",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ tool: 'work-email-finder', input: { firstname: $json['First name'], lastname: $json['Last name'], domainOrCompany: $json.Company } }) }}",
        "options": {
          "batching": {
            "batch": {
              "batchSize": 5,
              "batchInterval": 1000
            }
          },
          "response": {
            "response": {
              "fullResponse": true,
              "neverError": true
            }
          }
        }
      },
      "id": "a4",
      "name": "Find work email (PeopleSearch.im)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        0
      ],
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 2000,
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "s1",
              "name": "row_number",
              "value": "={{ $('Read contacts from the sheet').item.json.row_number }}",
              "type": "number"
            },
            {
              "id": "s2",
              "name": "Email",
              "value": "={{ $json.body?.result?.found ? $json.body.result.profile.email : '' }}",
              "type": "string"
            },
            {
              "id": "s3",
              "name": "Email status",
              "value": "={{ $json.body?.result?.found ? (/ultra|very|^sure/i.test($json.body.result.profile.emailCertainty || '') ? 'Verified' : 'Likely') : $json.body?.result?.message || $json.body?.message || $json.error?.message || 'No work email found' }}",
              "type": "string"
            },
            {
              "id": "s4",
              "name": "LinkedIn",
              "value": "={{ $json.body?.result?.profile?.linkedinUrl || '' }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "a5",
      "name": "Pick email, status and LinkedIn",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        880,
        0
      ]
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "operation": "update",
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "row_number": "={{ $json.row_number }}",
            "Email": "={{ $json.Email }}",
            "Email status": "={{ $json['Email status'] }}",
            "LinkedIn": "={{ $json.LinkedIn }}"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "readOnly": true,
              "removed": false
            },
            {
              "id": "Email",
              "displayName": "Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Email status",
              "displayName": "Email status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "LinkedIn",
              "displayName": "LinkedIn",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "id": "a6",
      "name": "Write the email back to the row",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1100,
        0
      ]
    },
    {
      "parameters": {
        "content": "## Enrich a Google Sheet with verified work emails\n\nFills the **Email** column of a contact list (names and companies) with each person's verified work email, using [PeopleSearch.im](https://peoplesearch.im/developers). Rows that already have an email are skipped, so you can run it again after adding rows.\n\n**Who it is for:** sales and recruiting teams with a lead list, an event attendee list or a CRM export that has names and companies but no emails.\n\n### How it works\n1. Reads every row of your sheet.\n2. Keeps the rows whose Email cell is empty.\n3. Asks PeopleSearch.im for each person's work email, 5 at a time.\n4. Writes the email, how sure it is and the LinkedIn profile back into the same row.\n\n### Set up (5 minutes)\n1. Make a sheet with the columns **First name**, **Last name**, **Company**, **Email**, **Email status**, **LinkedIn** (Company can be a website such as acme.com, which matches best, or a name).\n2. Get an API key at peoplesearch.im/developers (new accounts get free credits).\n3. In **Find work email (PeopleSearch.im)**, create a **Header Auth** credential: Name `Authorization`, Value `Bearer sk_sift_...` (your key).\n4. Pick your Google Sheets credential, file and sheet in the two Google Sheets nodes.\n5. Run it on a few rows first.\n\n### Cost\n2 PeopleSearch.im credits per email found. A person with no email found costs nothing.",
        "height": 760,
        "width": 520,
        "color": 4
      },
      "id": "n1",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -600,
        -300
      ]
    },
    {
      "parameters": {
        "content": "### The lookup\nOne POST to `https://peoplesearch.im/api/v1/tools` per row with the **work-email-finder** tool. Batching sends 5 rows a second. Every answer is kept: a row with no email found, a run that runs out of credits or a lookup the service could not answer right now writes the reason into **Email status** and leaves **Email** empty, so the next run picks that row up again. A network failure is retried twice.",
        "height": 300,
        "width": 420,
        "color": 7
      },
      "id": "n2",
      "name": "The lookup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        560,
        -340
      ]
    },
    {
      "parameters": {
        "content": "### Write back\nUpdates the same row (matched on `row_number`). Only rows where an email was found get an address; every looked-up row gets a status.",
        "height": 220,
        "width": 380,
        "color": 7
      },
      "id": "n3",
      "name": "Write back",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1020,
        -260
      ]
    }
  ],
  "connections": {
    "When clicking 'Execute workflow'": {
      "main": [
        [
          {
            "node": "Read contacts from the sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read contacts from the sheet": {
      "main": [
        [
          {
            "node": "Only rows without an email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Only rows without an email": {
      "main": [
        [
          {
            "node": "Find work email (PeopleSearch.im)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find work email (PeopleSearch.im)": {
      "main": [
        [
          {
            "node": "Pick email, status and LinkedIn",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pick email, status and LinkedIn": {
      "main": [
        [
          {
            "node": "Write the email back to the row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "active": false
}
