{
  "name": "Sync LinkedIn profile visitors to HubSpot CRM",
  "nodes": [
    {
      "parameters": {
        "content": "## 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)",
        "height": 580,
        "width": 400,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        2440,
        1280
      ],
      "id": "overview-sticky-note",
      "name": "Workflow Overview"
    },
    {
      "parameters": {
        "content": "## 1. Trigger\nRuns weekly on schedule or manually for testing.",
        "height": 280,
        "width": 280,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        2860,
        1380
      ],
      "id": "section-1-trigger",
      "name": "Section 1 - Trigger"
    },
    {
      "parameters": {
        "content": "## 2. Fetch Visitors\nRetrieves LinkedIn profile visitors via ConnectSafely.ai API and splits into individual records.",
        "height": 280,
        "width": 480,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        3160,
        1380
      ],
      "id": "section-2-fetch",
      "name": "Section 2 - Fetch Visitors"
    },
    {
      "parameters": {
        "content": "## 3. Enrich and Validate\nEnriches visitor data via Apify and validates email exists before CRM sync.",
        "height": 280,
        "width": 560,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        3660,
        1380
      ],
      "id": "section-3-enrich",
      "name": "Section 3 - Enrich and Validate"
    },
    {
      "parameters": {
        "content": "## 4. CRM Sync\nCreates or updates contact in HubSpot with enriched profile data.",
        "height": 280,
        "width": 280,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        4240,
        1380
      ],
      "id": "section-4-crm",
      "name": "Section 4 - CRM Sync"
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        2900,
        1488
      ],
      "id": "schedule-trigger",
      "name": "Run Weekly"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        2900,
        1580
      ],
      "id": "manual-trigger",
      "name": "Test Manually"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.connectsafely.ai/linkedin/profile/visitors",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {}
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{\"timeRange\":\"past_7_days\",\"start\":0,\"fetchAll\":true}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3200,
        1488
      ],
      "id": "fetch-visitors-api",
      "name": "Fetch Profile Visitors",
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "fieldToSplitOut": "visitors",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        3400,
        1488
      ],
      "id": "split-visitors",
      "name": "Split Visitors Array"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        3600,
        1488
      ],
      "id": "loop-visitors",
      "name": "Process Each Visitor"
    },
    {
      "parameters": {
        "operation": "Run actor and get dataset",
        "actorId": {
          "__rl": true,
          "value": "YOUR_APIFY_ACTOR_URL",
          "mode": "url"
        },
        "customBody": "={\n    \"linkedin\": \"{{ $json.navigationUrl }}\"\n}"
      },
      "type": "@apify/n8n-nodes-apify.apify",
      "typeVersion": 1,
      "position": [
        3800,
        1488
      ],
      "id": "enrich-profile-apify",
      "name": "Enrich LinkedIn Profile",
      "credentials": {
        "apifyApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "email-exists-condition",
              "leftValue": "={{ $json['04_Email'] }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        4000,
        1488
      ],
      "id": "check-email-exists",
      "name": "Has Valid Email"
    },
    {
      "parameters": {
        "authentication": "appToken",
        "email": "={{ $json['04_Email'] }}",
        "additionalFields": {
          "city": "={{ $json['14_City'] }}",
          "companyName": "={{ $json['16_Company_name'] }}",
          "country": "={{ $json['15_Country'] }}",
          "firstName": "={{ $json['02_First_name'] }}",
          "jobTitle": "={{ $json['07_Title'] }}",
          "lastName": "={{ $json['03_Last_name'] }}",
          "leadStatus": "NEW",
          "linkedinUrl": "={{ $json['06_Linkedin_url'] }}",
          "streetAddress": "={{ $json['13_Current_address'] }}"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 2.1,
      "position": [
        4280,
        1408
      ],
      "id": "create-hubspot-contact",
      "name": "Create HubSpot Contact",
      "credentials": {
        "hubspotAppToken": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        4280,
        1568
      ],
      "id": "skip-no-email",
      "name": "Skip - No Email"
    }
  ],
  "connections": {
    "Run Weekly": {
      "main": [
        [
          {
            "node": "Fetch Profile Visitors",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Test Manually": {
      "main": [
        [
          {
            "node": "Fetch Profile Visitors",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Profile Visitors": {
      "main": [
        [
          {
            "node": "Split Visitors Array",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Visitors Array": {
      "main": [
        [
          {
            "node": "Process Each Visitor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Each Visitor": {
      "main": [
        [],
        [
          {
            "node": "Enrich LinkedIn Profile",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enrich LinkedIn Profile": {
      "main": [
        [
          {
            "node": "Has Valid Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Valid Email": {
      "main": [
        [
          {
            "node": "Create HubSpot Contact",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Skip - No Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create HubSpot Contact": {
      "main": [
        [
          {
            "node": "Process Each Visitor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Skip - No Email": {
      "main": [
        [
          {
            "node": "Process Each Visitor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}