{
  "nodes": [
    {
      "parameters": {
        "jsCode": "// Build request query parameters with safe handling of empty fields\nconst config = $input.item.json;\n\nfunction splitSafe(value, delimiter) {\n  if (!value || typeof value !== 'string') return '';\n  return value.split(delimiter).map(s => s.trim()).filter(Boolean).join(',');\n}\n\n// Convert job titles delimited by '/' to comma-separated for Harvest API\nlet titles = config.JobTitles;\nif (titles && typeof titles === 'string' && titles.includes('/')) {\n  titles = titles.split('/').join(',');\n}\n\nconst queryParams = {\n  locations: splitSafe(config.Location, ','),\n  currentJobTitles: splitSafe(titles, ','),\n  seniorityLevelIds: splitSafe(config.SeniorityIds, ','),\n  industryIds: splitSafe(config.IndustryIds, ','),\n  profileLanguages: 'en',\n  page: 1\n};\n\n// Filter out empty params\nconst activeParams = {};\nfor (const [key, val] of Object.entries(queryParams)) {\n  if (val !== undefined && val !== null && val !== '') {\n    activeParams[key] = String(val);\n  }\n}\n\n// Build full URL with encoded query string — bypasses n8n toggle quirks\nconst base = 'https://api.harvest-api.com/linkedin/lead-search';\nconst qs = Object.entries(activeParams)\n  .map(([k, v]) => encodeURIComponent(k) + '=' + encodeURIComponent(v))\n  .join('&');\nconst _url = base + '?' + qs;\n\nreturn { json: { ...activeParams, _url } };"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -4880,
        2784
      ],
      "id": "9491d8c1-e170-4029-8e62-2d9c46cea5a8",
      "name": "Prepare Request Body"
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "30 7 * * *"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [
        -6304,
        2912
      ],
      "id": "3cf3ecbb-830b-44ef-b7a6-fc9a9392162d",
      "name": "Every Morning at 7:"
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "list",
          "cachedResultName": "LinkedIn Profile Search configs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": 552164539,
          "mode": "list",
          "cachedResultName": "profile_buffer",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit#gid=552164539"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        -6080,
        2912
      ],
      "id": "6c9d6d9e-71ef-4ce7-ae11-d57f9cbc8aed",
      "name": "Read Buffer1",
      "alwaysOutputData": true,
      "executeOnce": false,
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Count pending (unsent) profiles in buffer\nconst allItems = $input.all();\nconst pending = allItems.filter(i => i.json.Status === 'Pending');\nconst needsSearch = pending.length < 10;\n\nreturn {\n  json: {\n    pendingCount: pending.length,\n    needsSearch: needsSearch,\n    message: needsSearch \n      ? `Buffer has ${pending.length} profiles, need to search for more` \n      : `Buffer has ${pending.length} profiles, enough for today`\n  }\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -5856,
        2912
      ],
      "id": "a624c582-bb45-4de0-b2ad-af1ece9d5817",
      "name": "Check Buffer Size1"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "if-1",
              "leftValue": "={{ $json.needsSearch }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -5648,
        2912
      ],
      "id": "ce132531-372b-49fa-bb0f-36e6dd118bf0",
      "name": "Need Search?1"
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "list",
          "cachedResultName": "LinkedIn Profile Search configs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "search_configs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit#gid=0"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        -5424,
        2784
      ],
      "id": "ad7a8195-638f-49c7-a724-c1a2ce01a07a",
      "name": "Read Search Configs1",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "filter-1",
              "leftValue": "={{ $json.Status }}",
              "rightValue": "Used",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.3,
      "position": [
        -5200,
        2784
      ],
      "id": "f3dd4df9-38f7-4395-b986-f563caade397",
      "name": "Filter Unused Configs1"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.limit",
      "typeVersion": 1,
      "position": [
        -4976,
        2784
      ],
      "id": "fdd27998-091e-4d29-8c9d-e6f41881d651",
      "name": "Take First Config1"
    },
    {
      "parameters": {
        "method": "GET",
        "url": "={{ $json._url }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "timeout": 120000
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "continueOnFail": false,
      "position": [
        -4656,
        2784
      ],
      "id": "929f0391-8752-41f8-9d98-ccae08762828",
      "name": "Harvest Lead Search",
      "alwaysOutputData": false,
      "credentials": {
        "httpHeaderAuth": {
          "id": "",
          "name": "Header Auth account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Process Harvest API results: filter, dedup, add to buffer\nconst response = $input.all()[0]?.json || {};\n\n// If the HTTP node somehow passed through an error body, throw hard\nif (response.error || (response.status && response.status >= 400)) {\n  throw new Error(`API Error: ${response.error || 'Unknown Error'} (Status ${response.status})`);\n}\n\nconst profiles = Array.isArray(response.elements) ? response.elements : [];\nconst config = $('Take First Config1').first().json;\n\n// Read existing buffer URLs for dedup\nconst bufferItems = $('Read Buffer1').all();\nconst existingUrls = new Set(bufferItems.map(i => i.json.LinkedinUrl).filter(Boolean));\n\n// Filter and prepare profiles for buffer\nconst newProfiles = profiles\n  .filter(p => p.linkedinUrl && !existingUrls.has(p.linkedinUrl))\n  .map(p => {\n    const pos = p.currentPositions?.[0] || {};\n    const loc = p.location?.linkedinText || '';\n    return {\n      LinkedinUrl: p.linkedinUrl,\n      Name: `${p.firstName || ''} ${p.lastName || ''}`.trim(),\n      Headline: `${pos.title || ''} at ${pos.companyName || ''}`.substring(0, 200).trim(),\n      Title: pos.title || '',\n      Company: pos.companyName || '',\n      Location: loc,\n      Connections: 0,\n      HasPhoto: p.pictureUrl ? 'Yes' : 'No',\n      IsPremium: p.premium ? 'Yes' : 'No',\n      IsOpen: p.openProfile ? 'Yes' : 'No',\n      Status: 'Pending',\n      AddedDate: new Date().toISOString().split('T')[0],\n      ConfigLabel: `${config.Location} | ${config.IndustryIds}`\n    };\n  });\n\nif (newProfiles.length === 0) {\n  return [{ json: { _isEmpty: true } }];\n}\nreturn newProfiles.map(p => ({ json: p }));"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "continueOnFail": false,
      "position": [
        -4544,
        2784
      ],
      "id": "48c388a0-e02d-464b-9b72-7d149baf483b",
      "name": "Process New Profiles1"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "list",
          "cachedResultName": "LinkedIn Profile Search configs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "profile_buffer",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "LinkedinUrl": "={{ $json.LinkedinUrl }}",
            "Name": "={{ $json.Name }}",
            "Headline": "={{ $json.Headline }}",
            "Title": "={{ $json.Title }}",
            "Company": "={{ $json.Company }}",
            "Location": "={{ $json.Location }}",
            "Connections": "={{ $json.Connections }}",
            "HasPhoto": "={{ $json.HasPhoto }}",
            "IsPremium": "={{ $json.IsPremium }}",
            "IsOpen": "={{ $json.IsOpen }}",
            "Status": "={{ $json.Status }}",
            "AddedDate": "={{ $json.AddedDate }}",
            "ConfigLabel": "={{ $json.ConfigLabel }}"
          },
          "schema": [
            {
              "id": "LinkedinUrl",
              "displayName": "LinkedinUrl",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Name",
              "displayName": "Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Headline",
              "displayName": "Headline",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Title",
              "displayName": "Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Company",
              "displayName": "Company",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Location",
              "displayName": "Location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Connections",
              "displayName": "Connections",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "HasPhoto",
              "displayName": "HasPhoto",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "IsPremium",
              "displayName": "IsPremium",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "IsOpen",
              "displayName": "IsOpen",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "AddedDate",
              "displayName": "AddedDate",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "ConfigLabel",
              "displayName": "ConfigLabel",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        -4096,
        2512
      ],
      "id": "9c0a8a9b-8f03-4fa3-bd26-2fd4e7789b62",
      "name": "Save to Buffer1",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "list",
          "cachedResultName": "LinkedIn Profile Search configs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "search_configs",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "row_number": "={{ $('Take First Config1').first().json.row_number }}",
            "Status": "Used"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "row_number",
              "displayName": "row_number",
              "type": "number",
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        -4096,
        2864
      ],
      "id": "78fccdde-c873-486e-999b-8cc61ca4bd41",
      "name": "Mark Config Used1",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "list",
          "cachedResultName": "LinkedIn Profile Search configs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": 552164539,
          "mode": "list",
          "cachedResultName": "profile_buffer",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit#gid=552164539"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        -5200,
        3120
      ],
      "id": "aeb926e2-0689-42fd-a63b-85d57d53d390",
      "name": "Read Fresh Buffer1",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Pick best 10 pending profiles from buffer\nconst allItems = $input.all();\nconst pending = allItems.filter(i => i.json.Status === 'Pending');\n\nif (pending.length === 0) {\n  return { json: { message: '❌ No pending profiles in buffer. All configs may be used up.', profiles: [], count: 0 } };\n}\n\n// Sanitize text: strip chars that Telegram's parser treats as markdown entities\nfunction safe(str) {\n  if (!str) return '';\n  return String(str).replace(/[\\\\[\\\\]_*`]/g, '');\n}\n\n// Score and sort: photo + premium + open + high connections = better\nconst scored = pending.map(i => {\n  const p = i.json;\n  let score = 0;\n  if (p.HasPhoto === 'Yes') score += 3;\n  if (p.IsPremium === 'Yes') score += 2;\n  if (p.IsOpen === 'Yes') score += 2;\n  const conns = parseInt(p.Connections) || 0;\n  if (conns >= 5000) score += 3;\n  else if (conns >= 1000) score += 2;\n  else if (conns >= 500) score += 1;\n  return { ...p, _score: score };\n});\n\nscored.sort((a, b) => b._score - a._score);\nconst selected = scored.slice(0, 10);\n\n// Format Telegram message — use () not [] for connections to avoid broken link entities\nconst message = selected.map((p, i) => {\n  const photo = p.HasPhoto === 'Yes' ? '📷' : '';\n  const premium = p.IsPremium === 'Yes' ? '⭐' : '';\n  const open = p.IsOpen === 'Yes' ? '🔓' : '';\n  const conns = parseInt(p.Connections) || 0;\n  const connStr = conns >= 1000 ? `${(conns/1000).toFixed(1)}k` : `${conns}`;\n  return `${i + 1}. ${photo}${premium}${open} ${safe(p.Name)} (${connStr})\\n   ${safe(p.Headline || p.Title)}\\n   📍 ${safe(p.Location)}\\n   ${p.LinkedinUrl}`;\n}).join('\\n\\n');\n\nconst header = `🔍 LinkedIn Leads (${new Date().toISOString().split('T')[0]})\\n📊 Buffer: ${pending.length} pending → sending ${selected.length}\\n`;\n\nreturn {\n  json: {\n    message: header + '\\n' + message,\n    profiles: selected.map(p => ({ LinkedinUrl: p.LinkedinUrl, Name: p.Name, Title: p.Title, Company: p.Company, Location: p.Location })),\n    selectedUrls: selected.map(p => p.LinkedinUrl),\n    count: selected.length\n  }\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -4976,
        3120
      ],
      "id": "f8ccb029-1d7e-4232-9bc7-42ad2a7277d6",
      "name": "Pick 10 & Format1"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "if-2",
              "leftValue": "={{ $json.count }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -4768,
        3120
      ],
      "id": "bb203a3e-f338-453c-a5ce-f1fd5a976aac",
      "name": "Has Profiles?1"
    },
    {
      "parameters": {
        "chatId": "YOUR_TELEGRAM_CHAT_ID",
        "text": "={{ $json.message }}",
        "additionalFields": {
          "appendAttribution": false,
          "parse_mode": ""
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -4544,
        3056
      ],
      "id": "4ceb07e8-3169-4c85-adc3-4312e55cfb52",
      "name": "Send to Telegram1",
      "webhookId": "b1000001-0001-0001-0001-000000000001",
      "credentials": {
        "telegramApi": {
          "id": "",
          "name": "Telegram API account"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Create individual update items to mark profiles as Sent in buffer\nconst selectedUrls = $('Pick 10 & Format1').first().json.selectedUrls || [];\nreturn selectedUrls.map(url => ({  json: {\n    LinkedinUrl: url,\n    Status: 'Sent',\n    SentDate: new Date().toISOString().split('T')[0]\n  }\n}));"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -4320,
        3056
      ],
      "id": "c52cca7f-9ab0-4737-a61f-90874cff56fe",
      "name": "Split for Update1"
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "list",
          "cachedResultName": "LinkedIn Profile Search configs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "profile_buffer",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "LinkedinUrl": "={{ $json.LinkedinUrl }}",
            "Status": "={{ $json.Status }}",
            "SentDate": "={{ $json.SentDate }}"
          },
          "matchingColumns": [
            "LinkedinUrl"
          ],
          "schema": [
            {
              "id": "LinkedinUrl",
              "displayName": "LinkedinUrl",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "SentDate",
              "displayName": "SentDate",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        -4096,
        3056
      ],
      "id": "40a44571-77a2-4915-97ed-051b58f2c4b0",
      "name": "Mark Sent in Buffer1",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "chatId": "YOUR_TELEGRAM_CHAT_ID",
        "text": "=⚠️ LinkedIn Leads: no pending profiles in buffer and no unused search configs left. Time to add new configs!",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.1,
      "position": [
        -4544,
        3232
      ],
      "id": "d51e3039-2f33-4626-b17b-71542ee858c2",
      "name": "Notify Empty Buffer1",
      "webhookId": "b1000001-0001-0001-0001-000000000002",
      "credentials": {
        "telegramApi": {
          "id": "",
          "name": "Telegram API account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $json._isEmpty }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -4352,
        2784
      ],
      "id": "788223b7-96f8-4104-9834-e8e621fa0525",
      "name": "Check If Empty"
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "list",
          "cachedResultName": "LinkedIn Profile Search configs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "search_configs",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "row_number": "={{ $('Take First Config1').first().json.row_number }}",
            "Status": "Used"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "row_number",
              "displayName": "row_number",
              "type": "number",
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        -4096,
        3312
      ],
      "id": "6ad2fef4-cdfd-4993-837e-fab0c64be21d",
      "name": "Mark Config Used (Empty)",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "",
          "name": "Google Sheets account"
        }
      }
    }
  ],
  "connections": {
    "Prepare Request Body": {
      "main": [
        [
          {
            "node": "Harvest Lead Search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every Morning at 7:": {
      "main": [
        [
          {
            "node": "Read Buffer1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Buffer1": {
      "main": [
        [
          {
            "node": "Check Buffer Size1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Buffer Size1": {
      "main": [
        [
          {
            "node": "Need Search?1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Need Search?1": {
      "main": [
        [
          {
            "node": "Read Search Configs1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Read Fresh Buffer1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Search Configs1": {
      "main": [
        [
          {
            "node": "Filter Unused Configs1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Unused Configs1": {
      "main": [
        [
          {
            "node": "Take First Config1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Take First Config1": {
      "main": [
        [
          {
            "node": "Prepare Request Body",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Harvest Lead Search": {
      "main": [
        [
          {
            "node": "Process New Profiles1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process New Profiles1": {
      "main": [
        [
          {
            "node": "Check If Empty",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save to Buffer1": {
      "main": [
        [
          {
            "node": "Read Fresh Buffer1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Fresh Buffer1": {
      "main": [
        [
          {
            "node": "Pick 10 & Format1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pick 10 & Format1": {
      "main": [
        [
          {
            "node": "Has Profiles?1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Profiles?1": {
      "main": [
        [
          {
            "node": "Send to Telegram1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Notify Empty Buffer1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send to Telegram1": {
      "main": [
        [
          {
            "node": "Split for Update1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split for Update1": {
      "main": [
        [
          {
            "node": "Mark Sent in Buffer1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check If Empty": {
      "main": [
        [
          {
            "node": "Mark Config Used (Empty)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Save to Buffer1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Mark Config Used1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mark Config Used (Empty)": {
      "main": [
        [
          {
            "node": "Read Search Configs1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": ""
  }
}