8
n8n 中文网amn8n.com

LinkedIn 自动评论 - 创作者中心

高级

这是一个Social Media, Multimodal AI领域的自动化工作流,包含 39 个节点。主要使用 If, Set, Code, Wait, ConvertToFile 等节点。 使用 GPT-4o 和 Phantombuster 实现 LinkedIn 自动互动评论

前置要求
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "rkxGxBa9TAlFHrSd",
  "meta": {
    "instanceId": "2cf742429c2e3ee4e5a20069d3d8a75208519303b864f026a79464efa726bd95",
    "templateCredsSetupCompleted": true
  },
  "name": "LinkedIn 自动评论 - 创作者中心",
  "tags": [],
  "nodes": [
    {
      "id": "ca0ddcb6-eac0-4dd6-ba06-7b2dafdebe0c",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        -1152,
        -1200
      ],
      "webhookId": "034ce185-00da-45f3-8695-9624d3467de1",
      "parameters": {
        "amount": 30
      },
      "typeVersion": 1.1
    },
    {
      "id": "15a3b305-304c-443f-aee8-53bad10415e9",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1424,
        -656
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "chatgpt-4o-latest",
          "cachedResultName": "chatgpt-4o-latest"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "E4PFATctY0kV00hl",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a17410db-8f35-4a32-9411-f94dd68267c3",
      "name": "等待1",
      "type": "n8n-nodes-base.wait",
      "position": [
        -320,
        -800
      ],
      "webhookId": "5123048c-4e3b-4596-926b-8a26dd943b0f",
      "parameters": {
        "amount": 30
      },
      "typeVersion": 1.1
    },
    {
      "id": "bfb60257-2e4b-42d5-80cd-2626cb3d114c",
      "name": "启动代理",
      "type": "n8n-nodes-base.phantombuster",
      "position": [
        -1360,
        -1200
      ],
      "parameters": {
        "agentId": "={{ $json.id }}",
        "jsonParameters": true,
        "additionalFields": {
          "argumentsJson": "={\n  \"category\": \"Content\",\n\"connectionDegreesToScrape\": [\"2\", \"3+\"],\n  \"numberOfLinesPerLaunch\": {{$('Set ENV Variables').item.json.ENV_SEARCH_RESULTS_PER_LAUNCH}},\n\"numberOfResultsPerLaunch\": {{$('Set ENV Variables').item.json.ENV_SEARCH_RESULTS_PER_LAUNCH}},\n\"numberOfResultsPerSearch\": {{$('Set ENV Variables').item.json.ENV_SEARCH_RESULTS_PER_LAUNCH}},\n  \"searchType\": \"keywords\",\n\"enrichLeadsWithAdditionalInformation\": true,\n  \"linkedInSearchUrl\": \"https://www.linkedin.com/search/results/all/\",\n  \"identityId\": \"8677906884862411\",\n  \"sessionCookie\": \"{{$('Set ENV Variables').item.json.ENV_SESSION_COOKIE}}\",\n  \"keywords\": \"{{$('Set ENV Variables').item.json.ENV_SEARCH_TERM}}\"\n}"
        }
      },
      "credentials": {
        "phantombusterApi": {
          "id": "Zf0AAqqdjBFfyW4W",
          "name": "Phantombuster account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a2789353-cb54-40d9-b02c-28ec853e2859",
      "name": "获取随机帖子",
      "type": "n8n-nodes-base.code",
      "position": [
        -2688,
        -800
      ],
      "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.textContent\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "85ccb579-aa24-4819-aa8b-68885e82306b",
      "name": "创建评论",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1424,
        -800
      ],
      "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 (LinkedIn-optimiert)\n- Beziehe dich subtil auf den Original-Post Inhalt\n\n**POST-INHALT FÜR KOMMENTAR:**\n{{ $('Get Random Post').first().json.description }} \n\nErstelle einen perfekten LinkedIn-Kommentar.",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "452b162d-1a7d-49e7-a76b-dc484dd9f94e",
      "name": "创建 CSV 二进制文件",
      "type": "n8n-nodes-base.code",
      "position": [
        -1104,
        -800
      ],
      "parameters": {
        "jsCode": "// Extract correct values\nconst postUrl = $('Get Random Post').first().json.postUrl + \"/?&actorCompanyId=\" + $('Set ENV Variables').first().json.ENV_COMPANY_ID_LINKEDIN;\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": "002902d4-7228-4a45-8a7d-0ac89b7cd002",
      "name": "上传 CSV",
      "type": "n8n-nodes-base.microsoftSharePoint",
      "position": [
        -960,
        -800
      ],
      "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": "linkedin_posts_to_comment.csv",
        "operation": "upload",
        "fileContents": "data",
        "requestOptions": {}
      },
      "credentials": {
        "microsoftSharePointOAuth2Api": {
          "id": "jZkLTQXyVEzxtmp3",
          "name": "Microsoft SharePoint account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "cb09abc7-128f-46b9-9757-bf4634adc9aa",
      "name": "获取自动评论代理",
      "type": "n8n-nodes-base.phantombuster",
      "position": [
        -720,
        -800
      ],
      "parameters": {
        "agentId": "5630833318534903",
        "operation": "get"
      },
      "credentials": {
        "phantombusterApi": {
          "id": "Zf0AAqqdjBFfyW4W",
          "name": "Phantombuster account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e8b8b531-e2b9-4ae7-86f2-e7425899ec0c",
      "name": "获取帖子",
      "type": "n8n-nodes-base.phantombuster",
      "position": [
        -976,
        -1200
      ],
      "parameters": {
        "agentId": "1609454338224846",
        "operation": "getOutput",
        "additionalFields": {}
      },
      "credentials": {
        "phantombusterApi": {
          "id": "Zf0AAqqdjBFfyW4W",
          "name": "Phantombuster account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6a40123b-2583-420f-a5c7-be371d238c82",
      "name": "启动 AC 代理",
      "type": "n8n-nodes-base.phantombuster",
      "position": [
        -512,
        -800
      ],
      "parameters": {
        "agentId": "5630833318534903",
        "jsonParameters": true,
        "additionalFields": {
          "argumentsJson": "={\n  \"numberOfLinesPerLaunch\": 1,\n  \"sessionCookie\": \"{{$('Set ENV Variables').first().json.ENV_SESSION_COOKIE}}\",\n  \"spreadsheetUrl\": \"{{ $('Upload CSV').item.json['@content.downloadUrl'] }}\"\n}"
        }
      },
      "credentials": {
        "phantombusterApi": {
          "id": "Zf0AAqqdjBFfyW4W",
          "name": "Phantombuster account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "02649ff0-8f07-4ac0-bfe2-dc0c5f97f78c",
      "name": "获取响应",
      "type": "n8n-nodes-base.phantombuster",
      "position": [
        -128,
        -800
      ],
      "parameters": {
        "agentId": "5630833318534903",
        "operation": "getOutput",
        "additionalFields": {}
      },
      "credentials": {
        "phantombusterApi": {
          "id": "Zf0AAqqdjBFfyW4W",
          "name": "Phantombuster account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3a931925-82d0-4d6e-a518-68a47737a0c0",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2128,
        -1344
      ],
      "parameters": {
        "color": 5,
        "width": 1300,
        "height": 400,
        "content": "## 通过搜索关键词获取 LinkedIn 帖子"
      },
      "typeVersion": 1
    },
    {
      "id": "9bc3959d-9de7-48ad-ba9e-d767f4480284",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2896,
        -928
      ],
      "parameters": {
        "color": 3,
        "width": 2068,
        "height": 364,
        "content": "## 处理帖子并生成评论"
      },
      "typeVersion": 1
    },
    {
      "id": "f1e33aa2-258e-484b-bf51-3a6640ea45a9",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -816,
        -928
      ],
      "parameters": {
        "width": 948,
        "height": 368,
        "content": "## 启动自动评论代理发布评论"
      },
      "typeVersion": 1
    },
    {
      "id": "98ef2702-956a-4885-9ce1-9bc999328f04",
      "name": "获取搜索代理",
      "type": "n8n-nodes-base.phantombuster",
      "position": [
        -1552,
        -1200
      ],
      "parameters": {
        "agentId": "1609454338224846",
        "operation": "get"
      },
      "credentials": {
        "phantombusterApi": {
          "id": "Zf0AAqqdjBFfyW4W",
          "name": "Phantombuster account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "67dafef7-8e3f-4534-b794-c67256491d40",
      "name": "设置环境变量",
      "type": "n8n-nodes-base.set",
      "position": [
        -1760,
        -1200
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "e24e8c1a-c6c9-4ae2-a0ef-e0e7369dc262",
              "name": "ENV_SEARCH_TERM",
              "type": "string",
              "value": "={{ $json.output.parseJson().search_term }}"
            },
            {
              "id": "cf050595-8ad9-4f78-bca4-f463e8b9982e",
              "name": "ENV_SESSION_COOKIE",
              "type": "string",
              "value": "={{ $('Select Cookie').first().json.output.parseJson().session_cookie }}"
            },
            {
              "id": "29cce2e6-90ae-419c-8f2c-9cd310726183",
              "name": "ENV_SEARCH_RESULTS_PER_LAUNCH",
              "type": "string",
              "value": "5"
            },
            {
              "id": "6c337012-3bd9-49b9-86a4-b8e9795eb8f7",
              "name": "ENV_COMMENT_PROMPT",
              "type": "string",
              "value": "Erstelle einen ansprechenden LinkedIn-Kommentar basierend auf dem gegebenen Post-Inhalt."
            },
            {
              "id": "eee1f029-fa62-439b-a52f-4d8820e55be4",
              "name": "ENV_COMMENT_LANGUAGE",
              "type": "string",
              "value": "Deutsch"
            },
            {
              "id": "6e8e7b08-ffa6-4411-a143-e8e7ec70d191",
              "name": "ENV_COMPANY_ID_LINKEDIN",
              "type": "string",
              "value": "78274663"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e6c2b43e-1e74-42c2-82ac-e299d3398f08",
      "name": "生成随机搜索词",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -2112,
        -1200
      ],
      "parameters": {
        "text": "=Can you create a single random search term related to Artificial Intelligence and Business Process Automation, suitable for fetching LinkedIn posts?\nThe search term should be human like. Something like \"AIBizAutomation\" is not realistic.\nYou can be very vague and also use IT companies as search terms.\nTry to be as random as possible because I can't track with search terms you already generated and I can use a search term only once.\n\nPlease respond only with a **valid, raw JSON object**, like this:\n{\n  \"search_term\": \"Automation\"\n}",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "89eb5d65-6a89-4031-90ee-866330f479b9",
      "name": "计划触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1984,
        -1600
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "fc10ed9b-2f5b-4b0d-9795-e47e609c6f8a",
      "name": "OpenAI 聊天模型1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -2096,
        -1056
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "chatgpt-4o-latest",
          "cachedResultName": "chatgpt-4o-latest"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "E4PFATctY0kV00hl",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "216af711-09a5-4e01-aa3f-a43e31337a67",
      "name": "更新文件",
      "type": "n8n-nodes-base.microsoftSharePoint",
      "position": [
        -1568,
        -800
      ],
      "parameters": {
        "file": {
          "__rl": true,
          "mode": "list",
          "value": "01M45PWA36Y6B5NNKSCFHLCZIRBXOG5NCW",
          "cachedResultName": "linkedin_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": "linkedin_posts_already_commented.csv",
        "operation": "update",
        "fileContents": "data",
        "requestOptions": {},
        "changeFileContent": true
      },
      "credentials": {
        "microsoftSharePointOAuth2Api": {
          "id": "jZkLTQXyVEzxtmp3",
          "name": "Microsoft SharePoint account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6801929d-4ad1-4603-92de-6f773fe2c6cf",
      "name": "下载文件",
      "type": "n8n-nodes-base.microsoftSharePoint",
      "position": [
        -2528,
        -800
      ],
      "parameters": {
        "file": {
          "__rl": true,
          "mode": "list",
          "value": "01M45PWA36Y6B5NNKSCFHLCZIRBXOG5NCW",
          "cachedResultName": "linkedin_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": {
          "id": "jZkLTQXyVEzxtmp3",
          "name": "Microsoft SharePoint account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "27a4bc94-8859-48c5-94c5-c98a1bd817ce",
      "name": "检查是否在列表中",
      "type": "n8n-nodes-base.code",
      "position": [
        -2208,
        -800
      ],
      "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(\"🚨 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(\"✅ randomPost:\", randomPost);\nconsole.log(\"✅ 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(`🟠 Comparing:\\n→ raw: ${candidateRaw}\\n→ normalized: ${candidate}\\n→ target: ${randomPost}`);\n\n  if (candidate === randomPost) {\n    isDuplicate = true;\n    break;\n  }\n}\n\nreturn [{ json: { isDuplicate } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "34a9d026-17b9-4f8b-bdf1-22c10b0bd71c",
      "name": "条件判断",
      "type": "n8n-nodes-base.if",
      "position": [
        -2064,
        -800
      ],
      "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": "111cacd8-845a-4886-be50-b59d0fd3cc5d",
      "name": "等待2",
      "type": "n8n-nodes-base.wait",
      "position": [
        -2848,
        -800
      ],
      "webhookId": "df99f781-2d6d-4a98-9846-97843180f9e7",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "9988cda7-1734-4c89-a2a0-664a8cbd8119",
      "name": "准备更新数据",
      "type": "n8n-nodes-base.code",
      "position": [
        -1888,
        -800
      ],
      "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": "65e3d941-304a-4aec-ba3d-416254a6159d",
      "name": "从文件提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -2368,
        -800
      ],
      "parameters": {
        "options": {
          "headerRow": true
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "eca4b1a3-d938-4e77-a7ac-237b831140e3",
      "name": "转换为文件",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        -1728,
        -800
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "d1eddbdf-1fde-4f2d-b6b1-b77aa9fc07a9",
      "name": "获取可用会话 Cookie",
      "type": "n8n-nodes-base.microsoftSharePoint",
      "position": [
        -1808,
        -1600
      ],
      "parameters": {
        "file": {
          "__rl": true,
          "mode": "list",
          "value": "01M45PWA6IR6PTZ4EFZVH2XP5XGQ2MVXRW",
          "cachedResultName": "linkedin_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": {
          "id": "jZkLTQXyVEzxtmp3",
          "name": "Microsoft SharePoint account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6e7b0891-dfb0-427a-b1cf-898ee211b00d",
      "name": "提取 Cookie",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -1600,
        -1600
      ],
      "parameters": {
        "options": {},
        "operation": "text"
      },
      "typeVersion": 1
    },
    {
      "id": "64342664-102c-4861-990d-b08b4ad990ac",
      "name": "选择 Cookie",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1376,
        -1600
      ],
      "parameters": {
        "text": "=##################  PROMPT  ##################\n\n**ROLE:**  You are a session-cookie selector.\n\n**CURRENT BERLIN TIME**  \nDate & time : {{ $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   • N = number of cookies in the list (2 ≤ N ≤ 4).  \n   • H = current hour as an integer (0–23).  \n   • W = 24 ÷ N  (the width of each time slice in hours, always an integer).\n\n2. Determine the slice index:  \n   sliceIndex = floor(H ÷ W)  // 0-based\n\n3. Choose the cookie at position *(sliceIndex + 1)* in the list.  \n   • Example when N = 4 (W = 6):  \n     00-05 → 1st, 06-11 → 2nd, 12-17 → 3rd, 18-23 → 4th  \n   • Example when N = 3 (W = 8):  \n     00-07 → 1st, 08-15 → 2nd, 16-23 → 3rd  \n   • Example when N = 2 (W = 12):  \n     00-11 → 1st, 12-23 → 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": "eda83bef-559d-4b03-8ab6-45b42e053242",
      "name": "OpenAI聊天模型2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1376,
        -1456
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "chatgpt-4o-latest",
          "cachedResultName": "chatgpt-4o-latest"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "E4PFATctY0kV00hl",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f49fb8ab-8e40-4cfb-86b5-0228308c9d3f",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2128,
        -1728
      ],
      "parameters": {
        "color": 6,
        "width": 1300,
        "height": 368,
        "content": "## 通过搜索关键词获取 LinkedIn 帖子"
      },
      "typeVersion": 1
    },
    {
      "id": "5fddace1-4fc4-449a-bc5b-b581ccc9fd6f",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -816,
        -1728
      ],
      "parameters": {
        "width": 432,
        "height": 288,
        "content": "### 1) Cookie 和搜索词选择"
      },
      "typeVersion": 1
    },
    {
      "id": "f684ca9c-3656-4496-bdab-f2c240ceb5c1",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2544,
        -1344
      ],
      "parameters": {
        "width": 400,
        "height": 272,
        "content": "### 2) 抓取 LinkedIn 帖子"
      },
      "typeVersion": 1
    },
    {
      "id": "8bbe5f78-b384-453b-b9a6-b2c92c013908",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2896,
        -544
      ],
      "parameters": {
        "width": 512,
        "height": 272,
        "content": "### 3) 评论生成"
      },
      "typeVersion": 1
    },
    {
      "id": "2170e6f3-7006-40f3-8e8d-bbb29efa8f02",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2064,
        -544
      ],
      "parameters": {
        "width": 464,
        "height": 272,
        "content": "### 4) CSV 上传与自动评论"
      },
      "typeVersion": 1
    },
    {
      "id": "de072d11-7806-4b91-886a-0d12e3aa8cde",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1328,
        -544
      ],
      "parameters": {
        "width": 496,
        "height": 272,
        "content": "### 5) 去重处理"
      },
      "typeVersion": 1
    },
    {
      "id": "cf384719-df40-43a8-8e26-ec74fc80bdb0",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -928
      ],
      "parameters": {
        "width": 464,
        "height": 240,
        "content": "### 6) 速率限制与调度"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "df5d712c-3422-4b8a-bb75-95d1b61e7461",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Wait2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare Updated Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Get Posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "Get Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait2": {
      "main": [
        [
          {
            "node": "Get Random Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Posts": {
      "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
          }
        ]
      ]
    },
    "Launch Agent": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download file": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Select Cookie": {
      "main": [
        [
          {
            "node": "Generate Random Search Term",
            "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
          }
        ]
      ]
    },
    "Get Search Agent": {
      "main": [
        [
          {
            "node": "Launch Agent",
            "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 Search Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Random Search Term",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Select Cookie",
            "type": "ai_languageModel",
            "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
          }
        ]
      ]
    },
    "Generate Random Search Term": {
      "main": [
        [
          {
            "node": "Set ENV Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Available Session Cookies": {
      "main": [
        [
          {
            "node": "Extract Cookies",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 社交媒体, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量39
分类2
节点类型12
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
plemeo

plemeo

@plemeo

Hi, I'm Gerhard from Plemeo. At plemeo.ai, we focus on AI-driven automation and workflow optimization. Our deep expertise with n8n enables us to streamline processes and boost efficiency in software development. This allows us to deliver real, measurable improvements. Curious how plemeo.ai and n8n can benefit your business? Reach out at info@plemeo.de or visit plemeo.ai.

外部链接
在 n8n.io 查看

分享此工作流