{
  "name": "Enrich companies in Google Sheets with LinkedIn data using Apify",
  "nodes": [
    {
      "parameters": {
        "content": "## Enrich companies in Google Sheets with LinkedIn data\n\n**Who's it for**\nSales, marketing and research teams with a list of companies in a sheet who want each row filled in from the company's LinkedIn page.\n\n**How it works**\n1. You start the workflow by hand when the sheet has new companies.\n2. The Set node holds your Google Sheet and how many companies to enrich per run.\n3. Google Sheets reads the rows. Rows with a LinkedIn company URL in `url` and nothing in `name` yet are kept.\n4. The Apify node runs the [LinkedIn Company Scraper](https://apify.com/logical_scrapers/linkedin-company-scraper?utm_source=n8n&utm_medium=template&utm_campaign=enrich-companies-with-linkedin-data) Actor on those URLs. No LinkedIn account or cookies are needed.\n5. Each company's details are written back to its row, matched on `url`.\n\n**How to set up**\n1. Install the Apify community node (`@apify/n8n-nodes-apify`) and connect your Apify account in the Apify node.\n2. Connect your Google account in both Google Sheets nodes.\n3. Create a sheet with this header row:\n`url, name, website, industry, companySize, numberOfEmployees, followersCount, headquarters, description`\n4. Put LinkedIn company page URLs in the `url` column, for example `https://www.linkedin.com/company/microsoft/`.\n5. Open **Set sheet and limits** and enter the sheet URL.\n\n**Requirements**\nAn Apify account (the Actor is pay per result, see its Store page for the price) and a Google account.\n\nSetup guide: https://www.logicalscrapers.com/integrations/n8n#enrich-companies-with-linkedin-data",
        "height": 700,
        "width": 560
      },
      "id": "4ddedd63-5ee6-4402-a1ba-6bdf503d5853",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -680,
        -260
      ]
    },
    {
      "parameters": {
        "content": "### 1. Your settings\nEdit **Set sheet and limits**: the Google Sheet, the tab name, how many companies to enrich per run and a spend limit per run.",
        "height": 420,
        "width": 440,
        "color": 7
      },
      "id": "3364b12f-6212-47e9-ae21-288d6da627a6",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -60,
        -260
      ]
    },
    {
      "parameters": {
        "content": "### 2. Find rows to enrich\nReads the sheet and keeps rows that have a LinkedIn company URL in `url` and an empty `name`. Rows already filled in are skipped, so you can run it again after adding companies.",
        "height": 420,
        "width": 860,
        "color": 7
      },
      "id": "f2087b34-cd9f-4f9f-aebc-cd25ab3876c1",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        420,
        -260
      ]
    },
    {
      "parameters": {
        "content": "### 3. Scrape and write back\nRuns the LinkedIn Company Scraper Actor on your Apify account for the collected URLs, keeps the columns the sheet needs and updates each row, matched on `url`. Each company is one result.",
        "height": 420,
        "width": 700,
        "color": 7
      },
      "id": "47ae6d23-024c-4ccf-a106-5cb553f12f10",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1320,
        -260
      ]
    },
    {
      "parameters": {},
      "id": "5009f97c-b3e7-435e-a719-715d805d6889",
      "name": "Start enrichment",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "cb91f420-d09d-4d50-ad67-0f74519af605",
              "name": "googleSheetUrl",
              "value": "https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID/edit",
              "type": "string"
            },
            {
              "id": "f441c03a-2f64-487e-a516-994f295b093f",
              "name": "sheetName",
              "value": "Sheet1",
              "type": "string"
            },
            {
              "id": "209f9cc1-ea8a-4a2e-a4a6-d696e823522a",
              "name": "maxCompaniesPerRun",
              "value": 25,
              "type": "number"
            },
            {
              "id": "9eafc5e3-a0f9-4466-a3c0-79ad800b141f",
              "name": "maxCostPerRunUsd",
              "value": 0.25,
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "id": "4974fddd-f7f0-40f3-a93f-0627640ec702",
      "name": "Set sheet and limits",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "={{ $('Set sheet and limits').first().json.googleSheetUrl }}",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "={{ $('Set sheet and limits').first().json.sheetName }}",
          "mode": "name"
        },
        "options": {}
      },
      "id": "29d76723-c68e-40ee-aabd-d1fae4a26cf7",
      "name": "Read companies from the sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        480,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "dc85c275-856c-8e71-0531-b59a2bed2504",
              "leftValue": "={{ $json.url }}",
              "rightValue": "linkedin.com/company/",
              "operator": {
                "type": "string",
                "operation": "contains"
              }
            },
            {
              "id": "a283b211-4cfc-5e3c-666d-e0cea8d3c62b",
              "leftValue": "={{ $json.name }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "0874c80d-cf52-4a95-af70-6471bb00facc",
      "name": "Keep rows not enriched yet",
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.2,
      "position": [
        700,
        0
      ]
    },
    {
      "parameters": {
        "maxItems": "={{ $('Set sheet and limits').first().json.maxCompaniesPerRun }}"
      },
      "id": "00dee06f-f1b8-4a3d-af2f-caedfd93b6e6",
      "name": "Limit companies per run",
      "type": "n8n-nodes-base.limit",
      "typeVersion": 1,
      "position": [
        920,
        0
      ]
    },
    {
      "parameters": {
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "url",
              "renameField": true,
              "outputFieldName": "companyUrls"
            }
          ]
        },
        "options": {}
      },
      "id": "ce88002c-f1d8-44d5-a43c-df8e135d575e",
      "name": "Collect company URLs",
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [
        1140,
        0
      ]
    },
    {
      "parameters": {
        "resource": "Actors",
        "operation": "Run actor and get dataset",
        "actorId": "logical_scrapers~linkedin-company-scraper",
        "customBody": "={\n  \"companyUrls\": {{ JSON.stringify($json.companyUrls) }}\n}",
        "memory": 512,
        "maxTotalChargeUsd": "={{ $('Set sheet and limits').first().json.maxCostPerRunUsd }}"
      },
      "id": "d0905942-104c-439b-a8eb-c5fe73154615",
      "name": "Scrape LinkedIn company pages",
      "type": "@apify/n8n-nodes-apify.apify",
      "typeVersion": 1,
      "position": [
        1400,
        0
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "bc519abf-7f1f-48ea-ae54-59c32d783f51",
              "name": "url",
              "value": "={{ $json.url }}",
              "type": "string"
            },
            {
              "id": "8fffd0ca-58db-4cdd-a0e6-fbeadc3e7695",
              "name": "name",
              "value": "={{ $json.name }}",
              "type": "string"
            },
            {
              "id": "7b58e79e-b4bb-4f01-a008-ac423409e6ff",
              "name": "website",
              "value": "={{ $json.website }}",
              "type": "string"
            },
            {
              "id": "f10d1566-f4ef-485a-a95d-7e84a7691770",
              "name": "industry",
              "value": "={{ $json.Industry }}",
              "type": "string"
            },
            {
              "id": "6ad389a3-aed3-404b-a5d9-a17ac6570318",
              "name": "companySize",
              "value": "={{ $json[\"Company size\"] }}",
              "type": "string"
            },
            {
              "id": "e8f10b4c-b836-4458-ae9b-64ee9263eeeb",
              "name": "numberOfEmployees",
              "value": "={{ $json.numberOfEmployees }}",
              "type": "number"
            },
            {
              "id": "f276f6a0-b39a-4ecf-a7d4-b18f69211882",
              "name": "followersCount",
              "value": "={{ $json.followersCount }}",
              "type": "number"
            },
            {
              "id": "bd3c531f-67d5-4a8b-a942-8ab9891d5cee",
              "name": "headquarters",
              "value": "={{ $json.headquarters }}",
              "type": "string"
            },
            {
              "id": "7913d952-bee8-4f9e-a8b8-ae1f32e12ff5",
              "name": "description",
              "value": "={{ $json.description }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "1808e547-3b8d-4b5d-ae8f-9ea383049faf",
      "name": "Keep sheet columns",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1640,
        0
      ]
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "={{ $('Set sheet and limits').first().json.googleSheetUrl }}",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "={{ $('Set sheet and limits').first().json.sheetName }}",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [
            "url"
          ],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "id": "fb9ea7b1-2a37-407f-ab7e-7c57966ba9a3",
      "name": "Write company data to the sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1860,
        0
      ]
    }
  ],
  "connections": {
    "Start enrichment": {
      "main": [
        [
          {
            "node": "Set sheet and limits",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set sheet and limits": {
      "main": [
        [
          {
            "node": "Read companies from the sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read companies from the sheet": {
      "main": [
        [
          {
            "node": "Keep rows not enriched yet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keep rows not enriched yet": {
      "main": [
        [
          {
            "node": "Limit companies per run",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit companies per run": {
      "main": [
        [
          {
            "node": "Collect company URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Collect company URLs": {
      "main": [
        [
          {
            "node": "Scrape LinkedIn company pages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape LinkedIn company pages": {
      "main": [
        [
          {
            "node": "Keep sheet columns",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keep sheet columns": {
      "main": [
        [
          {
            "node": "Write company data to the sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}
