8
n8n 中文网amn8n.com

YouTube观众评论分析器

高级

这是一个Market Research, AI Summarization领域的自动化工作流,包含 17 个节点。主要使用 If, SplitOut, HttpRequest, GoogleSheets, ManualTrigger 等节点。 使用Gemini AI分析YouTube评论情感并保存到Google Sheets

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
  • OpenAI API Key
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "IJ4YYLsaOiD1z9Oz",
  "meta": {
    "instanceId": "ed6d846a2fce1f660ede2e7da800724cca01dc3d0685524a3c917881b7cfcfe9",
    "templateCredsSetupCompleted": true
  },
  "name": "YouTube - 观众评论分析器",
  "tags": [
    {
      "id": "CEVEeZJa4qgPvdpK",
      "name": "youtube",
      "createdAt": "2025-05-27T02:29:43.874Z",
      "updatedAt": "2025-05-27T02:29:43.874Z"
    }
  ],
  "nodes": [
    {
      "id": "ecd26999-0115-4739-b02c-65801a35eb51",
      "name": "拆分输出",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        900,
        220
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "body.items"
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "1c93def0-47b9-498c-84bb-18b945cc5ecf",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1500,
        180
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "qULV9xA6eq3tfpye",
          "name": "OpenAi - nhu.le"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "40976cd9-49d0-44eb-9ef9-55d7a864df54",
      "name": "当点击\"测试工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -360,
        220
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "69c74c11-d4a5-4b27-9058-60ad46f9421c",
      "name": "HTTP 请求 - 获取评论",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        520,
        220
      ],
      "parameters": {
        "url": "https://www.googleapis.com/youtube/v3/commentThreads",
        "options": {
          "response": {
            "response": {
              "fullResponse": true,
              "responseFormat": "json"
            }
          },
          "pagination": {
            "pagination": {
              "parameters": {
                "parameters": [
                  {
                    "name": "pageToken",
                    "value": "={{ $response.body.nextPageToken }}"
                  }
                ]
              },
              "completeExpression": "={{ !$response.body.nextPageToken}}",
              "paginationCompleteWhen": "other"
            }
          }
        },
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "part",
              "value": "snippet"
            },
            {
              "name": "videoId",
              "value": "={{ $json.video_url.match(/(?:v=|\\/)([0-9A-Za-z_-]{11})/)[1] || ''}}"
            },
            {
              "name": "limit",
              "value": "100"
            }
          ]
        },
        "nodeCredentialType": "youTubeOAuth2Api"
      },
      "credentials": {
        "youTubeOAuth2Api": {
          "id": "KhD0GLQGWl8MtqCs",
          "name": "YouTube - toan.ngo"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "7148ceec-b9c2-41ab-9e23-092b28d7bdc4",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        320,
        220
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "40dba5d2-e175-443d-a417-45bdec5e84ec",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1180,
        -320
      ],
      "parameters": {
        "width": 660,
        "height": 1820,
        "content": "## [n8n 自动化] YouTube 评论分析器 - 立即试用!"
      },
      "typeVersion": 1
    },
    {
      "id": "44b7e7f9-dab4-41d2-b0fd-c985da58480c",
      "name": "Google Gemini 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1320,
        180
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "AlDwotqhFT4EfJXQ",
          "name": "Google Gemini(PaLM) Api - toan.ngo"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e4aef7cf-bb41-49b6-b73a-f065d0534dc3",
      "name": "检查视频 URL 是否不为空",
      "type": "n8n-nodes-base.if",
      "position": [
        100,
        220
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "92084960-e023-4cd6-a5c0-ddd43275cc33",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.video_url }}",
              "rightValue": "={{ $now.toISO() }}"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "cffd5351-827e-4d85-84dd-892ae135aa12",
      "name": "检查是否 - 成功响应",
      "type": "n8n-nodes-base.if",
      "position": [
        700,
        220
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "bce76f94-5904-4fdb-b172-adc1134855f9",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $json.statusCode }}",
              "rightValue": 200
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "445564ea-a3f1-45cb-b887-85bbcf43dd7c",
      "name": "检查是否 - 评论存在",
      "type": "n8n-nodes-base.if",
      "position": [
        1120,
        220
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e4d47098-097d-4fd7-9703-638858f9565a",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.snippet.videoId }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c4971a87-2a5e-428a-8e8f-b82afb4f403d",
      "name": "更新视频状态",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1720,
        460
      ],
      "parameters": {
        "columns": {
          "value": {
            "status": "Finished",
            "row_number": "={{ $('Get Video URLs').item.json.row_number }}",
            "last_fetched_time": "={{ $now.toISO().toString().slice(0, 19).replace('T', ' ') }}"
          },
          "schema": [
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "video_url",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "video_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "last_fetched_time",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "last_fetched_time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 426418282,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/18-3CmJPbC73MycmNiSWotdsyGBAAzqESf33vktwnYmM/edit#gid=426418282",
          "cachedResultName": "Video URLs"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "18-3CmJPbC73MycmNiSWotdsyGBAAzqESf33vktwnYmM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/18-3CmJPbC73MycmNiSWotdsyGBAAzqESf33vktwnYmM/edit?usp=drivesdk",
          "cachedResultName": "YouTube - Audience Feedback Sentiment Analyzer"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "pe6UD1A6MWIk2X91",
          "name": "Google Sheets - toan.ngo"
        }
      },
      "executeOnce": true,
      "typeVersion": 4.5
    },
    {
      "id": "9dffad3c-5940-4623-b6dc-b704a3866e53",
      "name": "获取视频 URL",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -140,
        220
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "=Ready",
              "lookupColumn": "status"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 426418282,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/18-3CmJPbC73MycmNiSWotdsyGBAAzqESf33vktwnYmM/edit#gid=426418282",
          "cachedResultName": "Video URLs"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "18-3CmJPbC73MycmNiSWotdsyGBAAzqESf33vktwnYmM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/18-3CmJPbC73MycmNiSWotdsyGBAAzqESf33vktwnYmM/edit?usp=drivesdk",
          "cachedResultName": "YouTube - Audience Feedback Sentiment Analyzer"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "pe6UD1A6MWIk2X91",
          "name": "Google Sheets - toan.ngo"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "6b1f966b-342a-4f37-80e4-179e207ec421",
      "name": "插入评论数据和分析",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1740,
        120
      ],
      "parameters": {
        "columns": {
          "value": {
            "likes": "={{ $json.snippet.topLevelComment.snippet.likeCount }}",
            "reply": "={{ $json.snippet.totalReplyCount }}",
            "comment": "={{ $json.snippet.topLevelComment.snippet.textOriginal }}",
            "sentiment": "={{ $json.sentimentAnalysis.category }}",
            "video_url": "=https://www.youtube.com/watch?v={{ $json.snippet.videoId }}",
            "comment_id": "={{ $json.snippet.topLevelComment.id }}",
            "author_name": "={{ $json.snippet.topLevelComment.snippet.authorDisplayName }}",
            "published_at": "={{ $json.snippet.topLevelComment.snippet.publishedAt.toString().slice(0, 19).replace('T', ' ') }}"
          },
          "schema": [
            {
              "id": "video_url",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "video_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "comment_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "comment_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "comment",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "comment",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "author_name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "author_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "likes",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "likes",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reply",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "reply",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "sentiment",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "sentiment",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "published_at",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "published_at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "comment_id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/18-3CmJPbC73MycmNiSWotdsyGBAAzqESf33vktwnYmM/edit#gid=0",
          "cachedResultName": "Results "
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "18-3CmJPbC73MycmNiSWotdsyGBAAzqESf33vktwnYmM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/18-3CmJPbC73MycmNiSWotdsyGBAAzqESf33vktwnYmM/edit?usp=drivesdk",
          "cachedResultName": "YouTube - Audience Feedback Sentiment Analyzer"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "pe6UD1A6MWIk2X91",
          "name": "Google Sheets - toan.ngo"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "0596acb0-ba5a-43cd-8957-ceefd7297d76",
      "name": "AI 代理 - 分析每条评论的情感",
      "type": "@n8n/n8n-nodes-langchain.sentimentAnalysis",
      "position": [
        1340,
        0
      ],
      "parameters": {
        "options": {
          "categories": "Positive, Neutral, Negative",
          "systemPromptTemplate": "You are a highly intelligent and precise sentiment analysis system.  \nWhen given any input text, determine its overall sentiment and classify it into one of the following categories: {categories}. \nUse the provided formatting instructions. Respond with exactly one JSON object and nothing else."
        },
        "inputText": "={{ $json.snippet.topLevelComment.snippet.textOriginal }}"
      },
      "typeVersion": 1
    },
    {
      "id": "38fabc2b-b369-436f-ac41-3e0cad36498b",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -420,
        -240
      ],
      "parameters": {
        "color": 4,
        "width": 420,
        "height": 940,
        "content": "## 1. 读取就绪视频 URL"
      },
      "typeVersion": 1
    },
    {
      "id": "bee35409-3dd4-4e03-aa76-12007a785384",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1080,
        -240
      ],
      "parameters": {
        "color": 4,
        "width": 880,
        "height": 940,
        "content": "## 3. 分析评论情感、更新结果和视频状态"
      },
      "typeVersion": 1
    },
    {
      "id": "73644694-fd5c-4962-8412-6249766024c1",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        40,
        -240
      ],
      "parameters": {
        "color": 4,
        "width": 1020,
        "height": 940,
        "content": "## 2. 通过 YouTube API 获取评论"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1763a723-5e69-4d7d-ac35-664c14ddf023",
  "connections": {
    "Split Out": {
      "main": [
        [
          {
            "node": "Check If - Comment Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Video URLs": {
      "main": [
        [
          {
            "node": "Check If Video URL is Not Empty",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "HTTP Request - Get Comments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        []
      ]
    },
    "Update Video Status": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent - Analyze Sentiment Of Every Comment",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Check If - Comment Exists": {
      "main": [
        [
          {
            "node": "AI Agent - Analyze Sentiment Of Every Comment",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update Video Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check If - Success Response": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request - Get Comments": {
      "main": [
        [
          {
            "node": "Check If - Success Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert Comment Data & Analysis": {
      "main": [
        [
          {
            "node": "Update Video Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check If Video URL is Not Empty": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Get Video URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent - Analyze Sentiment Of Every Comment": {
      "main": [
        [
          {
            "node": "Insert Comment Data & Analysis",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Insert Comment Data & Analysis",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Insert Comment Data & Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

作者
Agent Circle

Agent Circle

@agentcircle

Agent Circle - A growing marketplace of AI agents, workflows, and toolkits — built to help teams automate smarter and scale faster

外部链接
在 n8n.io 查看

分享此工作流