8
n8n 中文网amn8n.com

LinkedIn 群组发帖

中级

这是一个AI, Marketing领域的自动化工作流,包含 13 个节点。主要使用 If, Code, Limit, HttpRequest, GoogleSheets 等节点,结合人工智能技术实现智能自动化。 使用 GPT-4o 从电子表格主题自动发布 LinkedIn 更新

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "MDqbZwyjpy48Ytl0",
  "meta": {
    "instanceId": "260491e02302632e6a217f5c83135ad573c31ec4f93b05d79785a77df9c4a7e5"
  },
  "name": "Linkedin 群组发帖",
  "tags": [],
  "nodes": [
    {
      "id": "511707c0-2e6b-4223-b126-454cf9f4ea11",
      "name": "限制",
      "type": "n8n-nodes-base.limit",
      "position": [
        -1440,
        -200
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "fd6b4832-3a29-475b-8019-470ebf51c501",
      "name": "结构化输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -1072,
        10
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"post\": {\n\t\t\t\"type\": \"string\"\n\t\t}\t\t\n\t}\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "0c8eea04-25b4-452c-917f-d989aeaa89f7",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1192,
        10
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "O2czYITX17GGksaO",
          "name": "OPENAI_ACCOUNT"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "1a02780a-f95e-44f3-932c-c4aa635f9861",
      "name": "Linkedin-帖子主题",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "position": [
        -1880,
        -210
      ],
      "parameters": {
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/147NIoP4NAZtmXdjciHyKdOWqpPvJ9ifoS8P6HJxikY8/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "147NIoP4NAZtmXdjciHyKdOWqpPvJ9ifoS8P6HJxikY8",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/147NIoP4NAZtmXdjciHyKdOWqpPvJ9ifoS8P6HJxikY8/edit?usp=drivesdk",
          "cachedResultName": "Linkedin Post"
        }
      },
      "credentials": {
        "googleSheetsTriggerOAuth2Api": {
          "id": "5RtjOrwI9CDHwaz1",
          "name": "Google Sheets Trigger account 3"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5a6c2f81-1375-4d45-b383-0bdeacb3f32a",
      "name": "验证状态",
      "type": "n8n-nodes-base.if",
      "position": [
        -1660,
        -210
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "ddab9b1e-0de2-4eb9-8d7b-b9f0846eb496",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.Status }}",
              "rightValue": "Pending"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "1c0a2c6d-c2e7-474b-88e0-8b15edb290e4",
      "name": "Linkedin-帖子创建器",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1220,
        -210
      ],
      "parameters": {
        "text": "=You are a LinkedIn post writer. You will be given a title and your task is to create an engaging LinkedIn post based on that title.\n\nYour post should:\n\nBegin with a compelling hook related to the title\n\nInclude 3-4 paragraphs of informative content\n\nEnd with a question to encourage engagement\n\nInclude 4-6 relevant hashtags\n\nUse appropriate emojis in between\n\nImportant formatting requirements:\n\nFormat all paragraphs with proper newline characters (\\n\\n) between them\n\nEnsure the text is properly escaped for JSON\n\nDo not use double quote (\") in response or any special character\n\nDo not put asterisk\n\nKeep the overall length appropriate for LinkedIn (under 3000 characters)\n\nNow, create a LinkedIn post based on the following title:\n{{ $('Linkedin-Post-Topic').item.json['Linkedin Post Title'] }}",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.9
    },
    {
      "id": "72e79e7b-1e76-44f8-8893-bac589a46004",
      "name": "格式化内容",
      "type": "n8n-nodes-base.code",
      "position": [
        -844,
        -210
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\n\n\n\n\n//const postData = $('Limit').first().json.ID;\n\n// Store this value in a workflow variable that can be accessed by other nodes\n//$variables.PostId = postData;\n\n//$workflow.setContext('postContent', postData);\n\n// Also store it in a more persistent variable if needed across workflows\n//$variables.set('postData', postData);\n\n\n\n const updatedItems = items.map((item) => {\n  item.json.output.post = JSON.stringify(item.json.output.post);\n  return item;\n});\nreturn updatedItems; \n\n\n"
      },
      "typeVersion": 2
    },
    {
      "id": "50b46b9f-8250-47e4-bba5-379bfeb441ee",
      "name": "Linkedin-用户详情",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -624,
        -210
      ],
      "parameters": {
        "url": "https://api.linkedin.com/v2/userinfo",
        "options": {
          "response": {
            "response": {}
          }
        },
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {}
          ]
        },
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "ZIlbEIFkMIFXYBav",
          "name": "Header Auth account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "63ea9ba8-4c38-4fee-b6eb-e382b3d90bdb",
      "name": "Linkedin-帖子",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -404,
        -210
      ],
      "parameters": {
        "url": "https://api.linkedin.com/v2/ugcPosts",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"author\": \"urn:li:person:{{ $('Linkedin-User-Detail').item.json.sub }}\",\n  \"lifecycleState\": \"PUBLISHED\",\n  \"specificContent\": {\n    \"com.linkedin.ugc.ShareContent\": {\n      \"shareCommentary\": {\n        \"text\": {{ $('Format-Content').item.json.output.post }}\n      },\n      \"shareMediaCategory\": \"NONE\"\n      }\n  },\n  \"visibility\": {\n    \"com.linkedin.ugc.MemberNetworkVisibility\": \"PUBLIC\"\n  }\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "ZIlbEIFkMIFXYBav",
          "name": "Header Auth account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "cf99dfae-35b1-48d1-a369-3ba9dd7ed974",
      "name": "获取群组ID",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -184,
        -210
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1240468053,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/147NIoP4NAZtmXdjciHyKdOWqpPvJ9ifoS8P6HJxikY8/edit#gid=1240468053",
          "cachedResultName": "Groups"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "147NIoP4NAZtmXdjciHyKdOWqpPvJ9ifoS8P6HJxikY8",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/147NIoP4NAZtmXdjciHyKdOWqpPvJ9ifoS8P6HJxikY8/edit?usp=drivesdk",
          "cachedResultName": "Linkedin Post"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "kV7R8M5Wq888iCSq",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "9d23f626-39ea-47fd-ac54-90520e96700d",
      "name": "逐个选取",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        36,
        -210
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "165b45ec-f13e-45f5-b64e-0eb9b93af68f",
      "name": "Linkedin群组发帖",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        256,
        -160
      ],
      "parameters": {
        "url": "https://api.linkedin.com/v2/ugcPosts",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"author\": \"urn:li:person:{{ $('Linkedin-User-Detail').item.json.sub }}\",\n  \"containerEntity\": \"urn:li:group:{{ $json.GroupIds }}\",\n  \"lifecycleState\": \"PUBLISHED\",\n  \"specificContent\": {\n    \"com.linkedin.ugc.ShareContent\": {\n      \"shareCommentary\": {\n        \"text\": {{ $('Format-Content').item.json.output.post }}\n      },\n      \"shareMediaCategory\": \"NONE\"\n    }\n  },\n  \"visibility\": {\n    \"com.linkedin.ugc.MemberNetworkVisibility\": \"PUBLIC\"\n  }\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "xZXXbTFNsITteRvV",
          "name": "Header Auth account 2"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "ad781a4b-9905-4028-984c-8949f6f10136",
      "name": "更新状态",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        256,
        -360
      ],
      "parameters": {
        "columns": {
          "value": {
            "ID": "={{ $('Limit').item.json.ID }}",
            "Status": "Posted"
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Linkedin Post Title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Linkedin Post Title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Image Path",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Image Path",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/147NIoP4NAZtmXdjciHyKdOWqpPvJ9ifoS8P6HJxikY8/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "147NIoP4NAZtmXdjciHyKdOWqpPvJ9ifoS8P6HJxikY8",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/147NIoP4NAZtmXdjciHyKdOWqpPvJ9ifoS8P6HJxikY8/edit?usp=drivesdk",
          "cachedResultName": "Linkedin Post"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "kV7R8M5Wq888iCSq",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "ea122424-0676-4423-985d-b72b0841837c",
  "connections": {
    "Limit": {
      "main": [
        [
          {
            "node": "Linedin-Post-Creator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pick 1 by 1": {
      "main": [
        [
          {
            "node": "Update-Status",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Post-Linkedin-Groups",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get-Group-id": {
      "main": [
        [
          {
            "node": "Pick 1 by 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Linkedin-post": {
      "main": [
        [
          {
            "node": "Get-Group-id",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format-Content": {
      "main": [
        [
          {
            "node": "Linkedin-User-Detail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate-Status": {
      "main": [
        [
          {
            "node": "Limit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Linedin-Post-Creator",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Linkedin-Post-Topic": {
      "main": [
        [
          {
            "node": "Validate-Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Linedin-Post-Creator": {
      "main": [
        [
          {
            "node": "Format-Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Linkedin-User-Detail": {
      "main": [
        [
          {
            "node": "Linkedin-post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post-Linkedin-Groups": {
      "main": [
        [
          {
            "node": "Pick 1 by 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Linedin-Post-Creator",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 人工智能, 营销

需要付费吗?

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

工作流信息
难度等级
中级
节点数量13
分类2
节点类型10
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Amit Mehta

Amit Mehta

@amitswba

I'm a workflow automation expert with 15+ years in IT industry. I build smart, scalable n8n workflows for AI automation, marketing, CRM, and SaaS integrations. My focus is on simplifying business processes with tools like OpenAI, WhatsApp, Gmail, and Airtable. I help teams and solopreneurs automate smarter, reduce manual tasks, and grow faster—one workflow at a time.

外部链接
在 n8n.io 查看

分享此工作流