{
  "nodes": [
    {
      "id": "6850ecf6-af45-41d0-998c-fcde45eef749",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        48,
        64
      ],
      "parameters": {
        "width": 617,
        "height": 954,
        "content": "@[youtube](hzYsKUDVffo)\n\n## Add LinkedIn Post Commenters to HubSpot CRM\n\nThis workflow automatically enriches LinkedIn post commenters with professional data and adds them as contacts to your HubSpot CRM.\n\n### How it works\n1. Submit a LinkedIn post URL via the form trigger\n2. Fetch all comments from the specified post using ConnectSafely\n3. Loop through each commenter and enrich their profile using Apify\n4. Check if the contact has a valid email address\n5. Create or update the contact in HubSpot CRM with enriched data\n\n### Setup steps\n1. Install the ConnectSafely community node (self-hosted n8n only)\n2. Configure your ConnectSafely API credentials\n3. Configure your Apify API credentials\n4. Configure your HubSpot App Token credentials\n5. Activate the workflow and submit a LinkedIn post URL\n\n### Customization\n- Modify the HubSpot node to map additional fields from the enriched data\n- Add filters to exclude certain commenters based on criteria\n- Adjust the loop batch size based on your API rate limits\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "acfb1348-6d4c-4069-89b1-84cf07c6ebbe",
      "name": "Form Trigger - Enter Post URL",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        768,
        544
      ],
      "parameters": {
        "options": {},
        "formTitle": "LinkedIn Post Engagement Automation",
        "formFields": {
          "values": [
            {
              "fieldLabel": "LinkedIn Post URL",
              "placeholder": "https://www.linkedin.com/posts/your-post-url...",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Enter your LinkedIn post URL below to automatically send personalized connection requests to people who commented on your post."
      },
      "typeVersion": 2.3
    },
    {
      "id": "417f6637-dfc4-47a1-86da-3549ccae061c",
      "name": "Fetch Post Comments",
      "type": "n8n-nodes-connectsafely-ai.connectSafelyLinkedIn",
      "position": [
        992,
        544
      ],
      "parameters": {
        "postUrl": "={{ $json['LinkedIn Post URL'] }}",
        "operation": "getPostComments"
      },
      "typeVersion": 1
    },
    {
      "id": "7e74b052-04d7-4306-9c30-f5aa54fd28ea",
      "name": "Split Comments Array",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1216,
        544
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "comments"
      },
      "typeVersion": 1
    },
    {
      "id": "b53fec91-ad8d-433f-83bc-429e964e6689",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1440,
        448
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "5f6e04cc-b9ea-4f5c-9aab-8666c36f6c2d",
      "name": "Enrich Profile with Apify",
      "type": "@apify/n8n-nodes-apify.apify",
      "position": [
        1664,
        464
      ],
      "parameters": {
        "actorId": {
          "__rl": true,
          "mode": "url",
          "value": "https://console.apify.com/actors/UMdANQyqx3b2JVuxg"
        },
        "operation": "Run actor and get dataset",
        "customBody": "={\n    \"linkedin\": \"{{ $json.profileUrl }}\"\n}"
      },
      "typeVersion": 1
    },
    {
      "id": "09651bdd-d6a5-4092-85fc-c0f85d88cd2e",
      "name": "Check Email Exists",
      "type": "n8n-nodes-base.if",
      "position": [
        1872,
        464
      ],
      "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": "0c5e7187-b932-4fca-9fc6-3943182f82d7",
      "name": "Create or Update HubSpot Contact",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        2128,
        384
      ],
      "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'] }}",
          "companyName": "={{ $json['16_Company_name'] }}",
          "streetAddress": "={{ $json['13_Current_address'] }}"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "3c7833e2-7360-4536-a8b9-e5065d0ca4e1",
      "name": "Continue Loop",
      "type": "n8n-nodes-base.noOp",
      "position": [
        2336,
        560
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "203364c2-c3d4-4ea8-a6ad-192345fa41b4",
      "name": "Sticky Note - Trigger Section",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        698,
        440
      ],
      "parameters": {
        "color": 7,
        "width": 668,
        "height": 264,
        "content": "## 1. Trigger and Fetch Comments\nCapture LinkedIn post URL and retrieve all commenters"
      },
      "typeVersion": 1
    },
    {
      "id": "7e862188-ddcd-43c1-8776-0c1456d9e84f",
      "name": "Sticky Note - Enrich Section",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1584,
        264
      ],
      "parameters": {
        "color": 7,
        "width": 928,
        "height": 440,
        "content": "## 2. Enrich Profiles and Add to CRM\nEnrich each commenter profile with Apify and create HubSpot contacts"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Continue Loop": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Enrich Profile with Apify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Email Exists": {
      "main": [
        [
          {
            "node": "Create or Update HubSpot Contact",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Continue Loop",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Post Comments": {
      "main": [
        [
          {
            "node": "Split Comments Array",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Comments Array": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enrich Profile with Apify": {
      "main": [
        [
          {
            "node": "Check Email Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Form Trigger - Enter Post URL": {
      "main": [
        [
          {
            "node": "Fetch Post Comments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create or Update HubSpot Contact": {
      "main": [
        [
          {
            "node": "Continue Loop",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}