{
  "id": "g4Fo68HZ8ZM6Hvs4",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Instagram Auto Commenting (Profile Post Extractor) - Creators Hub",
  "tags": [
    {
      "id": "Tl9QVfvwkdFQyffg",
      "name": "n8n Creators Hub",
      "createdAt": "2025-08-01T09:19:22.310Z",
      "updatedAt": "2025-08-01T09:19:22.310Z"
    }
  ],
  "nodes": [
    {
      "id": "97fdeac9-a809-4bb1-84e3-1268fc7a5ba3",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1104,
        -1360
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "chatgpt-4o-latest",
          "cachedResultName": "chatgpt-4o-latest"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c5861294-4e0d-43c0-934b-d5c58d445dff",
      "name": "Wait1",
      "type": "n8n-nodes-base.wait",
      "position": [
        128,
        -1520
      ],
      "parameters": {
        "amount": 30
      },
      "typeVersion": 1.1
    },
    {
      "id": "dedd3196-3e1a-4b60-a784-7e4936f6b69e",
      "name": "Get Random Post",
      "type": "n8n-nodes-base.code",
      "position": [
        -2464,
        -1520
      ],
      "parameters": {
        "jsCode": "const data = $input.all().map(item => item.json);\n\nif (!data || data.length === 0) {\n  throw new Error('No Instagram posts data found');\n}\n\n// Get a random post\nconst randomPost = data[Math.floor(Math.random() * data.length)];\n\n// Return only postUrl and description\nreturn {\n  json: {\n    postUrl: randomPost.postUrl,\n    description: randomPost.description\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "b7fb6aec-23e6-41f4-a08d-14d4843e91ec",
      "name": "Create Comment",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1088,
        -1520
      ],
      "parameters": {
        "text": "=Du bist ein spezialisierter Social Media Content Creator.\n\n**AUFGABE:** {{ $('Set ENV Variables').first().json.ENV_COMMENT_PROMPT }}\n\n**KOMMENTAR RICHTLINIEN:**\n- Antworte NUR auf {{ $('Set ENV Variables').first().json.ENV_COMMENT_LANGUAGE }}\n- Maximal 150 Zeichen (Instagram-optimiert)\n- Beziehe dich subtil auf den Original-Post Inhalt\n\n**POST-INHALT F\u00dcR KOMMENTAR:**\n{{ $('Get Random Post').first().json.description }} \n\nErstelle einen perfekten Instagram-Kommentar.",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "56f80bb6-d123-4bd5-8789-877b7111a182",
      "name": "Create CSV Binary",
      "type": "n8n-nodes-base.code",
      "position": [
        -816,
        -1520
      ],
      "parameters": {
        "jsCode": "// Extract correct values\nconst postUrl = $('Get Random Post').first().json.postUrl;\nconsole.log(\"postUrl: \", postUrl)\nconst commentText = $input.first().json.output;\n\n// Clean utility\nconst clean = str => String(str || \"\").replace(/[\\u200B-\\u200D\\uFEFF]/g, \"\").trim();\n\n// Escape and quote single data row\nconst row = [\n  `\"${clean(postUrl).replace(/\"/g, '\"\"')}\"`,\n  `\"${clean(commentText).replace(/\"/g, '\"\"')}\"`\n];\n\n// Convert to buffer without header or BOM\nconst csvBuffer = Buffer.from(row.join(\",\") + \"\\n\", \"utf8\");\n\n// Return binary file\nreturn [\n  {\n    binary: {\n      data: {\n        data: csvBuffer,\n        mimeType: \"text/csv\",\n        fileName: \"phantombuster_clean.csv\"\n      }\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "517a8fe5-bed2-433a-a823-94d5e31da702",
      "name": "Upload CSV",
      "type": "n8n-nodes-base.microsoftSharePoint",
      "position": [
        -656,
        -1520
      ],
      "parameters": {
        "site": {
          "__rl": true,
          "mode": "list",
          "value": "plemeo.sharepoint.com,f304c34c-1252-4b99-a852-059c2036c718,c3bf26ab-bf44-4334-8e5b-e8b680bb9e1d",
          "cachedResultName": "plemeo"
        },
        "folder": {
          "__rl": true,
          "mode": "list",
          "value": "01M45PWAY4RSXX7PGSC5CL27V2Y7XYSNQZ",
          "cachedResultName": "Phantombuster"
        },
        "fileName": "instagram_post_to_comment.csv",
        "operation": "upload",
        "fileContents": "data",
        "requestOptions": {}
      },
      "credentials": {
        "microsoftSharePointOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d27ed660-08d5-48a5-8c5a-cf5c9b58b808",
      "name": "Get Autocomment Agent",
      "type": "n8n-nodes-base.phantombuster",
      "position": [
        -320,
        -1520
      ],
      "parameters": {
        "agentId": "5533276466709830",
        "operation": "get"
      },
      "credentials": {
        "phantombusterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d6d7e4cf-089c-4e6c-9d67-7b06d67ae0af",
      "name": "Launch AC Agent",
      "type": "n8n-nodes-base.phantombuster",
      "position": [
        -96,
        -1520
      ],
      "parameters": {
        "agentId": "5533276466709830",
        "jsonParameters": true,
        "additionalFields": {
          "argumentsJson": "={\n  \"sessionCookie\": \"{{ $('Set ENV Variables').first().json.ENV_SESSION_COOKIE }}\",\n  \"spreadsheetUrl\": \"{{ $('Upload CSV').item.json['@content.downloadUrl'] }}\"\n}"
        }
      },
      "credentials": {
        "phantombusterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "88358da1-f2b6-450e-bc3f-76a0b8588b65",
      "name": "Get Response",
      "type": "n8n-nodes-base.phantombuster",
      "position": [
        336,
        -1520
      ],
      "parameters": {
        "agentId": "5533276466709830",
        "operation": "getOutput",
        "additionalFields": {}
      },
      "credentials": {
        "phantombusterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "57b113b3-31c5-47a2-b638-df87cc88962d",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        -1664
      ],
      "parameters": {
        "width": 1040,
        "height": 400,
        "content": "## Launch Autocomment Agent to Post Comment\n"
      },
      "typeVersion": 1
    },
    {
      "id": "944c13bf-1704-4823-9aac-015551c5e5b6",
      "name": "Set ENV Variables",
      "type": "n8n-nodes-base.set",
      "position": [
        -720,
        -2368
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "debcbe7a-3298-46ec-a8ab-96e8dc0184a7",
              "name": "ENV_SESSION_COOKIE",
              "type": "string",
              "value": "={{ $('Select Cookie').first().json.output.parseJson().session_cookie }}"
            },
            {
              "id": "32531b3f-d01e-4764-9cc5-1f9f37979a3a",
              "name": "ENV_COMMENT_PROMPT",
              "type": "string",
              "value": "Erstelle einen ansprechenden Instagram-Kommentar basierend auf dem gegebenen Post-Inhalt."
            },
            {
              "id": "6e0bf007-ebce-4b39-9920-2f523b5bfe70",
              "name": "ENV_COMMENT_LANGUAGE",
              "type": "string",
              "value": "Deutsch"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "150fd84d-2dce-4626-9ece-22387b1ed106",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1680,
        -2368
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 2,
              "triggerAtMinute": 30
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "34a3a3b8-970a-40cb-a99c-1dc841443cf5",
      "name": "Update file",
      "type": "n8n-nodes-base.microsoftSharePoint",
      "position": [
        -1248,
        -1520
      ],
      "parameters": {
        "file": {
          "__rl": true,
          "mode": "list",
          "value": "01M45PWA37FQNX5XDRVVCYAT6XSISPVTCM",
          "cachedResultName": "instagram_posts_already_commented.csv"
        },
        "site": {
          "__rl": true,
          "mode": "list",
          "value": "plemeo.sharepoint.com,f304c34c-1252-4b99-a852-059c2036c718,c3bf26ab-bf44-4334-8e5b-e8b680bb9e1d",
          "cachedResultName": "plemeo"
        },
        "folder": {
          "__rl": true,
          "mode": "list",
          "value": "01M45PWAY4RSXX7PGSC5CL27V2Y7XYSNQZ",
          "cachedResultName": "Phantombuster"
        },
        "fileName": "instagram_posts_already_commented.csv",
        "operation": "update",
        "fileContents": "data",
        "requestOptions": {},
        "changeFileContent": true
      },
      "credentials": {
        "microsoftSharePointOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "66411156-c8a6-4c16-a71d-2847134c4a80",
      "name": "Download file",
      "type": "n8n-nodes-base.microsoftSharePoint",
      "position": [
        -2288,
        -1520
      ],
      "parameters": {
        "file": {
          "__rl": true,
          "mode": "list",
          "value": "01M45PWA37FQNX5XDRVVCYAT6XSISPVTCM",
          "cachedResultName": "instagram_posts_already_commented.csv"
        },
        "site": {
          "__rl": true,
          "mode": "list",
          "value": "plemeo.sharepoint.com,f304c34c-1252-4b99-a852-059c2036c718,c3bf26ab-bf44-4334-8e5b-e8b680bb9e1d",
          "cachedResultName": "plemeo"
        },
        "folder": {
          "__rl": true,
          "mode": "list",
          "value": "01M45PWAY4RSXX7PGSC5CL27V2Y7XYSNQZ",
          "cachedResultName": "Phantombuster"
        },
        "requestOptions": {}
      },
      "credentials": {
        "microsoftSharePointOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c44bc338-b70c-48ee-a818-9cd5e9b5dc53",
      "name": "Check if in List",
      "type": "n8n-nodes-base.code",
      "position": [
        -1952,
        -1520
      ],
      "parameters": {
        "jsCode": "const randomPost = normalizeUrl($('Get Random Post').first().json.postUrl);\nconst allItems = $('Extract from File').all();\n\nif (!allItems || allItems.length === 0) {\n  return [{ json: { isDuplicate: false } }];\n}\n\nfunction normalizeUrl(url) {\n  if (typeof url !== 'string') {\n    console.log(\"\ud83d\udea8 NOT A STRING:\", url);\n    return '';\n  }\n  return url.trim().toLowerCase().replace(/\\/$/, '');\n}\n\n// Helper function to get postUrl value regardless of BOM\nfunction getPostUrl(item) {\n  const json = item.json;\n  // Try normal field name first\n  if (json.postUrl) return json.postUrl;\n  \n  // Look for any field containing \"postUrl\"\n  const postUrlKey = Object.keys(json).find(key => key.includes('postUrl'));\n  return postUrlKey ? json[postUrlKey] : null;\n}\n\nconsole.log(\"\u2705 randomPost:\", randomPost);\nconsole.log(\"\u2705 allItems:\", allItems);\n\nlet isDuplicate = false;\n\nfor (const item of allItems) {\n  const candidateRaw = getPostUrl(item);\n  const candidate = normalizeUrl(candidateRaw);\n\n  console.log(`\ud83d\udfe0 Comparing:\\n\u2192 raw: ${candidateRaw}\\n\u2192 normalized: ${candidate}\\n\u2192 target: ${randomPost}`);\n\n  if (candidate === randomPost) {\n    isDuplicate = true;\n    break;\n  }\n}\n\nreturn [{ json: { isDuplicate } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "9c426089-a4a1-4bca-b1d6-723c552bda4c",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        -1776,
        -1520
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "bcef43b3-e773-45ba-b245-19ab3fc1e508",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $('Check if in List').first().json.isDuplicate }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "dfe8ca2a-e877-427b-9cf9-9d4a14ff04fd",
      "name": "Wait2",
      "type": "n8n-nodes-base.wait",
      "position": [
        -2624,
        -1520
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "13c86d76-7f0b-4867-a74b-a50f73a6db3c",
      "name": "Prepare Updated Data",
      "type": "n8n-nodes-base.code",
      "position": [
        -1584,
        -1520
      ],
      "parameters": {
        "jsCode": "const existingUrls = $('Extract from File').all().map(item => {\n  // Get the first key (which has the BOM) and use its value\n  const firstKey = Object.keys(item.json)[0];\n  return { postUrl: item.json[firstKey] };\n});\n\nconsole.log(\"existingUrls: \", existingUrls);\n\nconst randomPost = $('Get Random Post').first().json.postUrl;\nconsole.log(\"randomPost: \", randomPost);\n\nreturn [\n  ...existingUrls,\n  { postUrl: randomPost }\n].map(entry => ({ json: entry }));"
      },
      "typeVersion": 2
    },
    {
      "id": "695d6a6a-3969-4dd7-9227-24b82956d6ef",
      "name": "Extract from File",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -2128,
        -1520
      ],
      "parameters": {
        "options": {
          "headerRow": true
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "0fc73bdd-d2b4-4e28-aff8-b1bffe5c8284",
      "name": "Convert to File",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        -1424,
        -1520
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "a3ae7951-3834-4453-ad5b-0e8ed726d81f",
      "name": "Get Available Session Cookies",
      "type": "n8n-nodes-base.microsoftSharePoint",
      "position": [
        -1456,
        -2368
      ],
      "parameters": {
        "file": {
          "__rl": true,
          "mode": "list",
          "value": "01M45PWA5FHBKEDCMCXRBJK64QFIFWOCQE",
          "cachedResultName": "instagram_session_cookies.txt"
        },
        "site": {
          "__rl": true,
          "mode": "list",
          "value": "plemeo.sharepoint.com,f304c34c-1252-4b99-a852-059c2036c718,c3bf26ab-bf44-4334-8e5b-e8b680bb9e1d",
          "cachedResultName": "plemeo"
        },
        "folder": {
          "__rl": true,
          "mode": "list",
          "value": "01M45PWAY4RSXX7PGSC5CL27V2Y7XYSNQZ",
          "cachedResultName": "Phantombuster"
        },
        "requestOptions": {}
      },
      "credentials": {
        "microsoftSharePointOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ccaf486c-ed22-45e0-abee-d6eda9341254",
      "name": "Extract Cookies",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -1248,
        -2368
      ],
      "parameters": {
        "options": {},
        "operation": "text"
      },
      "typeVersion": 1
    },
    {
      "id": "39af0281-a435-4fde-93fb-7f03aef7d22a",
      "name": "Select Cookie",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1040,
        -2368
      ],
      "parameters": {
        "text": "=##################  PROMPT  ##################\n\n**ROLE:**  You are a session-cookie selector.\n\n**CURRENT BERLIN TIME**  \nDate\u2009&\u2009time : {{ $now.setZone('Europe/Berlin').format('DD HH:mm:ss') }}  \nHour (00-23): {{ $now.setZone('Europe/Berlin').format('HH') }}\n\n**SESSION COOKIES (keep order):**  \n{{ $json.data }}\n\n**SELECTION LOGIC**\n\n1. Let  \n   \u2022 N = number of cookies in the list (2 \u2264 N \u2264 4).  \n   \u2022 H = current hour as an integer (0\u201323).  \n   \u2022 W = 24 \u00f7 N \u2003(the width of each time slice in hours, always an integer).\n\n2. Determine the slice index:  \n   sliceIndex = floor(H \u00f7 W)\u2003\u2003// 0-based\n\n3. Choose the cookie at position *(sliceIndex + 1)* in the list.  \n   \u2022 Example when N = 4 (W = 6):  \n     00-05 \u2192 1st, 06-11 \u2192 2nd, 12-17 \u2192 3rd, 18-23 \u2192 4th  \n   \u2022 Example when N = 3 (W = 8):  \n     00-07 \u2192 1st, 08-15 \u2192 2nd, 16-23 \u2192 3rd  \n   \u2022 Example when N = 2 (W = 12):  \n     00-11 \u2192 1st, 12-23 \u2192 2nd\n\n**OUTPUT FORMAT**  \nReturn only the selected session cookie value in a valid JSON-Field called \"session_cookie\", nothing else.\n\n##############################################",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "f9c9b63f-c8f9-402f-b324-56a95435e9e9",
      "name": "OpenAI Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1056,
        -2208
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "chatgpt-4o-latest",
          "cachedResultName": "chatgpt-4o-latest"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ac8242e2-3f1a-48ae-b4ef-a3b290098741",
      "name": "Get Profile Extractor Agent",
      "type": "n8n-nodes-base.phantombuster",
      "position": [
        -1696,
        -1936
      ],
      "parameters": {
        "agentId": "7569425938663423",
        "operation": "get"
      },
      "credentials": {
        "phantombusterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8f57c31b-8d99-441f-a16a-2a306b1a0202",
      "name": "Get List of Accounts",
      "type": "n8n-nodes-base.microsoftSharePoint",
      "position": [
        -1536,
        -1936
      ],
      "parameters": {
        "file": {
          "__rl": true,
          "mode": "list",
          "value": "01M45PWA5UGUOGJDHZDVEJOKYNQFNF4ERC",
          "cachedResultName": "instagram_profiles_to_scrape.csv"
        },
        "site": {
          "__rl": true,
          "mode": "list",
          "value": "plemeo.sharepoint.com,f304c34c-1252-4b99-a852-059c2036c718,c3bf26ab-bf44-4334-8e5b-e8b680bb9e1d",
          "cachedResultName": "plemeo"
        },
        "folder": {
          "__rl": true,
          "mode": "list",
          "value": "01M45PWAY4RSXX7PGSC5CL27V2Y7XYSNQZ",
          "cachedResultName": "Phantombuster"
        },
        "fileName": "instagram_profiles_to_scrape.csv",
        "operation": "update",
        "requestOptions": {}
      },
      "credentials": {
        "microsoftSharePointOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "efaa61d2-51f0-48b1-b23d-a0809f5fcf42",
      "name": "If Empty",
      "type": "n8n-nodes-base.if",
      "position": [
        -592,
        -1936
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "77805c7a-32a4-492e-9084-6a459e8d6b65",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.isEmpty() }}",
              "rightValue": "true"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "8068ec0b-b9f7-456d-a85e-3a40f0578b89",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1040,
        -1936
      ],
      "parameters": {
        "url": "https://api.phantombuster.com/api/v2/agents/fetch?id=7569425938663423",
        "options": {},
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "phantombusterApi"
      },
      "credentials": {
        "phantombusterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "c1b124d2-32c4-45c6-8896-74fb655f5751",
      "name": "HTTP Request1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -880,
        -1936
      ],
      "parameters": {
        "url": "=https://phantombuster.s3.amazonaws.com/{{ $json.data?.orgS3Folder || $json.orgS3Folder }}/{{ $json.data?.s3Folder || $json.s3Folder }}/filtered_result.csv\n",
        "options": {},
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "phantombusterApi"
      },
      "credentials": {
        "phantombusterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "ea4d4211-329b-4ce0-9841-50669a2b2d8c",
      "name": "Prepare Posts",
      "type": "n8n-nodes-base.code",
      "position": [
        -736,
        -1936
      ],
      "parameters": {
        "jsCode": "// Split the \"data\" field into lines\nconst raw = $json[\"data\"] || \"\";\nconst lines = raw.split(\"\\n\").map(l => l.trim()).filter(Boolean);\n\n// First line is the header (\"postUrl\")\nconst header = lines.shift();\n\n// Build an array of { postUrl } objects\nreturn lines.map(url => {\n  return {\n    json: {\n      postUrl: url\n    }\n  };\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "2a426ca7-9f98-45e8-91d6-3a5ec803178b",
      "name": "Wait3",
      "type": "n8n-nodes-base.wait",
      "position": [
        -1200,
        -1936
      ],
      "parameters": {
        "amount": 30
      },
      "typeVersion": 1.1
    },
    {
      "id": "88c15ec9-715b-412a-ab74-71a6a3c28385",
      "name": "Launch Agent1",
      "type": "n8n-nodes-base.phantombuster",
      "position": [
        -1376,
        -1936
      ],
      "parameters": {
        "agentId": "={{ $('Get Profile Extractor Agent').item.json.id }}",
        "jsonParameters": true,
        "additionalFields": {
          "argumentsJson": "={\n  \"numberOfPostsPerProfile\": 20,\n  \"filters\": \"postUrl\",\n  \"spreadsheetUrl\": \"{{$('Get List of Accounts').item.json['@content.downloadUrl']}}\",\n  \"sessionCookie\": \"{{$('Set ENV Variables').item.json.ENV_SESSION_COOKIE}}\"\n}"
        }
      },
      "credentials": {
        "phantombusterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "282b9721-87a3-4d0c-a31e-ee922faf331f",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1744,
        -2496
      ],
      "parameters": {
        "color": 6,
        "width": 1260,
        "height": 400,
        "content": "## Start Workflow and Retrieve Session Cookie\n"
      },
      "typeVersion": 1
    },
    {
      "id": "bc825198-dc23-4ac7-9ee7-228915e49419",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1744,
        -2080
      ],
      "parameters": {
        "color": 5,
        "width": 1260,
        "height": 400,
        "content": "## Get Instagram Posts By Custom Hashtag\n"
      },
      "typeVersion": 1
    },
    {
      "id": "e5a86f9a-000a-44e6-babd-e73003c92fe9",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2672,
        -1664
      ],
      "parameters": {
        "color": 3,
        "width": 2192,
        "height": 400,
        "content": "## Process Posts and Generate Comment \n"
      },
      "typeVersion": 1
    },
    {
      "id": "4d9549a9-0035-4ea2-820a-b7bf59a4940a",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        -2496
      ],
      "parameters": {
        "width": 432,
        "height": 288,
        "content": "### 1) Cookie & Hashtag Selection  \n**What it does**  \n\u2022 Downloads cookie list \u279c **Select Cookie** picks one by hour-slice.  \n\n**Credentials**  \nOpenAI + SharePoint OAuth2.\n\n**Tweaks**  \n\u2022 Add/remove cookies in SharePoint file."
      },
      "typeVersion": 1
    },
    {
      "id": "ca3bcfb0-92bd-4888-a621-6c28d6860bbd",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2144,
        -2080
      ],
      "parameters": {
        "width": 384,
        "height": 256,
        "content": "### 2) Scrape Instagram Posts  \n**What it does**  \n\u2022 **Hashtag Agent** fetches 20 posts for the defined Instagram profiles in the CSV file.  \n\u2022 **Get Posts** forwards raw results downstream.\n\n**Credentials**  \nPhantombuster API.\n\n**Tweaks**   \n\u2022 Adjust scrape depth in the agent UI."
      },
      "typeVersion": 1
    },
    {
      "id": "a576d850-e278-49aa-8325-d3939241a4a5",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2672,
        -1248
      ],
      "parameters": {
        "width": 384,
        "height": 272,
        "content": "### 3) Comment Generation  \n**What it does**  \n\u2022 **Get Random Post** selects one post + description.  \n\u2022 **Create Comment** (GPT-4o) returns a \u2264150-char reply.\n\n**Credentials**  \nOpenAI.\n\n**Tweaks**  \n\u2022 Edit language or style via **Set ENV Variables** / prompt."
      },
      "typeVersion": 1
    },
    {
      "id": "c324d99f-4044-4e58-b8e5-3257152d638a",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1680,
        -1248
      ],
      "parameters": {
        "width": 416,
        "height": 272,
        "content": "### 4) CSV Upload & Auto-comment  \n**What it does**  \n\u2022 Builds one-row CSV (post URL + comment).  \n\u2022 Uploads to SharePoint.  \n\u2022 **Auto-comment Agent** posts the reply.\n\n**Credentials**  \nSharePoint OAuth2 + Phantombuster API.\n\n**Tweaks**  \n\u2022 Rename files/folders in **Upload CSV**.  \n\u2022 Replace SharePoint with Drive/Dropbox if preferred."
      },
      "typeVersion": 1
    },
    {
      "id": "90e911a2-7a80-42b6-b2a3-6053eebc9561",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        -1248
      ],
      "parameters": {
        "width": 400,
        "height": 288,
        "content": "### 5) Deduplication  \n**What it does**  \n\u2022 Downloads `instagram_posts_already_commented.csv`.  \n\u2022 **Check if in List** skips URLs already commented.  \n\u2022 On success, appends the new URL and re-uploads the file.\n\n**Credentials**  \nSharePoint OAuth2.\n\n**Tweaks**  \n\u2022 Modify duplicate logic if extra columns are stored."
      },
      "typeVersion": 1
    },
    {
      "id": "57d88ba0-f8bc-4c74-934f-bca11cce5f5b",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        592,
        -1664
      ],
      "parameters": {
        "width": 384,
        "height": 304,
        "content": "### 6) Rate Limiting & Scheduling  \n**What it does**  \n\u2022 2-hour cron + **Wait** nodes keep totals near 80 comments/day\n  (8 runs \u00d7 10 posts).\n\n**Credentials**  \nNone\n\n**Tweaks**  \n\u2022 Edit cron rule or wait durations.  \n\u2022 Increase comments/day by raising limits and frequency."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "815140cd-74db-4bcb-af32-10a49be4a68c",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Wait2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare Updated Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "Get Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait2": {
      "main": [
        [
          {
            "node": "Get Random Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait3": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Empty": {
      "main": [
        [],
        [
          {
            "node": "Wait2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload CSV": {
      "main": [
        [
          {
            "node": "Get Autocomment Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update file": {
      "main": [
        [
          {
            "node": "Create Comment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download file": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request1": {
      "main": [
        [
          {
            "node": "Prepare Posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Launch Agent1": {
      "main": [
        [
          {
            "node": "Wait3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Posts": {
      "main": [
        [
          {
            "node": "If Empty",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Select Cookie": {
      "main": [
        [
          {
            "node": "Set ENV Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Comment": {
      "main": [
        [
          {
            "node": "Create CSV Binary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Update file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Cookies": {
      "main": [
        [
          {
            "node": "Select Cookie",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Random Post": {
      "main": [
        [
          {
            "node": "Download file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Launch AC Agent": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if in List": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get Available Session Cookies",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create CSV Binary": {
      "main": [
        [
          {
            "node": "Upload CSV",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Check if in List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Create Comment",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Set ENV Variables": {
      "main": [
        [
          {
            "node": "Get Profile Extractor Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Select Cookie",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get List of Accounts": {
      "main": [
        [
          {
            "node": "Launch Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Updated Data": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Autocomment Agent": {
      "main": [
        [
          {
            "node": "Launch AC Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Profile Extractor Agent": {
      "main": [
        [
          {
            "node": "Get List of Accounts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Available Session Cookies": {
      "main": [
        [
          {
            "node": "Extract Cookies",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}