{
  "name": "LinkedIn Outreach (Lean Build)",
  "nodes": [
    {
      "parameters": {},
      "id": "ManualTrigger",
      "name": "Start",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        200,
        200
      ]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "json": [
            {
              "name": "contacts",
              "value": [
                {
                  "profileUrl": "https://www.linkedin.com/in/REPLACE_1/"
                },
                {
                  "profileUrl": "https://www.linkedin.com/in/REPLACE_2/"
                }
              ]
            }
          ]
        }
      },
      "id": "ContactsSet",
      "name": "Contacts",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        420,
        200
      ]
    },
    {
      "parameters": {
        "functionCode": "const list = items[0].json.contacts || [];\nreturn list.map((c,i)=>({json:{contactId:i+1, profileUrl:c.profileUrl}}));"
      },
      "id": "SplitContacts",
      "name": "Split Contacts",
      "type": "n8n-nodes-base.function",
      "typeVersion": 2,
      "position": [
        640,
        200
      ]
    },
    {
      "parameters": {
        "url": "https://api.phantombuster.com/api/v2/agents/launch",
        "method": "POST",
        "jsonParameters": true,
        "headerParametersJson": "{\"X-Phantombuster-Key-1\":\"O1jLrrHNXybkStIYIkX09htdCY9bYlfUsHrniF58uLw\",\"Content-Type\":\"application/json\"}",
        "bodyParametersJson": "={\"id\":\"SCRAPER_AGENT_ID\",\"argument\":{\"profileUrls\":[\"{{$json.profileUrl}}\"]}}"
      },
      "id": "PB_LaunchScraper",
      "name": "PB: Launch Scraper",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        880,
        200
      ]
    },
    {
      "parameters": {
        "amount": 20,
        "unit": "seconds"
      },
      "id": "WaitScrape",
      "name": "Wait 20s",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 2,
      "position": [
        1100,
        200
      ]
    },
    {
      "parameters": {
        "url": "https://api.phantombuster.com/api/v2/agents/fetch-output?id=SCRAPER_AGENT_ID",
        "method": "GET",
        "headerParametersJson": "{\"X-Phantombuster-Key-1\":\"O1jLrrHNXybkStIYIkX09htdCY9bYlfUsHrniF58uLw\"}"
      },
      "id": "PB_FetchOutput",
      "name": "PB: Fetch Output",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        1320,
        200
      ]
    },
    {
      "parameters": {
        "functionCode": "const out = items[0].json || {};\nconst row = (out.resultObject && out.resultObject.data && out.resultObject.data[0]) || (out.data && out.data[0]) || {};\nreturn [{ json: { fullName: row.fullName||'', headline: row.headline||'', company: row.company||'', skills: row.skills||[], summary: row.summary||'', profileUrl: $json.profileUrl } }];"
      },
      "id": "ExtractProfile",
      "name": "Extract Profile",
      "type": "n8n-nodes-base.function",
      "typeVersion": 2,
      "position": [
        1540,
        200
      ]
    },
    {
      "parameters": {
        "url": "https://api.openai.com/v1/chat/completions",
        "method": "POST",
        "jsonParameters": true,
        "headerParametersJson": "{\"Authorization\":\"Bearer OPENAI_API_KEY\",\"Content-Type\":\"application/json\"}",
        "bodyParametersJson": "={\n  \"model\": \"gpt-4o-mini\",\n  \"messages\": [\n    {\"role\":\"system\",\"content\":\"You write short, friendly LinkedIn outreach (max 280 chars).\"},\n    {\"role\":\"user\",\"content\":\"Name: {{$json.fullName}}\\nHeadline: {{$json.headline}}\\nCompany: {{$json.company}}\\nSummary: {{$json.summary}}\\nSkills: {{$json.skills}}\"}\n  ]\n}"
      },
      "id": "OpenAIChat",
      "name": "OpenAI",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        1760,
        200
      ]
    },
    {
      "parameters": {
        "functionCode": "const c = items[0].json;\nconst msg = (c.choices && c.choices[0] && c.choices[0].message && c.choices[0].message.content) || '';\nreturn [{json:{profileUrl:$json.profileUrl, draft:msg}}];"
      },
      "id": "CollectDraft",
      "name": "Collect Draft",
      "type": "n8n-nodes-base.function",
      "typeVersion": 2,
      "position": [
        1980,
        200
      ]
    },
    {
      "parameters": {
        "url": "https://api.phantombuster.com/api/v2/agents/launch",
        "method": "POST",
        "jsonParameters": true,
        "headerParametersJson": "{\"X-Phantombuster-Key-1\":\"O1jLrrHNXybkStIYIkX09htdCY9bYlfUsHrniF58uLw\",\"Content-Type\":\"application/json\"}",
        "bodyParametersJson": "={\"id\":\"SENDER_AGENT_ID\",\"argument\":{\"leads\":[{\"profileUrl\":\"{{$json.profileUrl}}\",\"message\":\"{{$json.draft}}\"}]}}"
      },
      "id": "PB_SendMessage",
      "name": "PB: Send Message",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        2200,
        200
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Contacts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Contacts": {
      "main": [
        [
          {
            "node": "Split Contacts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Contacts": {
      "main": [
        [
          {
            "node": "PB: Launch Scraper",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PB: Launch Scraper": {
      "main": [
        [
          {
            "node": "Wait 20s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 20s": {
      "main": [
        [
          {
            "node": "PB: Fetch Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PB: Fetch Output": {
      "main": [
        [
          {
            "node": "Extract Profile",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Profile": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "Collect Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Collect Draft": {
      "main": [
        [
          {
            "node": "PB: Send Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}