使用AI代理与Gemini Chat API生成并发布LinkedIn内容

高级

这是一个Multimodal AI领域的自动化工作流,包含 43 个节点。主要使用 Set、Code、Gmail、Switch、LinkedIn 等节点。 LinkedIn内容机器:通过Gemini AI生成邮件审批的帖子

前置要求
  • Google 账号和 Gmail API 凭证
  • LinkedIn API 凭证
  • Google Sheets API 凭证
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "fDLwldlY6FV3fqJ2",
  "meta": {
    "instanceId": "cc015731fc495809b886aea182b15bbd667eb8429470d9c57541b0221b87b7e0",
    "templateCredsSetupCompleted": true
  },
  "name": "使用 AI 代理与 Gemini Chat API 生成并发布 LinkedIn 内容",
  "tags": [],
  "nodes": [
    {
      "id": "d24cd7a9-52b3-4cde-8323-748f4a474e9f",
      "name": "当点击“执行工作流”时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -528,
        -64
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "9d8dc5b0-603a-484a-b710-0484141017ec",
      "name": "编辑字段",
      "type": "n8n-nodes-base.set",
      "position": [
        -304,
        -64
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "baaa3fc3-f510-4af1-80ac-7b46619de020",
              "name": "niche",
              "type": "string",
              "value": "startup founders in SaaS"
            },
            {
              "id": "287ddc20-8032-4fc4-8913-ca52fbb58d29",
              "name": "audience",
              "type": "string",
              "value": "growth-focused professionals"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d7740a8c-0cf3-4bdc-84c9-4e5261ace324",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -80,
        -64
      ],
      "parameters": {
        "text": "=You are a content strategist for LinkedIn.\nGiven a niche and audience, return 10 scroll-stopping post ideas as compact titles.\nOutput STRICT JSON:\n{\n  \"ideas\": [\n    {\"id\": 1, \"title\": \"...\"},\n    ...\n    {\"id\": 10, \"title\": \"...\"}\n  ]\n}\nNiche: {{$json.niche}}\nAudience: {{$json.audience}}\n",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "80d63523-f0e3-4253-8d66-1de45233dfbe",
      "name": "Google Gemini 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -8,
        160
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "id": "FfoNPWQzVaqAowCG",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "be593fa2-f68c-461d-994a-d5b7274c3a6a",
      "name": "代码",
      "type": "n8n-nodes-base.code",
      "position": [
        272,
        -64
      ],
      "parameters": {
        "jsCode": "// 1) Get raw AI output from the previous node\nlet raw = $input.first().json.output || $json.data || \"\";\n\n// 2) Remove ```json fences if present\nraw = raw.replace(/```json/i, \"\").replace(/```/g, \"\").trim();\n\n// 3) Parse\nlet data;\ntry { data = JSON.parse(raw); }\ncatch (e) { throw new Error(\"Gemini did not return valid JSON:\\n\" + raw); }\n\nconst ideas = data.ideas || [];\n\n// 4) Create correlationId for this email thread/session\nconst correlationId = Date.now().toString() + '-' + Math.random().toString(36).slice(2,8);\n\n// 5) Build a nice email body\nlet body = `Here are 10 LinkedIn post ideas for “$('Edit Fields').first().json.audience” in “$('Edit Fields').first().json.niche”:\\n\\n`;\nideas.forEach(i => { body += `${i.id}. ${i.title}\\n`; });\nbody += `\\nReply with the number (1–10) to draft posts.\\n`;\n\n// 6) Return\nreturn [{\n  correlationId,\n  niche: $('Edit Fields').first().json.niche,\n  audience: $('Edit Fields').first().json.audience,\n  ideas,\n  emailBody: body\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "db32c86a-f3d3-4257-80cc-1d9c45f2d9df",
      "name": "发送消息",
      "type": "n8n-nodes-base.gmail",
      "position": [
        720,
        -64
      ],
      "webhookId": "b2d6878b-8142-4621-bc13-36dc9ab30273",
      "parameters": {
        "sendTo": "yourmail@gmail.com ",
        "message": "={{ $('Code').item.json.emailBody }}",
        "options": {},
        "subject": "=Your 10 LinkedIn Ideas [CID: {{ $json['correlationId '] }}]"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "UGcoN71TRNANpnvK",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "eeafee6c-8258-48d7-99f6-7cd80b1c95bf",
      "name": "Gmail 触发器",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -528,
        516
      ],
      "parameters": {
        "filters": {
          "q": "to:me subject:\"[CID:\" is:inbox -category:promotions",
          "sender": "yourmail@gmail.com ",
          "includeSpamTrash": false
        },
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "UGcoN71TRNANpnvK",
          "name": "Gmail account"
        }
      },
      "executeOnce": true,
      "typeVersion": 1.3
    },
    {
      "id": "812e4f0c-4d66-4fba-a7dc-882504ac3cd5",
      "name": "代码1",
      "type": "n8n-nodes-base.code",
      "position": [
        -304,
        516
      ],
      "parameters": {
        "jsCode": "// Pull a plain text we can regex against (snippet is usually fine)\nconst text = ($input.first().json.snippet || '').trim();\n\n// First number in the reply\nconst numMatch = text.match(/\\d+/);\nconst selectedNumber = numMatch ? Number(numMatch[0]) : null;\n\n// Extract correlationId from Subject header\nlet subject = $input.first().json.Subject\nconst cidMatch = subject.match(/\\[CID:\\s*([^\\]]+)\\]/i);\nconst correlationId = cidMatch ? cidMatch[1] : null;\n\n// Who replied (optional, can be useful)\nlet from = '';\nif ($json.payload && $json.payload.headers) {\n  const f = $json.payload.headers.find(h => h.name === 'From');\n  from = f ? f.value : '';\n}\n\nif (!correlationId || !selectedNumber) {\n  return [{ kind: 'unknown', reason: 'Missing CID or number', subject, text }];\n}\n\nreturn [{\n  kind: 'numberReply',\n  selectedNumber,\n  correlationId,\n  from\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "fdcd4332-9481-48c9-98a0-00b9aa2f6d85",
      "name": "代码2",
      "type": "n8n-nodes-base.code",
      "position": [
        464,
        384
      ],
      "parameters": {
        "jsCode": "// Parse ideas into array\nconst ideas = JSON.parse($input.first().json.ideas || \"[]\");\n\n// Convert selected number to string because ids are strings in your JSON\nconst selectedNumber = $('Code1').first().json.selectedNumber;\n\n// Find chosen idea\nconst chosen = ideas.find(i => i.id === selectedNumber);\n\nif (!chosen) {\n  return [{\n    error: true,\n    msg: 'Idea not found',\n    selectedNumber\n  }];\n}\n\nreturn [{\n  correlationId: $input.first().json['correlationId '],\n  selectedTopic: chosen.title,\n  niche: $input.first().json.niche,\n  audience: $input.first().json.audience\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "d809b62b-d5d9-4d87-8961-6be7ee9b2ae8",
      "name": "AI Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        704,
        272
      ],
      "parameters": {
        "text": "=Create 3 LinkedIn post drafts about the topic below, tailored to the audience.\nLength: 120–200 words each, plain text. Avoid emojis unless natural.\nOutput strict JSON:\n{\n  \"drafts\": [\n    {\"id\": 1, \"text\": \"...\"},\n    {\"id\": 2, \"text\": \"...\"},\n    {\"id\": 3, \"text\": \"...\"}\n  ]\n}\nTopic: {{$json.selectedTopic}}\nAudience: {{$json.audience}}\nNiche: {{$json.niche}}\nTone: insightful, practical, founder-friendly\n",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "2594ad03-fcb3-4ac8-b707-663cac6fb1b9",
      "name": "Google Gemini聊天模型1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        768,
        480
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "id": "FfoNPWQzVaqAowCG",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "aee41c79-9bce-4756-8603-15406165f11b",
      "name": "在表格中追加行",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        496,
        -64
      ],
      "parameters": {
        "columns": {
          "value": {
            "ideas": "={{ $json.ideas }}",
            "niche": "={{ $json.niche }}",
            "stage": "=\"ideas\"",
            "audience": "={{ $json.audience }}",
            "correlationId ": "={{ $json.correlationId }}"
          },
          "schema": [
            {
              "id": "correlationId ",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "correlationId ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "stage",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "stage",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "niche",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "niche",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "audience",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "audience",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ideas",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ideas",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "selectedTopic",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "selectedTopic",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "drafts",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "drafts",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "linkedinUrn",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "linkedinUrn",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "correlationId"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1O0ewqwJerpjv6h8Zq5jrA4NC-crh4CVcH1uT2PHuUQg",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/",
          "cachedResultName": "Linkedin Post Idea"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "pToMN52MhgPTizJB",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "4a3db0b9-20c7-423e-b0e3-90d9249b63c9",
      "name": "Google Calendar MCP",
      "type": "n8n-nodes-base.switch",
      "position": [
        144,
        500
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Drafts Path",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "a7824eea-4a1c-4e56-abfb-7b01f2195d76",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.stage }}",
                    "rightValue": "\"ideas\""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Publish Path",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "9fcf7470-47bb-4ec6-bf94-dd154f4c5220",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.stage }}",
                    "rightValue": "\"drafts\""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "END",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "c92dcf46-6b16-49d2-b4a8-9612c8615a42",
                    "operator": {
                      "type": "string",
                      "operation": "empty",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.stage }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "6f8f75a6-2226-412f-9f2b-694f7cde6e10",
      "name": "代码3",
      "type": "n8n-nodes-base.code",
      "position": [
        1056,
        272
      ],
      "parameters": {
        "jsCode": "let raw = $input.first().json.output || $json.data || \"\";\nraw = raw.replace(/```json/i, \"\").replace(/```/g, \"\").trim();\n\nlet data;\ntry { data = JSON.parse(raw); }\ncatch(e) { throw new Error(\"Gemini drafts JSON parse error:\\n\" + raw); }\n\nconst drafts = data.drafts || [];\nlet body = `Here are 3 drafts for:\\n“$('Code2').first().json.selectedTopic”\\n\\n`;\ndrafts.forEach(d => { body += `${d.id}. ${d.text}\\n\\n`; });\nbody += `Reply with 1, 2, or 3 to publish on LinkedIn.\\n`;\n\nreturn [{\n  correlationId: $('Code2').first().json.correlationId,\n  selectedTopic: $('Code2').first().json.selectedTopic,\n  drafts,\n  emailBody: body\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "6570f3c1-e3a8-4a27-a600-e0d101bb0f03",
      "name": "在表格中更新行",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1296,
        272
      ],
      "parameters": {
        "columns": {
          "value": {
            "stage": "\"drafts\"",
            "drafts": "={{ $json.drafts }}",
            "selectedTopic": "={{ $json.selectedTopic }}",
            "correlationId ": "={{ $json.correlationId }}"
          },
          "schema": [
            {
              "id": "correlationId ",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "correlationId ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "stage",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "stage",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "niche",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "niche",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "audience",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "audience",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ideas",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ideas",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "selectedTopic",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "selectedTopic",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "drafts",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "drafts",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "linkedinUrn",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "linkedinUrn",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "correlationId "
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1O0ewqwJerpjv6h8Zq5jrA4NC-crh4CVcH1uT2PHuUQg",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/k",
          "cachedResultName": "Linkedin Post Idea"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "pToMN52MhgPTizJB",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "eea1b34d-eb46-4ea6-b592-1143d11f7065",
      "name": "发送消息1",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1536,
        272
      ],
      "webhookId": "52a5c9a2-50c0-4bae-ae92-f779f993bf06",
      "parameters": {
        "sendTo": "yourmail@gmail.com",
        "message": "={{ $('Code3').item.json.emailBody }}",
        "options": {},
        "subject": "=Drafts for \"{{$json.selectedTopic}}\" [CID: {{ $json['correlationId '] }}]"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "UGcoN71TRNANpnvK",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "af15a85f-d54b-49d1-9225-c1a6bc34a30c",
      "name": "代码4",
      "type": "n8n-nodes-base.code",
      "position": [
        464,
        688
      ],
      "parameters": {
        "jsCode": "// Extract drafts from sheet row\nlet drafts = $input.first().json.drafts || [];\nif (typeof drafts === 'string') {\n  try {\n    drafts = JSON.parse(drafts);\n  } catch (e) {\n    return [{ error: true, msg: 'Failed to parse drafts JSON', raw: drafts }];\n  }\n}\n\n// Get selected number from earlier node\nconst idx = $item(0).$node[\"Code1\"].json.selectedNumber;\nconst selected = drafts.find(d => Number(d.id) === Number(idx));\n\nif (!selected) {\n  return [{\n    error: true,\n    msg: `Draft #${idx} not found`,\n    availableDrafts: drafts.map(d => d.id)\n  }];\n}\n\nreturn [{\n  correlationId: $json.correlationId,\n  selectedTopic: $json.selectedTopic,\n  finalPost: selected.text\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "d4da723f-bf55-4718-9e69-d928d1d871eb",
      "name": "创建帖子",
      "type": "n8n-nodes-base.linkedIn",
      "position": [
        752,
        688
      ],
      "parameters": {
        "text": "={{ $json.finalPost }}",
        "postAs": "organization",
        "organization": "79935287",
        "authentication": "communityManagement",
        "additionalFields": {}
      },
      "credentials": {
        "linkedInCommunityManagementOAuth2Api": {
          "id": "TXRpzuZrkSg5k9FL",
          "name": "LinkedIn Community Management account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9f09d25f-4e52-4a32-b819-3801cd48b46a",
      "name": "在 sheet1 中更新行",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        992,
        688
      ],
      "parameters": {
        "columns": {
          "value": {
            "stage": "Posted",
            "linkedinUrn": "={{ $json.urn }}",
            "correlationId ": "={{ $('Get row(s) in sheet').item.json['correlationId '] }}"
          },
          "schema": [
            {
              "id": "correlationId ",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "correlationId ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "stage",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "stage",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "niche",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "niche",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "audience",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "audience",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ideas",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ideas",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "selectedTopic",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "selectedTopic",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "drafts",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "drafts",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "linkedinUrn",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "linkedinUrn",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "correlationId "
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1O0ewqwJerpjv6h8Zq5jrA4NC-crh4CVcH1uT2PHuUQg",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/",
          "cachedResultName": "Linkedin Post Idea"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "pToMN52MhgPTizJB",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "b7d82533-a238-4bb3-8ee5-a024344031dc",
      "name": "发送消息2",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1216,
        688
      ],
      "webhookId": "c4837158-b2b7-4230-be5a-6acc21cd8836",
      "parameters": {
        "sendTo": "yourmailcurrent@gmail.com",
        "message": "=Published to LinkedIn ✅\n\nTopic:\n{{ $('Code4').item.json.selectedTopic }}\n\nPreview:\n{{($('Code4').item.json.finalPost).slice(0, 200) }}…\n",
        "options": {},
        "subject": "=Posted ✅ “{{ $('Code4').item.json.selectedTopic }}” [CID: {{ $json['correlationId '] }}]"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "UGcoN71TRNANpnvK",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "27456f83-4fab-47f3-b0da-967e0ceb578c",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1440,
        -288
      ],
      "parameters": {
        "width": 704,
        "height": 1360,
        "content": "将简单的邮件工作流转变为 **LinkedIn 内容机器**。生成帖子创意、起草完整帖子并自动发布到 LinkedIn —— 全部通过回复邮件控制。"
      },
      "typeVersion": 1
    },
    {
      "id": "fd24d63f-ff08-4bbb-ad21-ef373f050b00",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -616,
        -160
      ],
      "parameters": {
        "color": 4,
        "width": 272,
        "height": 256,
        "content": "### 1. 手动触发"
      },
      "typeVersion": 1
    },
    {
      "id": "bf456d49-6752-4a42-a0e0-728b42c091fe",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -368,
        -160
      ],
      "parameters": {
        "content": "### 2. 编辑字段(设置节点)"
      },
      "typeVersion": 1
    },
    {
      "id": "5fdf070e-5045-4178-ae6e-e97b5514711f",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        -256
      ],
      "parameters": {
        "color": 3,
        "width": 288,
        "height": 352,
        "content": "### 3. AI 代理(LangChain 代理)"
      },
      "typeVersion": 1
    },
    {
      "id": "a99ee1f8-19df-4f85-8f5e-7029b76b893d",
      "name": "便签说明4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -352,
        128
      ],
      "parameters": {
        "color": 3,
        "width": 352,
        "content": "### 4. Google Gemini 聊天模型"
      },
      "typeVersion": 1
    },
    {
      "id": "f0dde27d-4d91-4ecb-808f-974cc27b93b5",
      "name": "便签说明5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        -128
      ],
      "parameters": {
        "width": 224,
        "height": 224,
        "content": "### 5. 代码(解析 AI 输出)"
      },
      "typeVersion": 1
    },
    {
      "id": "6e382e0e-864c-4804-8e52-fe61ee75b813",
      "name": "便签 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        424,
        -192
      ],
      "parameters": {
        "color": 5,
        "height": 288,
        "content": "### 6. 在表格中追加行(Google Sheets)"
      },
      "typeVersion": 1
    },
    {
      "id": "f8163c49-3c9c-4587-8666-ec93ada62ce1",
      "name": "便签 7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        672,
        -240
      ],
      "parameters": {
        "color": 7,
        "height": 336,
        "content": "### 7. 发送消息(Gmail)"
      },
      "typeVersion": 1
    },
    {
      "id": "391c04c2-7832-4cd1-be7f-57b8d2783231",
      "name": "## 为什么选择 4o 模型?👆",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -600,
        324
      ],
      "parameters": {
        "color": 4,
        "height": 352,
        "content": "### 8. Gmail 触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "ba7c562d-6bc2-47c9-a4d1-0e26d2f0c04b",
      "name": "便签 9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -376,
        356
      ],
      "parameters": {
        "height": 320,
        "content": "### 9. 代码1(提取回复)"
      },
      "typeVersion": 1
    },
    {
      "id": "a86524e5-e4da-47ad-b2be-8f309d2860f3",
      "name": "获取表格中的行",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -80,
        516
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.correlationId }}",
              "lookupColumn": "correlationId "
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1O0ewqwJerpjv6h8Zq5jrA4NC-crh4CVcH1uT2PHuUQg/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1O0ewqwJerpjv6h8Zq5jrA4NC-crh4CVcH1uT2PHuUQg",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1O0ewqwJerpjv6h8Zq5jrA4NC-crh4CVcH1uT2PHuUQg/edit?usp=drivesdk",
          "cachedResultName": "Linkedin Post Idea"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "pToMN52MhgPTizJB",
          "name": "Google Sheets account"
        }
      },
      "executeOnce": true,
      "typeVersion": 4.7,
      "alwaysOutputData": true
    },
    {
      "id": "e22c031e-2559-4c29-af11-67fe606a259c",
      "name": "便签10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -128,
        356
      ],
      "parameters": {
        "color": 5,
        "width": 192,
        "height": 320,
        "content": "### 10. 在表格中获取行"
      },
      "typeVersion": 1
    },
    {
      "id": "686e770c-ea46-4b41-aca6-a705fa093dbf",
      "name": "便签11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        336
      ],
      "parameters": {
        "color": 6,
        "height": 464,
        "content": "### 11. 切换"
      },
      "typeVersion": 1
    },
    {
      "id": "62331774-9639-4eb2-a8bf-1fcf50971901",
      "name": "便签12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        368,
        256
      ],
      "parameters": {
        "content": "### 12. 代码2(匹配所选创意)"
      },
      "typeVersion": 1
    },
    {
      "id": "576bbe0f-f7fe-4de3-9fd7-fe19f7844e38",
      "name": "便签13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        656,
        128
      ],
      "parameters": {
        "color": 3,
        "width": 288,
        "height": 320,
        "content": "### 13. AI 代理1(草稿生成器)"
      },
      "typeVersion": 1
    },
    {
      "id": "9d83589b-207f-40ec-b74a-16506a070b98",
      "name": "便签 14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        864,
        464
      ],
      "parameters": {
        "color": 3,
        "width": 304,
        "height": 112,
        "content": "### 14. Google Gemini 聊天模型1"
      },
      "typeVersion": 1
    },
    {
      "id": "39933d7c-28dc-4d6e-88a4-7142174ba3fe",
      "name": "便签 15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        976,
        144
      ],
      "parameters": {
        "height": 256,
        "content": "### 15. 代码3(解析草稿)"
      },
      "typeVersion": 1
    },
    {
      "id": "796a69f9-2900-4f83-8d48-c254eeede8c3",
      "name": "便签16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1232,
        128
      ],
      "parameters": {
        "color": 5,
        "height": 288,
        "content": "### 16. 在表格中更新行"
      },
      "typeVersion": 1
    },
    {
      "id": "6d2bb7da-ea48-46f7-a684-29fb4da0bad4",
      "name": "便签17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1504,
        96
      ],
      "parameters": {
        "color": 7,
        "height": 320,
        "content": "### 17. 发送消息1(Gmail)"
      },
      "typeVersion": 1
    },
    {
      "id": "72eb365d-0a75-4568-bcc9-5c9e837a150c",
      "name": "便签18",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        384,
        560
      ],
      "parameters": {
        "content": "### 18. 代码4(匹配所选草稿)"
      },
      "typeVersion": 1
    },
    {
      "id": "2441751d-9a55-426d-995b-0c63313a41bc",
      "name": "便签19",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        656,
        624
      ],
      "parameters": {
        "color": 6,
        "content": "### 19. 创建帖子(LinkedIn)"
      },
      "typeVersion": 1
    },
    {
      "id": "13eedb37-8e92-4fad-994a-40948c2bccb5",
      "name": "便签20",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        912,
        608
      ],
      "parameters": {
        "color": 5,
        "height": 256,
        "content": "### 20. 在表格中更新行1"
      },
      "typeVersion": 1
    },
    {
      "id": "fd76390c-8832-4ba6-a8c2-44e8d7913dd4",
      "name": "便签21",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1168,
        592
      ],
      "parameters": {
        "color": 7,
        "height": 256,
        "content": "### 21. 发送消息2(Gmail)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "timezone": "Asia/Kolkata",
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": "fDLwldlY6FV3fqJ2",
    "executionOrder": "v1"
  },
  "versionId": "b50605e2-db09-447a-b131-1d982ed9c3ff",
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code2": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code3": {
      "main": [
        [
          {
            "node": "Update row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code4": {
      "main": [
        [
          {
            "node": "Create a post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Code2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Code4",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "Code3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create a post": {
      "main": [
        [
          {
            "node": "Update row in sheet1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message1": {
      "main": [
        []
      ]
    },
    "Append row in sheet": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update row in sheet": {
      "main": [
        [
          {
            "node": "Send a message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update row in sheet1": {
      "main": [
        [
          {
            "node": "Send a message2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

这是一个高级难度的工作流,适用于Multimodal AI等场景。适合高级用户,包含 16+ 个节点的复杂工作流

需要付费吗?

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

工作流信息
难度等级
高级
节点数量43
分类1
节点类型11
难度说明

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

作者
Parag Javale

Parag Javale

@pollar-beer

Tech driven creative who turns ideas into impact. I blend storytelling, product strategy, and automation whether it’s hooky audio promos, smart LMS platforms, or AI driven workflows. I help businesses grab attention, streamline ops, and scale fast. Big on data, experiments, and building digital solutions that actually work.

外部链接
在 n8n.io 上查看 →

分享此工作流