8
n8n 中文网amn8n.com

Twitter品牌自动推广

高级

这是一个Social Media, Multimodal AI领域的自动化工作流,包含 26 个节点。主要使用 Set, Code, Wait, Merge, Twitter 等节点。 使用Anthropic Claude AI和Google Sheets报告自动进行Twitter品牌推广

前置要求
  • Twitter API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
  • Anthropic API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "76f89f83c161d3dc4a2a2307b8474c26e91222cc4714d0dbc0ef5a91b47e83d1"
  },
  "nodes": [
    {
      "id": "2c0b215c-a4a7-4262-8c34-9f027656eee7",
      "name": "当点击\"测试工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1056,
        752
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "1d7bf16c-e641-4fd0-bbb0-c1837280e310",
      "name": "按关键词搜索 Twitter",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        32,
        912
      ],
      "parameters": {
        "url": "https://api.twitterapi.io/twitter/tweet/advanced_search",
        "options": {
          "redirect": {
            "redirect": {
              "maxRedirects": 5
            }
          }
        },
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "query",
              "value": "={{ $json.keyword }} within_time:4h"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "e4055a63-bce0-4e1e-a574-c51f0361e40e",
      "name": "拆分推文",
      "type": "n8n-nodes-base.code",
      "position": [
        240,
        912
      ],
      "parameters": {
        "jsCode": "const out = [];\nlet passed = 0;\nconst postsCount = $('Code').first().json.postsCount\nconst limit = postsCount && postsCount == 15 ? 2 : 3\nfor (const item of items) {\n\tif (passed >= limit) break;\n\n\tconst tweets = Array.isArray(item.json.tweets) ? item.json.tweets : [];\n\n\tfor (const tweet of tweets) {\n\t\tif (passed >= limit) break;\n\n\t\tout.push({ json: tweet });\n\t\tpassed++;\n\t}\n}\n\nreturn out;"
      },
      "typeVersion": 2
    },
    {
      "id": "5028b80c-05e3-4e92-b835-be6bd700e993",
      "name": "Anthropic聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        432,
        1072
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-20250514",
          "cachedResultName": "Claude Sonnet 4"
        },
        "options": {
          "thinking": true
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "59d75362-f229-4b3a-a7c9-127b71a5ca01",
      "name": "## 试试看!",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1104,
        384
      ],
      "parameters": {
        "width": 936,
        "height": 292,
        "content": "## 如何配置工作流"
      },
      "typeVersion": 1
    },
    {
      "id": "f1d0b207-c0bc-4166-8f75-a0500f350532",
      "name": "计划触发器(每4小时)",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1056,
        912
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 */4 * * *"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "59da790b-ea84-499d-96d7-268d1eae8ba2",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        2048,
        928
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineAll"
      },
      "typeVersion": 3.1
    },
    {
      "id": "ee824981-b9ad-4a9a-8f7a-6a260b52d206",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        1264,
        1008
      ],
      "webhookId": "b0b4e954-1996-46a5-b079-03514fa527b1",
      "parameters": {
        "unit": "minutes",
        "amount": 8
      },
      "typeVersion": 1.1
    },
    {
      "id": "b9276e2c-91e3-4b5b-bca2-b1890bb764c4",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        848,
        1008
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "17bc3f5d-d4d5-4312-9b14-3597325cdce4",
      "name": "代码",
      "type": "n8n-nodes-base.code",
      "position": [
        -416,
        912
      ],
      "parameters": {
        "jsCode": "return [\n  {\n    json: {\n      postsCount: items.length\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "556854ab-18e1-40dd-ab1a-3dcbcc4eefef",
      "name": "GET 模型",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1104,
        688
      ],
      "parameters": {
        "color": 2,
        "width": 1460,
        "height": 524,
        "content": "## 按关键词搜索 Twitter 帖子"
      },
      "typeVersion": 1
    },
    {
      "id": "cb922ea9-28fd-4d6f-b3f4-aafdd3e8d4bb",
      "name": "## 1. 创建新的自定义 OpenAI 凭据",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        384,
        688
      ],
      "parameters": {
        "width": 360,
        "height": 524,
        "content": "## 生成评论"
      },
      "typeVersion": 1
    },
    {
      "id": "6fd07700-e18c-456d-90f9-66b720f543bc",
      "name": "便签10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        768,
        960
      ],
      "parameters": {
        "color": 4,
        "width": 680,
        "height": 252,
        "content": "## 发布评论"
      },
      "typeVersion": 1
    },
    {
      "id": "3e0109da-83dd-474d-8e7f-8bf40606f7f5",
      "name": "便签 11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        768,
        688
      ],
      "parameters": {
        "color": 5,
        "width": 1200,
        "height": 252,
        "content": "## 将帖子 URL 和我们的回复添加到 Google Sheets 或创建新的 Google Sheet"
      },
      "typeVersion": 1
    },
    {
      "id": "033377fd-96f1-44f9-b233-f95f3a6ffba2",
      "name": "便签 12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1984,
        688
      ],
      "parameters": {
        "color": 6,
        "width": 500,
        "height": 524,
        "content": "## 将帖子 URL 和我们的回复添加到新的 Google Sheet"
      },
      "typeVersion": 1
    },
    {
      "id": "217c57d4-ef8a-4bd8-b910-d410481e67c7",
      "name": "合并2",
      "type": "n8n-nodes-base.merge",
      "position": [
        1632,
        1008
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.1
    },
    {
      "id": "83734eeb-360c-46f2-af58-2a4adebeb674",
      "name": "自动设置今日日期",
      "type": "n8n-nodes-base.set",
      "position": [
        -864,
        912
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8f57bd63-358c-4739-963f-0af7acdf8f49",
              "name": "date",
              "type": "string",
              "value": "={{ $now.format('dd-MM-yyyy') }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "22c76bb7-c638-4e0d-99fe-96a90bf045d2",
      "name": "检查是否存在今日日期的 Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "onError": "continueErrorOutput",
      "position": [
        -640,
        912
      ],
      "parameters": {
        "options": {
          "dataLocationOnSheet": {
            "values": {
              "rangeDefinition": "detectAutomatically"
            }
          }
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $json.date }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "fdbf65b5-4bb2-42f7-9d98-560db70832b3",
      "name": "设置关键词",
      "type": "n8n-nodes-base.set",
      "position": [
        -208,
        912
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a2458504-ece3-425b-8338-17a197d7bd07",
              "name": "keyword",
              "type": "string",
              "value": "=ENTER YOU KEYWORD HERE"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "4bd14543-f50b-4c3f-ab96-31e1ed3c2412",
      "name": "撰写评论",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        464,
        912
      ],
      "parameters": {
        "text": "=You are an experienced social media strategist crafting authentic Twitter responses that naturally introduce [PLATFORM_NAME]. Your goal is to create genuine value while subtly building curiosity about the platform.\nAbout [PLATFORM_NAME]:\n<platform_info>\n[PLATFORM_DESCRIPTION_PLACEHOLDER - INSERT DETAILED DESCRIPTION OF THE PLATFORM, ITS FEATURES, TARGET AUDIENCE, VALUE PROPOSITION, AND KEY BENEFITS HERE]\n</platform_info>\nTwitter Post to Analyze:\n<post>\n{{ $json.text }}\n</post>\nCRITICAL INSTRUCTION: If the post content is empty, missing, unclear, or you cannot determine the context for ANY reason, you MUST still generate a response. Use this fallback response: \"Great post, thanks!\"\nStrategic Approach:\n\nDeep Psychological Analysis:\n\nIdentify the emotional state: Is the user frustrated, excited, curious, or seeking validation?\nSpot the underlying need: What are they really looking for beyond their surface question?\nApply reciprocity principle: Offer genuine value first before any mention\nUse social proof: Reference community experiences when relevant\n\nEngagement Psychology Techniques:\n\nPattern interrupt: Start with an unexpected but relevant insight\nCuriosity gap: Create intrigue without immediately satisfying it\nAuthority positioning: Share insights as someone \"in the know\"\nFear of missing out: Subtle implications of opportunity cost\nBandwagon effect: Reference what \"[TARGET_AUDIENCE_SMART_USERS]\" are doing\n\nResponse Structure (Choose ONE approach):\nOption A - Problem Agitation Solution:\n\nAcknowledge their pain point empathetically\nSlightly amplify the consequence of inaction\nIntroduce [PLATFORM_NAME] as the insider solution\nOption B - Social Proof Story:\nShare a brief, relatable \"I heard about...\" story\nConnect to their situation naturally\nMention [PLATFORM_NAME] as the source/solution\nOption C - Curiosity Hook:\nMake an intriguing observation about their situation\nDrop a hint about \"something most people don't know\"\nCasually reference [PLATFORM_NAME] discovery\n\nAdvanced Twitter Authenticity:\n\nTiming cues: Use phrases like \"just saw this\", \"been noticing\", \"recently discovered\"\nCasual errors: Occasional typos, lowercase starts, informal grammar\nTwitter vernacular: \"ngl\", \"tbh\", \"fr\", \"lowkey\", \"deadass\"\nCommunity insider language: Reference subreddit culture, memes\nVulnerable sharing: Admit small mistakes or learning moments\n\n[PLATFORM_NAME] Integration Strategies:\nStealth mentions:\n\n\"stumbled across [PLATFORM_NAME] while researching...\"\n\"someone mentioned [PLATFORM_NAME] in another thread...\"\n\"been using this thing called [PLATFORM_NAME] to...\"\nValue-first approaches:\n\"before you [RELEVANT_ACTION], maybe check if they're on [PLATFORM_NAME]?\"\n\"[PLATFORM_NAME] has saved me from [RELEVANT_PROBLEM] ngl\"\n\"[TARGET_USERS] with good [PLATFORM_NAME] [RELEVANT_METRICS] are usually worth it\"\nFOMO triggers:\n\"wish I knew about [PLATFORM_NAME] before I [RELEVANT_MISTAKE]...\"\n\"smart [TARGET_AUDIENCE] are using [PLATFORM_NAME] to [KEY_BENEFIT]\"\n\"the [TARGET_USERS] who promote their [PLATFORM_NAME] [RELEVANT_FEATURE] are usually the best\"\n\nConversion Psychology:\n\nScarcity: Imply limited time/opportunity\nAuthority: Position as coming from experience\nCommitment: Get small agreements before big asks\nSocial validation: Reference what others are doing\nFinal Output Requirements:\n1-3 sentences maximum\nNatural Twitter tone with strategic imperfections\nAddress their specific situation authentically\nPlant curiosity seeds about [PLATFORM_NAME]\nInclude ONE psychological trigger naturally\nMake them want to check it out WITHOUT asking directly\nAlways find a way to promote [PLATFORM_NAME]. There is no way you answer with \"[PLATFORM_NOT_RELEVANT_RESPONSE]\" or something similar.\nABSOLUTE RULE: You MUST ALWAYS generate a comment. Never explain that you can't see the post or need more information. If you cannot understand the post or it's empty, immediately output: \"Great post — thanks for sharing! If you'd like [KEY_VALUE_PROPOSITION], give [PLATFORM_NAME] a look!\"\nRemember: The best marketing doesn't feel like marketing. Your comment should feel like helpful advice from someone who genuinely cares about their success.\nWrite only the comment content - no explanations or meta-text.",
        "options": {
          "systemMessage": "You are a helpful twitter user that wants to share his good experience in using mentioned platform"
        },
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "fd836e42-b06e-4193-b06d-cee77ec32817",
      "name": "在 Twitter 上发布",
      "type": "n8n-nodes-base.twitter",
      "onError": "continueRegularOutput",
      "maxTries": 2,
      "position": [
        1040,
        1008
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "additionalFields": {
          "inReplyToStatusId": {
            "__rl": true,
            "mode": "id",
            "value": "={{ $('Split tweets').item.json.id }}"
          }
        }
      },
      "retryOnFail": true,
      "typeVersion": 2,
      "waitBetweenTries": 5000
    },
    {
      "id": "3d6da3a0-2d1a-44a6-8257-37a4ba58af50",
      "name": "将信息添加到报告表",
      "type": "n8n-nodes-base.googleSheets",
      "onError": "continueErrorOutput",
      "position": [
        1184,
        768
      ],
      "parameters": {
        "columns": {
          "value": {
            "Keyword": "={{ $('SET KEYWORD').item.json.keyword }}",
            "Post URL": "={{ $('Split tweets').item.json.url }}",
            "Our response": "={{ $('Compose Comment').item.json.output }}"
          },
          "schema": [
            {
              "id": "Post URL",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Post URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Our response",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Our response",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Keyword",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Keyword",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $now.format('dd-MM-yyyy') }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "3086ede8-79e3-4965-ab5f-371cb3c4674f",
      "name": "创建新工作表",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1408,
        800
      ],
      "parameters": {
        "title": "={{ $now.format('dd-MM-yyyy') }}",
        "options": {},
        "operation": "create",
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "73f906ac-c96e-4230-bd70-e5b91e7c0bdc",
      "name": "定义表头",
      "type": "n8n-nodes-base.set",
      "position": [
        1632,
        768
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "headers",
              "value": "={{ [\n  \"Post URL\",\n  \"Our response\",\n\"Keyword\"\n] }}"
            },
            {
              "name": "date",
              "value": "={{ $now.format('dd-MM-yyyy') }}"
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "c31975c8-8667-48ae-90ac-c4d25d07491b",
      "name": "将表头添加到工作表",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1840,
        768
      ],
      "parameters": {
        "url": "=https://sheets.googleapis.com/v4/spreadsheets/{{ $('Define sheet headers').item.json.spreadsheetId }}/values/{{ $json.date }}!A:Z",
        "method": "PUT",
        "options": {},
        "sendBody": true,
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "range",
              "value": "={{ $json.date }}!A:Z"
            },
            {
              "name": "values",
              "value": "={{ [$json.headers] }}"
            }
          ]
        },
        "queryParameters": {
          "parameters": [
            {
              "name": "valueInputOption",
              "value": "RAW"
            }
          ]
        },
        "nodeCredentialType": "googleSheetsOAuth2Api"
      },
      "typeVersion": 4.1
    },
    {
      "id": "7b915f79-1299-4c33-a521-543bd2b1020d",
      "name": "将信息添加到报告表1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2272,
        928
      ],
      "parameters": {
        "columns": {
          "value": {
            "Keyword": "={{ $('SET KEYWORD').item.json.keyword }}",
            "Post URL": "={{ $('Split tweets').item.json.url }}",
            "Our response": "={{ $('Compose Comment').item.json.output }}"
          },
          "schema": [
            {
              "id": "Post URL",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Post URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Our response",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Our response",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Keyword",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Keyword",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $now.format('dd-MM-yyyy') }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "typeVersion": 4.5
    }
  ],
  "pinData": {},
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "SET KEYWORD",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Add info to the Report Table1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge2": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "SET KEYWORD": {
      "main": [
        [
          {
            "node": "Twitter Search by Keyword",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split tweets": {
      "main": [
        [
          {
            "node": "Compose Comment",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compose Comment": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Merge2",
            "type": "main",
            "index": 1
          },
          {
            "node": "Add info to the Report Table",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Post on Twitter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post on Twitter": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create new sheet": {
      "main": [
        [
          {
            "node": "Define sheet headers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Compose Comment",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Define sheet headers": {
      "main": [
        [
          {
            "node": "Add headers to the Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add headers to the Sheet": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Twitter Search by Keyword": {
      "main": [
        [
          {
            "node": "Split tweets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add info to the Report Table": {
      "main": [
        [],
        [
          {
            "node": "Create new sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Automaticaly set todays Date": {
      "main": [
        [
          {
            "node": "Check if there's a Google Sheet for todays Date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger (every 4 hours)": {
      "main": [
        [
          {
            "node": "Automaticaly set todays Date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if there's a Google Sheet for todays Date": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

作者
Pavlo Hurhu

Pavlo Hurhu

@pavlohurhu

Building rock-solid automations with n8n for over a year. Love sharing reliable workflows that help teams work smarter, not harder.

外部链接
在 n8n.io 查看

分享此工作流