8
n8n 中文网amn8n.com

Twitter监控工作流

中级

这是一个Market Research, AI Summarization领域的自动化工作流,包含 15 个节点。主要使用 If, Set, Slack, Switch, HttpRequest 等节点。 使用OpenAI、Google表格和Slack提醒自动化Twitter情感分析

前置要求
  • Slack Bot Token 或 Webhook URL
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "GHDkm5yryfu6FoXN",
  "meta": {
    "instanceId": "fcb622cbd5234c565b9b78babeaf0ea2455df9d2aad0d1adff7c1ef99583e685",
    "templateCredsSetupCompleted": true
  },
  "name": "Twitter 监控工作流",
  "tags": [],
  "nodes": [
    {
      "id": "8fa04bf9-68e5-43b7-81f2-ee5f2355abd9",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -60,
        210
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "dec03e00-a5fa-44eb-b269-b486259ac1aa",
      "name": "OpenAI",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1380,
        -220
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "GPT-4O-MINI"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "={{ $('Set Field for Loop').item.json.tweet_text }}"
            },
            {
              "role": "system",
              "content": "=You are a professional Twitter social media user replying to the original poster (admin).\n\nAnalyze the sentiment of the tweet below. If the sentiment is positive, write a short, thoughtful reply **from a user's perspective**, directed to the person who posted it.\n\nThe reply should:\n- Show appreciation, agreement, or excitement\n- Be friendly, intelligent, and relevant to tech or AI fields\n- Use no emojis\n- Be under 160 characters\n- Address the original poster directly as a real person would\n\nTweet:\n\"\"\"\nuse a user prompt\n\"\"\""
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "ga54eHkT3k6225Zq",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "a6ebd6b7-29a4-4d02-ab90-5e74235485ea",
      "name": "结构化输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1020,
        180
      ],
      "parameters": {
        "jsonSchemaExample": "{\n\"category\": \"neutral\"\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "c725e544-b9c4-4b5f-9e48-3e4ca1e8aec1",
      "name": "获取帖子数据",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        160,
        -40
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.id }}",
              "lookupColumn": "ID"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1040262065,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1sOxYQtX-O6p35FCNSRsovKEHL4w4GsfF-ylMVcwpb_E/edit#gid=1040262065",
          "cachedResultName": "Twitter(hashtag)"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1sOxYQtX-O6p35FCNSRsovKEHL4w4GsfF-ylMVcwpb_E",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1sOxYQtX-O6p35FCNSRsovKEHL4w4GsfF-ylMVcwpb_E/edit?usp=drivesdk",
          "cachedResultName": "Google Map Scraper"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "cOspDa8h1hkwDLvX",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6,
      "alwaysOutputData": true
    },
    {
      "id": "1def5fb1-e928-4c9e-bb7a-4f1ea5658d46",
      "name": "情感分析师",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        740,
        -80
      ],
      "parameters": {
        "text": "={{ $('Loop Over Items').item.json.tweet_text }}",
        "options": {
          "systemMessage": "You are a helpful AI assistant.Perfectly analyze the sentiment of this tweet_text and tell me in one word it is Positive, Neutral, or Negative."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2
    },
    {
      "id": "bc3fdb44-6588-4607-8e22-27a9bdf9ce9c",
      "name": "根据分析结果切换",
      "type": "n8n-nodes-base.switch",
      "position": [
        1180,
        -40
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Positive",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "394765f1-3f6b-484c-88ac-6eb699acd292",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.category }}",
                    "rightValue": "Positive"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Nagative",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "d102e916-73dc-4774-81eb-7ca7e6e1033e",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.category }}",
                    "rightValue": "Negative"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Neutral",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "9e383471-7b1b-4311-9fab-92ce4db0301f",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.category }}",
                    "rightValue": "Neutral"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "ce1e35b7-df4a-4969-81ed-21d8967cc834",
      "name": "添加帖子数据",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1700,
        240
      ],
      "parameters": {
        "columns": {
          "value": {
            "ID": "={{ $('Set Field for Loop').item.json.id }}",
            "TweetUrl": "={{ $('Set Field for Loop').item.json.tweet_url }}",
            "TweetText": "={{ $('Set Field for Loop').item.json.tweet_text }}",
            "Post Reply": "={{ $json.message.content }}",
            "Sentiment ": "={{ $('Switch According Analyst').item.json.output.category }}"
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "TweetUrl",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "TweetUrl",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "TweetText",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "TweetText",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Sentiment ",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Sentiment ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Post Reply",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Post Reply",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1040262065,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1sOxYQtX-O6p35FCNSRsovKEHL4w4GsfF-ylMVcwpb_E/edit#gid=1040262065",
          "cachedResultName": "Twitter(hashtag)"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1sOxYQtX-O6p35FCNSRsovKEHL4w4GsfF-ylMVcwpb_E",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1sOxYQtX-O6p35FCNSRsovKEHL4w4GsfF-ylMVcwpb_E/edit?usp=drivesdk",
          "cachedResultName": "Google Map Scraper"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "cOspDa8h1hkwDLvX",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6,
      "alwaysOutputData": false
    },
    {
      "id": "0ac588c7-2612-482e-91c2-e2622840ec5e",
      "name": "由 Github 模型提供支持",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -940,
        220
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 6
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b84b9a8a-e13e-41bf-96d0-aeb36c13c4be",
      "name": "设置循环字段",
      "type": "n8n-nodes-base.set",
      "position": [
        -280,
        210
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "56262d1d-f624-4e77-a03f-a0f2230070a6",
              "name": "id",
              "type": "string",
              "value": "={{ $json.postId }}"
            },
            {
              "id": "a32fc77b-7378-4ac4-a0af-193ae7092ae3",
              "name": "tweet_url",
              "type": "string",
              "value": "={{ $json.postUrl }}"
            },
            {
              "id": "f744541d-80db-46c6-91ad-3747ebac2c49",
              "name": "tweet_text",
              "type": "string",
              "value": "={{ $json.postText }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "3e8a8b36-69c8-42dd-86c2-fdda0259184c",
      "name": "在 Slack 上发送负面帖子消息",
      "type": "n8n-nodes-base.slack",
      "position": [
        1440,
        -60
      ],
      "webhookId": "ea8f7d60-91af-4452-adfa-2e00cf80acc6",
      "parameters": {
        "text": "=Received a Negative retweet on {{ $('Check Duplicate').item.json.TweetUrl }}. Consider if a response or clarification is needed.",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C090F70N52M",
          "cachedResultName": "website-uptime"
        },
        "otherOptions": {
          "includeLinkToWorkflow": false
        },
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "id": "rURgzu95YUHybmaa",
          "name": "Slack account"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "31469921-4053-435f-9909-ab5a7eb85204",
      "name": "通过 Apify 请求 Twitter 帖子",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        -720,
        220
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/scraper_one~x-posts-search/run-sync?token=api_key",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n    \"query\": \"LaraconIn\",\n    \"resultsCount\": 5,\n    \"searchType\": \"latest\",\n    \"lang\":\"en\"\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.1
    },
    {
      "id": "10774b92-a390-43de-a7a5-62ce25587e3e",
      "name": "从 Apify 获取请求的帖子",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -500,
        200
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/scraper_one~x-posts-search/runs/last/dataset/items?token=api_key",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "31525bf2-922d-413e-bad7-9ea8b9099880",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -900,
        -460
      ],
      "parameters": {
        "width": 800,
        "height": 560,
        "content": "## 示例输出表格"
      },
      "typeVersion": 1
    },
    {
      "id": "29960d67-1378-49b3-9174-ac26aef71ad9",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        760,
        140
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "ga54eHkT3k6225Zq",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8bd4d3f7-9020-43c6-bf0e-788075c5ec6f",
      "name": "如果重复",
      "type": "n8n-nodes-base.if",
      "position": [
        380,
        -40
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "6f5c821d-8b4b-40ab-a025-1b7fcc42c78d",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.ID }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "09a99040-3fec-411f-a270-2f73092e0c8d",
  "connections": {
    "OpenAI": {
      "main": [
        [
          {
            "node": "Add Post Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Duplicate": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Sentiment Analyst",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Post Data": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Post Data": {
      "main": [
        [
          {
            "node": "If Duplicate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Get Post Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Request for Twitter Post via Apify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Sentiment Analyst",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Sentiment Analyst": {
      "main": [
        [
          {
            "node": "Switch According Analyst",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Field for Loop": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Sentiment Analyst",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Switch According Analyst": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send negative post message on slack",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Add Post Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Requested Post from Apify": {
      "main": [
        [
          {
            "node": "Set Field for Loop",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Request for Twitter Post via Apify": {
      "main": [
        [
          {
            "node": "Get Requested Post from Apify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send negative post message on slack": {
      "main": [
        [
          {
            "node": "Add Post Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 市场调研, AI 摘要总结

需要付费吗?

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

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

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

作者
InfyOm Technologies

InfyOm Technologies

@infyom

We are an AI Automation Agency focusing on various AI Automation Services like, workflow automation, shopify automation, chatbot developerment, custom ai agent development and more.

外部链接
在 n8n.io 查看

分享此工作流