{
  "name": "Project: LinkedIn Scraper",
  "nodes": [
    {
      "parameters": {
        "options": {
          "responseMode": "responseNodes"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.3,
      "position": [
        0,
        0
      ],
      "id": "fbcd007d-1fe6-4208-9cf5-95cd054c9eeb",
      "name": "When chat message received",
      "webhookId": "508ab75a-0b8a-4f1f-b50d-d9f2b73d009f"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "4c181c61-cc0c-436b-b383-665d957dd293",
              "name": "mode",
              "value": "profiles",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        208,
        0
      ],
      "id": "77793159-2973-4fd6-8e6b-a1a2ec62b99d",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "content": "## Set mode\nSet this to either **jobs** or **profiles**\n",
        "height": 272,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        144,
        -112
      ],
      "typeVersion": 1,
      "id": "abb6bcff-5b59-4b16-80ab-a22bebf03e79",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "0b6d627a-55cc-4507-b169-04701c01582c",
              "leftValue": "={{ $json.mode }}",
              "rightValue": "jobs",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        416,
        0
      ],
      "id": "a47b9c76-20d1-43dd-806b-c49aca8960fe",
      "name": "If"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f81c9e59-5272-4f33-90bb-dabef460f839",
              "name": "prompt",
              "value": "You are an expert in Boolean search techniques for Google. When the user sends a job description, generate a search string specifically for finding LinkedIn job posts that match that description. Your response must always follow this exact format: site:linkedin.com/jobs [Boolean search string] Create the Boolean search string using precise operators (AND, OR, \"\", *, -) to match the job requirements. Focus only on generating the search string - provide no additional commentary or explanations unless specifically requested.  Also return sheet_name (less than 100 char)",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        624,
        -96
      ],
      "id": "0007c2e2-664d-438a-b88e-74695597bd08",
      "name": "Set jobs prompt"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "0aa44f48-adf1-4f62-93f5-be45ffae4bcf",
              "name": "prompt",
              "value": "You are an expert in Boolean search techniques for Google. When the user sends a job description, generate a search string specifically for finding LinkedIn job profiles that match that description. Your response must always follow this exact format: site:linkedin.com/in [Boolean search string] Create the Boolean search string using precise operators (AND, OR, \"\", *, -) to match the job requirements. Focus only on generating the search string - provide no additional commentary or explanations unless specifically requested.  Also return sheet_name (less than 100 char)",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        624,
        96
      ],
      "id": "0bd71411-91c5-4458-87f0-3bfa06e66272",
      "name": "Set Profiles prompt"
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4O-MINI"
        },
        "messages": {
          "values": [
            {
              "content": "={{ $('When chat message received').item.json.chatInput }}"
            },
            {
              "content": "={{ $json.prompt }}",
              "role": "system"
            }
          ]
        },
        "simplify": false,
        "jsonOutput": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        864,
        0
      ],
      "id": "e1e49ad9-c2d5-4fb3-a161-68d7b9a5f1a1",
      "name": "Message a model",
      "credentials": {
        "openAiApi": {
          "id": "xHWDVrLvQFklSodD",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "operation": "create",
        "documentId": {
          "__rl": true,
          "value": "13Ciy8R8upNoOXbnVGdofPi08ufwa7zWRzw8XAl3EDIs",
          "mode": "list",
          "cachedResultName": "scrapes",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/13Ciy8R8upNoOXbnVGdofPi08ufwa7zWRzw8XAl3EDIs/edit?usp=drivesdk"
        },
        "title": "={{ $json.choices[0].message.content.sheet_name }}",
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1216,
        0
      ],
      "id": "9af5d421-a53d-4d42-820e-9a3c63c914a8",
      "name": "Create sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "o2wjO6VTorTEj5dG",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "return [{\n  json: {\n    \"linkedin_url\": \"\"\n  }\n}];\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1424,
        0
      ],
      "id": "8fbfb9bd-2b7c-442b-9a2d-bab82e0efd74",
      "name": "Code"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "13Ciy8R8upNoOXbnVGdofPi08ufwa7zWRzw8XAl3EDIs",
          "mode": "list",
          "cachedResultName": "scrapes",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/13Ciy8R8upNoOXbnVGdofPi08ufwa7zWRzw8XAl3EDIs/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "={{ $('Create sheet').item.json.sheetId }}",
          "mode": "id"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1632,
        0
      ],
      "id": "367d3e1f-ca36-4130-b0d7-25ae32becf61",
      "name": "Append row in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "o2wjO6VTorTEj5dG",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "return [{ json: { start: 0 } }];\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1840,
        0
      ],
      "id": "90b16904-e68e-4b3a-b61e-b400b02894b2",
      "name": "Code1"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "5774512d-839b-40a6-b76f-fbfe1ec28f7a",
              "leftValue": "={{ $json.start }}",
              "rightValue": 15,
              "operator": {
                "type": "number",
                "operation": "lt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        64,
        432
      ],
      "id": "60fcd130-6a4d-44fa-aab5-29152b21c63d",
      "name": "If1"
    },
    {
      "parameters": {
        "content": "## How many links?",
        "height": 240,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        320
      ],
      "typeVersion": 1,
      "id": "935bbd12-7e22-4417-9d1d-3b7e7160f3dd",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "message": "Completed",
        "waitUserReply": false,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chat",
      "typeVersion": 1,
      "position": [
        352,
        576
      ],
      "id": "9cfaca9e-572f-46df-858c-8151c7995e8c",
      "name": "Respond to Chat"
    },
    {
      "parameters": {
        "url": "https://www.googleapis.com/customsearch/v1",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "key",
              "value": "AIzaSyDmtTA3R-7uWLUmmwD7AbMol6B6iSmsE3Q"
            },
            {
              "name": "cx",
              "value": "55b8201464ff24ae8"
            },
            {
              "name": "q",
              "value": "={{ $('Message a model').item.json.choices[0].message.content.search_string }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        352,
        336
      ],
      "id": "39a7d611-9080-4deb-855e-34984b423555",
      "name": "HTTP Request"
    },
    {
      "parameters": {
        "jsCode": "// Get all items from the first input element\nconst items = $input.first().json.items;\n\n// Map through and return only the \"link\" values\nconst links = items.map(item => item.link);\n\n// Return as individual output items for n8n\nreturn links.map(link => ({ json: { link } }));\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        560,
        336
      ],
      "id": "468c34ad-ea22-4c69-b4f7-a6a9274f6135",
      "name": "Code2"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "13Ciy8R8upNoOXbnVGdofPi08ufwa7zWRzw8XAl3EDIs",
          "mode": "list",
          "cachedResultName": "scrapes",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/13Ciy8R8upNoOXbnVGdofPi08ufwa7zWRzw8XAl3EDIs/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "={{ $('Create sheet').item.json.sheetId }}",
          "mode": "id"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "linkedin_url": "={{ $json.link }}"
          },
          "matchingColumns": [
            "linkedin_url"
          ],
          "schema": [
            {
              "id": "linkedin_url",
              "displayName": "linkedin_url",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        768,
        336
      ],
      "id": "73a3de2e-abd4-447b-be91-8dabbfc95854",
      "name": "Append row in sheet1",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "o2wjO6VTorTEj5dG",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "aggregate": "aggregateAllItemData",
        "options": {}
      },
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [
        976,
        336
      ],
      "id": "87888c1f-079d-4bd4-9f37-2afb5a1449d5",
      "name": "Aggregate"
    },
    {
      "parameters": {
        "jsCode": "// Get the start value from 'Edit Fields2' node\nconst startValue = $('If1').first().json.start\n// Add 10 to the start value\nconst start = startValue + 10;\n\n// Return the new value\nreturn { json: { start } };\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1184,
        336
      ],
      "id": "2e8c3aef-774a-404f-8105-b8fed2c1cdc7",
      "name": "Code3"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1392,
        336
      ],
      "id": "80806201-4ed6-4369-9491-75f914ceb5cf",
      "name": "Wait",
      "webhookId": "049c90c8-5407-4020-a056-69a973b6b4b9"
    }
  ],
  "pinData": {},
  "connections": {
    "When chat message received": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Set jobs prompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set Profiles prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set jobs prompt": {
      "main": [
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Profiles prompt": {
      "main": [
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "Create sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create sheet": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond to Chat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Code2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code2": {
      "main": [
        [
          {
            "node": "Append row in sheet1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet1": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Code3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code3": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "646e6f62-fb87-4dc4-8582-054ef4e8a404",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "281c34c03b9c41f054c536eeb966e9e503918cf7f00e3bc32a5ff9cca85ca255"
  },
  "id": "MK52er16dBpJTCuZ",
  "tags": []
}