{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "43d7bb8c-c0f2-4a27-96d2-6e8fd61c1f43",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        6064,
        1104
      ],
      "parameters": {
        "unit": "minutes"
      },
      "typeVersion": 1.1
    },
    {
      "id": "dc66507c-d69d-409d-9ba7-bcac82bcb79e",
      "name": "Get Linkedin Provider ID",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        5376,
        1104
      ],
      "parameters": {
        "url": "=https://{{ $json.unipile_DSN }}/api/v1/users/{{ $json.username }}",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "account_id",
              "value": "={{ $json.unipile_account_ID }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "X-API-KEY",
              "value": "={{ $json.unipile_api_key }}"
            },
            {
              "name": "accept",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "dbb03d50-a453-418e-9712-c296e11da393",
      "name": "Limit Connection Request",
      "type": "n8n-nodes-base.limit",
      "position": [
        4400,
        1088
      ],
      "parameters": {
        "maxItems": 10
      },
      "typeVersion": 1
    },
    {
      "id": "25cf5ca3-3fc4-4039-995f-91426e6adb8a",
      "name": "Data Arrangement",
      "type": "n8n-nodes-base.set",
      "position": [
        4896,
        1088
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "85e65f5e-2c0f-49ed-ab1c-c055ae3d6803",
              "name": "username",
              "type": "string",
              "value": "={{ $json.username }}"
            },
            {
              "id": "4010206c-e5a4-41e0-9f3b-4a42509ed118",
              "name": "row_number",
              "type": "number",
              "value": "={{ $('Filter').item.json.row_number }}"
            },
            {
              "id": "2631f30b-9886-4547-809e-be8bba4f0cba",
              "name": "first_name",
              "type": "string",
              "value": "={{ $('Filter').item.json.first_name }}"
            },
            {
              "id": "923ae4c5-21b5-4248-b552-b151c8186fbe",
              "name": "company_name",
              "type": "string",
              "value": "={{ $('Limit Connection Request').item.json.company_name }}"
            },
            {
              "id": "5bb53f3e-ee85-437d-8dc1-3d1ba5d92922",
              "name": "unipile_DSN",
              "type": "string",
              "value": "unipile-DSN"
            },
            {
              "id": "16c58cb4-3ce0-48c0-aaba-b7679f6aa30c",
              "name": "unipile_api_key",
              "type": "string",
              "value": "your-api-key-here"
            },
            {
              "id": "07d81241-ded9-4df1-ba96-cd5730f5a960",
              "name": "unipile_account_ID",
              "type": "string",
              "value": "your-unipile-linkedin-account-id-here"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "9b84d910-daa6-406a-a771-ff52bb4ea603",
      "name": "Get Linkedin Username",
      "type": "n8n-nodes-base.code",
      "position": [
        4640,
        1088
      ],
      "parameters": {
        "jsCode": "const linkedinUrl = $input.first().json.linkedin_url;\nconst cleanUrl = linkedinUrl.replace(/\\/$/, '');\nconst username = cleanUrl.split('/in/')[1]?.split('/')[0] || null;\n\nreturn [{\n  json: {\n    username: username\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "e87ad14f-8dd3-4309-9db3-299fd7607822",
      "name": "Filter",
      "type": "n8n-nodes-base.filter",
      "position": [
        4208,
        1088
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "d7a7f360-9796-4544-be34-834b20134833",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.inmail }}",
              "rightValue": "Sent"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "261a63ec-0d48-42bd-8325-5c3630ecb2dc",
      "name": "Get Leads",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        4016,
        1088
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultName": "leads"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1IM0qnZlhYK7Pbj__xwyPgEprW-5-P3RBnen1xGZjSSk",
          "cachedResultName": "linkedin_connection_request_template"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "44b4912d-21e8-4f43-9b6c-416ade4e6fc1",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        3808,
        1088
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "9f9fd7a7-ca5b-4915-a3c0-150a17417116",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        5136,
        1088
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "6cafa92c-0b80-4ab6-9c30-68896c845b98",
      "name": "Send Inmail",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        5600,
        1104
      ],
      "parameters": {
        "url": "=https://{{ $('Loop Over Items').item.json.unipile_DSN }}/api/v1/chats",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "attendees_ids",
              "value": "={{ $json.provider_id }}"
            },
            {
              "name": "account_id",
              "value": "={{ $('Loop Over Items').item.json.unipile_account_ID }}"
            },
            {
              "name": "api",
              "value": "sales_navigator"
            },
            {
              "name": "subject",
              "value": "=Automating the Repetitive Work Behind {{ $('Loop Over Items').item.json.company_name }}"
            },
            {
              "name": "text",
              "value": "=Hi {{ $('Loop Over Items').item.json.first_name }},\n\nI noticed you are leading {{ $('Loop Over Items').item.json.company_name }} and wanted to reach out directly.\n\nGrowing a company comes with a lot of moving parts \u2014 and more often than not, a significant amount of your team's time goes into manual, repetitive tasks that could be fully automated.\n\nI specialise in building n8n automations for founders and CEOs \u2014 helping businesses like {{ $('Loop Over Items').item.json.company_name }} eliminate manual work across areas such as:\n\n- Lead outreach and follow-up sequences\n- CRM data entry and pipeline updates\n- Client onboarding and contract workflows\n- Internal reporting and team notifications\n- Invoice generation and payment tracking\n\nThe result is a leaner operation, a more focused team, and more of your time back where it belongs \u2014 on growing {{ $('Loop Over Items').item.json.company_name }}.\n\nI would love to understand where {{ $('Loop Over Items').item.json.company_name }} is currently losing the most time and show you exactly how automation could solve it.\n\nWould you be open to a quick 20-minute call this week?\n\nBest regards,\n[Your Name]\n[Your Website / Calendar Link]"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "accept",
              "value": "application/json"
            },
            {
              "name": "X-API-KEY",
              "value": "={{ $('Loop Over Items').item.json.unipile_api_key }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "615765d3-d9bf-46ec-9db5-1d704ba6c503",
      "name": "Update Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        5792,
        1104
      ],
      "parameters": {
        "columns": {
          "value": {
            "inmail": "Sent",
            "chat_ID": "={{ $json.chat_id }}",
            "row_number": "={{ $('Loop Over Items').item.json.row_number }}"
          },
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultName": "leads"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1IM0qnZlhYK7Pbj__xwyPgEprW-5-P3RBnen1xGZjSSk",
          "cachedResultName": "linkedin_connection_request_template"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "f6844e7f-9487-4947-942a-831179c1f55b",
      "name": "\ud83d\udcd6 Setup Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3200,
        720
      ],
      "parameters": {
        "color": 4,
        "width": 520,
        "height": 500,
        "content": "# \ud83d\udce9 LinkedIn InMail Automation\nSend personalized LinkedIn InMails to CEOs & founders via n8n, Google Sheets, and Unipile.\n\n### \u26a0\ufe0f Requirements\n- LinkedIn **Sales Navigator** or **Recruiter Classic** (InMail credits are consumed from your plan)\n\n### \ud83d\udee0\ufe0f Setup\n1. **Google Sheet columns:** `first_name` | `company_name` | `linkedin_url` | `inmail` | `chat_ID` | `row_number`\n2. **Unipile:** Sign up at unipile.com \u2192 connect LinkedIn \u2192 copy your API Key, DSN & Account ID\n3. Paste credentials into the **Data Arrangement** node\n4. **Limit node** \u2192 10\u201315/run | **Wait node** \u2192 3\u20135 min | **Schedule** \u2192 every 4\u20138 hrs"
      },
      "typeVersion": 1
    },
    {
      "id": "c00f5093-eb24-44be-bed8-a32a7442e23f",
      "name": "\ud83d\udce5 Lead Collection & Filtering",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3760,
        912
      ],
      "parameters": {
        "color": 5,
        "width": 744,
        "height": 140,
        "content": "## \ud83d\udce5 Lead Collection & Filtering\nReads leads from Google Sheets and skips already-messaged contacts.\n\n**Flow:** Schedule Trigger \u2192 Get Leads \u2192 Filter (`inmail` \u2260 `Sent`) \u2192 Limit"
      },
      "typeVersion": 1
    },
    {
      "id": "18473314-af5e-447a-8865-437e236937f1",
      "name": "\u2699\ufe0f Data Preparation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4528,
        816
      ],
      "parameters": {
        "color": 3,
        "width": 540,
        "height": 248,
        "content": "## \u2699\ufe0f Data Preparation\nExtracts the LinkedIn username from the profile URL and bundles all fields for the loop.\n\n- **Get LinkedIn Username** \u2014 parses `/in/username/` from the URL\n- **Data Arrangement** \u2014 sets `username`, `first_name`, `company_name`, `row_number`, and Unipile credentials\n\n> Replace placeholder values in **Data Arrangement**: DSN, API key, Account ID"
      },
      "typeVersion": 1
    },
    {
      "id": "f9087fe4-09b0-4f52-93da-602698ed2a06",
      "name": "\ud83d\udce8 InMail Sending Loop",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5104,
        864
      ],
      "parameters": {
        "color": 6,
        "width": 600,
        "height": 204,
        "content": "## \ud83d\udce8 InMail Sending Loop\nSends one personalized InMail per lead via Sales Navigator.\n\n**Flow:** Loop \u2192 Get Provider ID \u2192 Send InMail \u2192 Update Sheet \u2192 Wait \u2192 repeat\n\n- Uses `POST /api/v1/chats` with `api: sales_navigator`\n- For Recruiter Classic: change `api` value to `recruiter`\n- Inmail Credits deducted from your LinkedIn plan (not Unipile)"
      },
      "typeVersion": 1
    },
    {
      "id": "f155b9f1-f8f9-4df2-8535-9af22258d522",
      "name": "\u2705 Tracking & Status Update",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5728,
        848
      ],
      "parameters": {
        "color": 7,
        "width": 516,
        "height": 220,
        "content": "## \u2705 Tracking & Status Update\nWrites results back to Google Sheets after each send.\n\n| Column | Value |\n|---|---|\n| `inmail: ` | `Sent` \u2014 prevents duplicate messages |\n| `chat_ID: ` | Conversation ID for follow-up workflows |\n\n> Use the saved `chat_id` to build a follow-up sequence (e.g. Day 3 reply if no response)."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "Limit Connection Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Leads": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Inmail": {
      "main": [
        [
          {
            "node": "Update Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Data": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Get Linkedin Provider ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Data Arrangement": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Linkedin Username": {
      "main": [
        [
          {
            "node": "Data Arrangement",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Linkedin Provider ID": {
      "main": [
        [
          {
            "node": "Send Inmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit Connection Request": {
      "main": [
        [
          {
            "node": "Get Linkedin Username",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}