{
  "nodes": [
    {
      "id": "4e71ad18-ba8c-4442-89a5-92df9be70757",
      "name": "Run an Actor and get dataset",
      "type": "@apify/n8n-nodes-apify.apify",
      "position": [
        3600,
        1488
      ],
      "parameters": {
        "actorId": {
          "__rl": true,
          "mode": "url",
          "value": "https://console.apify.com/actors/UMdANQyqx3b2JVuxg"
        },
        "operation": "Run actor and get dataset",
        "customBody": "={\n    \"linkedin\": \"{{ $json.navigationUrl }}\"\n}"
      },
      "credentials": {
        "apifyApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ac6809a5-5284-4b9a-9b4d-0c0067d4b584",
      "name": "Check if Contact is eligible to add into CRM",
      "type": "n8n-nodes-base.if",
      "position": [
        3824,
        1488
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "127bd789-e920-4bc1-8999-8adf2065002f",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json['04_Email'] }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "ad58a142-efa1-483f-8328-5b09c6c85094",
      "name": "Create or update a contact",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        4048,
        1408
      ],
      "parameters": {
        "email": "={{ $json['04_Email'] }}",
        "options": {},
        "authentication": "appToken",
        "additionalFields": {
          "city": "={{ $json['14_City'] }}",
          "country": "={{ $json['15_Country'] }}",
          "jobTitle": "={{ $json['07_Title'] }}",
          "lastName": "={{ $json['03_Last_name'] }}",
          "firstName": "={{ $json['02_First_name'] }}",
          "leadStatus": "NEW",
          "companyName": "={{ $json['16_Company_name'] }}",
          "linkedinUrl": "={{ $json['06_Linkedin_url'] }}",
          "streetAddress": "={{ $json['13_Current_address'] }}"
        }
      },
      "credentials": {
        "hubspotAppToken": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "9ee40226-e5c0-4553-b5a9-62990ecb22da",
      "name": "Replace Me",
      "type": "n8n-nodes-base.noOp",
      "position": [
        4272,
        1552
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "d60b0f37-6d10-4940-9a99-43bcba97dc67",
      "name": "\ud83d\udce4 Split Comments Array",
      "type": "n8n-nodes-base.splitOut",
      "notes": "\ud83d\udcdd STEP 3: SPLIT DATA\n\n\u2705 What this does:\n- Takes the array of comments from previous step\n- Splits each comment into a separate item\n- Prepares data for loop processing\n\n\ud83d\udd27 Technical Details:\n- Splits 'comments' field into individual items\n- Each item becomes a separate execution flow\n- Enables processing one commenter at a time\n\n\ud83d\udca1 Example:\nInput: {comments: [user1, user2, user3]}\nOutput: 3 separate items, one per user",
      "position": [
        3152,
        1552
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "visitors"
      },
      "typeVersion": 1
    },
    {
      "id": "e14ea4df-5ba5-4b67-b05e-db450a013246",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2928,
        1552
      ],
      "parameters": {
        "url": "https://api.connectsafely.ai/linkedin/profile/visitors",
        "method": "POST",
        "options": {},
        "jsonBody": "{\"timeRange\":\"past_7_days\",\"start\":0,\"fetchAll\":true}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "headerParameters": {
          "parameters": [
            {}
          ]
        }
      },
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "0f637b6e-8876-4710-9abe-dc8c1f811791",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        2704,
        1456
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "784d09b2-32ca-41b0-a5b7-09c68fe02e5c",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        2704,
        1648
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "704cd2e0-53ea-4cc2-9ed7-3075c8a20228",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        3376,
        1552
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "0ebda2fe-c0d8-4bfa-95f3-920a21f54a50",
      "name": "Workflow Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2048,
        1008
      ],
      "parameters": {
        "width": 544,
        "height": 1060,
        "content": "@[youtube](pWa6g_ln1pY)\n\n## Sync LinkedIn Profile Visitors to HubSpot CRM\n\nAutomatically capture LinkedIn profile visitors and add them as contacts in HubSpot CRM with enriched data.\n\n### Who is this for?\nSales professionals, recruiters, and marketers who want to convert LinkedIn profile visitors into actionable CRM leads without manual data entry.\n\n### How it works\n1. **Scheduled trigger** runs weekly (or manually) to fetch recent profile visitors\n2. **ConnectSafely.ai API** retrieves visitors from the past 7 days\n3. **Apify actor** enriches each visitor with detailed LinkedIn profile data\n4. **Email validation** filters contacts with valid email addresses\n5. **HubSpot integration** creates or updates contacts with full profile information\n\n### Setup steps\n1. Create a [ConnectSafely.ai](https://connectsafely.ai) account and get your API key\n2. Set up an [Apify](https://apify.com) account for LinkedIn profile enrichment\n3. Configure HubSpot credentials with contact creation permissions\n4. Update the HTTP Request node with your ConnectSafely.ai Bearer token\n5. Configure the Apify node with your actor ID for LinkedIn scraping\n\n### Customization\n- Adjust the schedule trigger frequency based on your needs\n- Modify the time range in the API request (past_7_days, past_30_days)\n- Add additional CRM fields in the HubSpot node\n- Replace HubSpot with your preferred CRM (Salesforce, Zoho, Pipedrive)"
      },
      "typeVersion": 1
    },
    {
      "id": "4e00e57a-5672-43d4-932a-7e3819ea2e47",
      "name": "Section 1 - Trigger",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2624,
        1296
      ],
      "parameters": {
        "color": 7,
        "width": 232,
        "height": 504,
        "content": "## 1. Trigger\nRuns weekly on schedule or manually for testing."
      },
      "typeVersion": 1
    },
    {
      "id": "28e37b17-9805-4cb0-a488-9c8766379b0b",
      "name": "Section 2 - Fetch Visitors",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2880,
        1424
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 280,
        "content": "## 2. Fetch Visitors\nRetrieves LinkedIn profile visitors via ConnectSafely.ai API and splits into individual records."
      },
      "typeVersion": 1
    },
    {
      "id": "82bc3590-dbf5-40d7-8145-579f03d5ec38",
      "name": "Section 3 - Enrich and Validate",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3536,
        1392
      ],
      "parameters": {
        "color": 7,
        "width": 448,
        "height": 280,
        "content": "## 3. Enrich and Validate\nEnriches visitor data via Apify and validates email exists before CRM sync."
      },
      "typeVersion": 1
    },
    {
      "id": "c6681f91-3ca1-426b-bbe2-0edf5555c3f5",
      "name": "Section 4 - CRM Sync",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4016,
        1264
      ],
      "parameters": {
        "color": 7,
        "width": 552,
        "height": 536,
        "content": "## 4. CRM Sync\nCreates or updates contact in HubSpot with enriched profile data."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Replace Me": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "\ud83d\udce4 Split Comments Array",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Run an Actor and get dataset",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83d\udce4 Split Comments Array": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create or update a contact": {
      "main": [
        [
          {
            "node": "Replace Me",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run an Actor and get dataset": {
      "main": [
        [
          {
            "node": "Check if Contact is eligible to add into CRM",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Contact is eligible to add into CRM": {
      "main": [
        [
          {
            "node": "Create or update a contact",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Replace Me",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}