{
  "name": "Build a lead list in Google Sheets from a plain-English search with verified work emails using PeopleSearch.im",
  "nodes": [
    {
      "parameters": {
        "formTitle": "Build a lead list with verified work emails",
        "formDescription": "Describe the people you want in plain English. They are added to your Google Sheet with their verified work emails.",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Who are you looking for?",
              "fieldType": "textarea",
              "placeholder": "Heads of Marketing at SaaS companies in New York",
              "requiredField": true
            },
            {
              "fieldLabel": "How many people?",
              "fieldType": "number",
              "placeholder": "25 (1 to 100)",
              "requiredField": true
            }
          ]
        },
        "options": {}
      },
      "id": "b1",
      "name": "Describe the people you want",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.2,
      "position": [
        0,
        0
      ],
      "webhookId": "peoplesearch-lead-list"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://peoplesearch.im/api/v1/deliver",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ query: $json['Who are you looking for?'], count: Math.min(100, Math.max(1, Number($json['How many people?']) || 10)), withEmail: true }) }}",
        "options": {
          "timeout": 120000,
          "response": {
            "response": {
              "fullResponse": true,
              "neverError": true
            }
          }
        }
      },
      "id": "b2",
      "name": "Find people with work emails (PeopleSearch.im)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        240,
        0
      ],
      "retryOnFail": true,
      "maxTries": 2,
      "waitBetweenTries": 3000,
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "jsCode": "// One item per person found, in the sheet's columns. A refusal becomes one row whose Email status is the API's\n// own sentence (for example how to add credits), so the run never ends silently.\nconst res = $input.first().json;\nconst body = res.body || {};\nconst people = Array.isArray(body.profiles) ? body.profiles : [];\nif (!people.length) {\n  return [{ json: { Name: '', 'Job title': '', Company: '', Website: '', Location: '', LinkedIn: '', Email: '', 'Email status': body.message || body.error || (res.error && res.error.message) || 'Nobody matched this search. Try fewer words or a wider place.' } }];\n}\nreturn people.map((item) => {\n  const p = item.profile || {};\n  const status = p.emailStatus === 'found' ? (/ultra|very|^sure/i.test(p.emailCertainty || '') ? 'Verified' : 'Likely') : p.emailStatus === 'searching' ? 'searching' : p.emailStatus === 'unconfirmed' ? 'Unconfirmed' : 'No work email found';\n  return { json: { Name: p.name || '', 'Job title': p.title || '', Company: p.company || '', Website: p.companyWebsite || '', Location: p.location || '', LinkedIn: p.linkedinUrl || '', Email: p.emailStatus === 'found' ? (p.email || '') : '', 'Email status': status } };\n});"
      },
      "id": "b3",
      "name": "One row per person",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        480,
        0
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [],
          "schema": [
            {
              "id": "Name",
              "displayName": "Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Job title",
              "displayName": "Job title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Company",
              "displayName": "Company",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Website",
              "displayName": "Website",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Location",
              "displayName": "Location",
              "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
            },
            {
              "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
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "id": "b4",
      "name": "Add the people to the sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        720,
        0
      ]
    },
    {
      "parameters": {
        "content": "## Build a lead list in Google Sheets from a plain-English search\n\nType who you are looking for, in plain English, and how many. [PeopleSearch.im](https://peoplesearch.im/developers) finds those people with their verified work emails, and each one is added to your Google Sheet as a row: name, job title, company, website, location, LinkedIn profile, email and how sure the email is.\n\n**Who it is for:** founders, sales and recruiting teams who build prospect or candidate lists by hand today.\n\n### How it works\n1. The form asks who you want (for example \"Heads of Marketing at SaaS companies in New York\") and how many (1 to 100).\n2. One call to PeopleSearch.im finds them and looks up each person's verified work email.\n3. Each person becomes a row in your sheet. Run the form again for the next list.\n\n### Set up (5 minutes)\n1. Make a sheet whose first row has the columns **Name**, **Job title**, **Company**, **Website**, **Location**, **LinkedIn**, **Email**, **Email status**.\n2. Get an API key at peoplesearch.im/developers (new accounts get free credits).\n3. In **Find people with work emails (PeopleSearch.im)**, create a **Header Auth** credential: Name `Authorization`, Value `Bearer sk_sift_...` (your key).\n4. In **Add the people to the sheet**, pick your Google Sheets credential, file and sheet.\n5. Open the form (the Form Trigger's test or production URL) and ask for 5 people first.\n\n### Cost\n1 PeopleSearch.im credit per person, plus 1 per verified email found (refunded when none is found). People you already got before are free.",
        "height": 820,
        "width": 540,
        "color": 4
      },
      "id": "m1",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -620,
        -320
      ]
    },
    {
      "parameters": {
        "content": "### The search\nOne POST to `https://peoplesearch.im/api/v1/deliver` with your words as `query`, the number as `count` and `withEmail: true`. The call waits about 12 seconds for the emails; an email still being looked up is written as **searching**. When the account runs out of credits, the answer says so with a link to buy more for this account, and that sentence is written into **Email status** so you see it in the sheet.",
        "height": 300,
        "width": 420,
        "color": 7
      },
      "id": "m2",
      "name": "The search",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        160,
        -360
      ]
    }
  ],
  "connections": {
    "Describe the people you want": {
      "main": [
        [
          {
            "node": "Find people with work emails (PeopleSearch.im)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find people with work emails (PeopleSearch.im)": {
      "main": [
        [
          {
            "node": "One row per person",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "One row per person": {
      "main": [
        [
          {
            "node": "Add the people to the sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "active": false
}
