YouTube 评论抓取器
高级
这是一个AI, Marketing领域的自动化工作流,包含 18 个节点。主要使用 If, Set, Code, Gmail, Limit 等节点,结合人工智能技术实现智能自动化。 使用 GPT-4o 的 YouTube 评论抓取与分析器 + 邮件摘要报告
前置要求
- •Google 账号和 Gmail API 凭证
- •可能需要目标 API 的认证凭证
- •Google Sheets API 凭证
- •OpenAI API Key
使用的节点 (18)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "ItynUguvK0Dx6mw4",
"meta": {
"instanceId": "260491e02302632e6a217f5c83135ad573c31ec4f93b05d79785a77df9c4a7e5",
"templateCredsSetupCompleted": true
},
"name": "YouTube 评论抓取器",
"tags": [],
"nodes": [
{
"id": "workflow-overview-note",
"name": "工作流概览",
"type": "n8n-nodes-base.stickyNote",
"position": [
-300,
-250
],
"parameters": {
"color": 2,
"width": 350,
"height": 400,
"content": "# 📊 YouTube 评论分析器工作流"
},
"typeVersion": 1
},
{
"id": "trigger-section-note",
"name": "触发器文档",
"type": "n8n-nodes-base.stickyNote",
"position": [
-50,
-250
],
"parameters": {
"color": 3,
"width": 300,
"height": 220,
"content": "## 🚀 触发器部分"
},
"typeVersion": 1
},
{
"id": "youtube-data-note",
"name": "YouTube API 部分",
"type": "n8n-nodes-base.stickyNote",
"position": [
770,
-250
],
"parameters": {
"color": 1,
"width": 280,
"height": 200,
"content": "## 📹 YouTube 数据收集"
},
"typeVersion": 1
},
{
"id": "ai-analysis-note",
"name": "AI 分析文档",
"type": "n8n-nodes-base.stickyNote",
"position": [
1420,
-280
],
"parameters": {
"color": 5,
"width": 320,
"height": 250,
"content": "## 🤖 AI 分析部分"
},
"typeVersion": 1
},
{
"id": "email-update-note",
"name": "电子邮件和状态更新",
"type": "n8n-nodes-base.stickyNote",
"position": [
2036,
-250
],
"parameters": {
"color": 4,
"width": 300,
"height": 220,
"content": "## 📧 电子邮件和更新部分"
},
"typeVersion": 1
},
{
"id": "data-prep-note",
"name": "数据处理说明",
"type": "n8n-nodes-base.stickyNote",
"position": [
1270,
200
],
"parameters": {
"color": 6,
"width": 250,
"height": 180,
"content": "⚠️ **数据准备**"
},
"typeVersion": 1
},
{
"id": "b5d9ad95-9fcc-4c3d-bf90-42e897ab5eda",
"name": "限制",
"type": "n8n-nodes-base.limit",
"notes": "Limits processing to 1 item at a time to prevent API overload",
"position": [
440,
0
],
"parameters": {},
"typeVersion": 1
},
{
"id": "d0f82101-07e6-4559-9b73-91b85dc77b40",
"name": "AI 代理",
"type": "@n8n/n8n-nodes-langchain.agent",
"notes": "Uses OpenAI GPT-4o to analyze comments and generate insights. Customize the prompt for different analysis needs.",
"position": [
1540,
0
],
"parameters": {
"text": "=Analyze these comments from the video \"{{ $json.videoTitle }}\":\n\nTotal Comments: {{ $json.totalComments }}\nAverage Likes: {{ $json.avgLikes }}\n\nComments to analyze:\n{{ $json.commentTexts }}",
"options": {
"maxIterations": 100,
"systemMessage": "You are a YouTube comment analyst. Analyze the provided comments and return a structured analysis with:\n1. Overall sentiment breakdown (positive/negative/neutral percentages)\n2. Top 3-5 main themes or topics discussed\n3. Common questions from viewers\n4. Key feedback points and suggestions\n5. Actionable insights for content improvement\n\nFormat your response in clear sections with headers in json key value format and use underscore in the key name. Always use following keys for output json: \n1. overall_sentiment_breakdown\n2. main_themes\n3. common_questions\n4. key_feedback_points\n5. actionable_insights"
},
"promptType": "define"
},
"typeVersion": 1.9
},
{
"id": "e7a9b6ea-af4a-4970-ba0e-3e18608015f5",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1628,
220
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {
"responseFormat": "json_object"
}
},
"credentials": {
"openAiApi": {
"id": "O2czYITX17GGksaO",
"name": "OpenAi account 4"
}
},
"typeVersion": 1.2
},
{
"id": "7c22599f-6fa8-4461-9b81-89a283a9dc84",
"name": "如果",
"type": "n8n-nodes-base.if",
"notes": "Filters rows to process only videos with 'Pending' status",
"position": [
220,
0
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "5f1eae10-5270-4e99-8627-597e3451c82c",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.Status }}",
"rightValue": "Pending"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "152902fb-d715-4473-972f-4f75e5788b7a",
"name": "设置视频详情",
"type": "n8n-nodes-base.set",
"notes": "Prepares video ID and sets max comments limit (100)",
"position": [
660,
0
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "219795ef-daa4-4444-9865-c5d3856be63b",
"name": "videoId",
"type": "string",
"value": "={{ $json['Youtube video id'] }}"
},
{
"id": "cd4f519d-4c84-496c-8974-29ef69c890fc",
"name": "maxComments ",
"type": "number",
"value": 100
}
]
}
},
"typeVersion": 3.4
},
{
"id": "67bb511b-478c-4fec-ba6a-816d81a8bad1",
"name": "获取 YouTube 视频详情",
"type": "n8n-nodes-base.youTube",
"notes": "Fetches video metadata including title, channel name, and other details",
"position": [
880,
0
],
"parameters": {
"options": {},
"videoId": "={{ $json.videoId }}",
"resource": "video",
"operation": "get"
},
"credentials": {
"youTubeOAuth2Api": {
"id": "2Mya1dm7vKjkxzqb",
"name": "YouTube account"
}
},
"typeVersion": 1
},
{
"id": "880379c3-791a-424f-a170-db214ee0bad0",
"name": "获取 YouTube 视频评论",
"type": "n8n-nodes-base.httpRequest",
"notes": "Retrieves top 100 comments ordered by relevance using YouTube API",
"position": [
1100,
0
],
"parameters": {
"url": "https://www.googleapis.com/youtube/v3/commentThreads",
"options": {},
"sendQuery": true,
"authentication": "predefinedCredentialType",
"queryParameters": {
"parameters": [
{
"name": "part",
"value": "snippet"
},
{
"name": "videoId",
"value": "={{ $('Set Video Details').item.json.videoId }}"
},
{
"name": "maxResults",
"value": "100"
},
{
"name": "order",
"value": "relevance"
}
]
},
"nodeCredentialType": "youTubeOAuth2Api"
},
"credentials": {
"youTubeOAuth2Api": {
"id": "2Mya1dm7vKjkxzqb",
"name": "YouTube account"
}
},
"typeVersion": 4.2
},
{
"id": "4a7f24c6-5dea-400f-8f0b-351597cae840",
"name": "准备评论数据",
"type": "n8n-nodes-base.code",
"notes": "Processes raw comments: extracts text, calculates stats, performs basic sentiment analysis, limits to 50 comments for AI",
"position": [
1320,
0
],
"parameters": {
"jsCode": "// Get comments from HTTP Request node\nconst comments = $input.first().json.items\n//const comments = response.items || [];\n\n// Get video title from the YouTube node (step 5)\n//const videoData = ;\nconst videoTitle = $('Get Youtube Video Details').first().json.snippet.title;\n\n// Extract comment data\nconst processedComments = comments.map(item => {\n const comment = item.snippet.topLevelComment.snippet;\n return {\n text: comment.textDisplay,\n author: comment.authorDisplayName,\n likes: comment.likeCount || 0,\n publishedAt: comment.publishedAt,\n replyCount: item.snippet.totalReplyCount || 0\n };\n});\n\n// Calculate statistics\nconst totalComments = processedComments.length;\nconst totalLikes = processedComments.reduce((sum, c) => sum + c.likes, 0);\nconst avgLikes = totalComments > 0 ? (totalLikes / totalComments).toFixed(2) : 0;\nconst totalReplies = processedComments.reduce((sum, c) => sum + c.replyCount, 0);\n\n// Get top comments by likes\nconst topComments = processedComments\n .sort((a, b) => b.likes - a.likes)\n .slice(0, 5);\n\n// Prepare comment texts for AI analysis\nconst commentTexts = processedComments\n .slice(0, 50) // Limit to 50 comments for AI analysis\n .map(c => c.text)\n .join('\\n---\\n');\n\n// Basic sentiment analysis (count positive/negative keywords)\nconst positiveWords = ['love', 'great', 'awesome', 'amazing', 'excellent', 'good', 'fantastic', 'helpful', 'thanks'];\nconst negativeWords = ['hate', 'terrible', 'awful', 'bad', 'worst', 'horrible', 'useless', 'waste'];\n\nlet positiveCount = 0;\nlet negativeCount = 0;\n\nprocessedComments.forEach(comment => {\n const lowerText = comment.text.toLowerCase();\n positiveWords.forEach(word => {\n if (lowerText.includes(word)) positiveCount++;\n });\n negativeWords.forEach(word => {\n if (lowerText.includes(word)) negativeCount++;\n });\n});\n\nreturn [{\n json: {\n videoTitle,\n totalComments,\n avgLikes,\n totalReplies,\n topComments,\n commentTexts,\n processedComments,\n sentimentCounts: {\n positive: positiveCount,\n negative: negativeCount,\n neutral: totalComments - positiveCount - negativeCount\n }\n }\n}];\n\n"
},
"typeVersion": 2
},
{
"id": "06ddd27a-242e-4975-82e4-2795af0252a7",
"name": "准备电子邮件 HTML",
"type": "n8n-nodes-base.code",
"notes": "Converts AI analysis into formatted HTML email with statistics, insights, and professional styling",
"position": [
1916,
0
],
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const output = JSON.parse($json.output)\n //return output; \n//return output.overall_sentiment_breakdown.Positive;\n\nlet common_question = \"\";\n \noutput.common_questions.map(rec => {\n return common_question += \"<li>\"+rec.trim().replace(new RegExp(\".*,$\"), \"\")+\"</li>\"\n})\n\nlet key_feedback_points_and_suggestions = \"\";\n\noutput.key_feedback_points.map(rec => {\n return key_feedback_points_and_suggestions += \"<li>\"+rec.trim().replace(new RegExp(\".*,$\"), \"\")+\"</li>\"\n})\n\n\nlet actionable_insights_for_content_improvement = \"\"\n\noutput.actionable_insights.map(rec => {\n return actionable_insights_for_content_improvement += \"<li>\"+rec.trim().replace(new RegExp(\".*,$\"), \"\")+\"</li>\"\n})\n\n\n// return {common_question};\n\n\n \n\n//return output; \n// Generate the email HTML\nconst emailHTML = `\n<!DOCTYPE html>\n<html>\n<head>\n <style>\n body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; }\n .header { background: #f4f4f4; padding: 20px; border-radius: 5px; }\n .section { margin: 20px 0; }\n .stats { background: #e9ecef; padding: 15px; border-radius: 5px; }\n .analysis { background: #f8f9fa; padding: 20px; border-radius: 5px; }\n h2 { color: #2c3e50; }\n h3 { color: #34495e; }\n h4 { color: #7f8c8d; }\n .footer { margin-top: 30px; padding-top: 20px; border-top: 1px solid #ddd; color: #666; font-size: 0.9em; }\n </style>\n</head>\n<body>\n <div class=\"header\">\n <h2>YouTube Comments Analysis Report</h2>\n <h3>Video: ${$(\"Prepare Comments Data\").item.json.videoTitle}</h3>\n </div>\n\n <div class=\"section stats\">\n <h3> Quick Statistics</h3>\n <ul>\n <li><strong>Total Comments Analyzed:</strong> ${$('Prepare Comments Data').item.json.totalComments}</li>\n <li><strong>Average Likes per Comment:</strong> ${$('Prepare Comments Data').item.json.avgLikes}</li>\n <li><strong>Total Replies:</strong> ${$('Prepare Comments Data').item.json.totalReplies}</li>\n <li><strong>Sentiment Summary:</strong> \n Positive: ${output.overall_sentiment_breakdown.positive}, \n Negative: ${output.overall_sentiment_breakdown.negative}, \n Neutral: ${output.overall_sentiment_breakdown.neutral}\n </li>\n </ul>\n </div>\n\n <div class=\"section stats\">\n <h3>Common Questions</h3>\n <ul>\n ${common_question}\n </ul>\n </div>\n\n <div class=\"section stats\">\n <h3>Key feedback points and suggestions</h3>\n <ul>\n ${key_feedback_points_and_suggestions}\n </ul>\n </div>\n\n\n <div class=\"section stats\">\n <h3>Actionable insights for content improvement</h3>\n <ul>\n ${actionable_insights_for_content_improvement}\n </ul>\n </div>\n\n\n\n\n <div class=\"footer\">\n <p><em>Report generated on ${new Date().toLocaleString()}</em></p>\n \n </div>\n</body>\n</html>`;\n\n\n// Return the formatted data\nreturn {\n json: {\n emailHTML,\n subject: `YouTube Analysis: ${$('Prepare Comments Data').item.json.videoTitle} - ${$('Prepare Comments Data').item.json.totalComments} comments analyzed`,\n videoTitle: $('Prepare Comments Data').item.json.videoTitle\n }\n};"
},
"typeVersion": 2
},
{
"id": "2c28a815-1e36-47ab-a96c-a3c040f60551",
"name": "Gmail 账户配置",
"type": "n8n-nodes-base.gmail",
"notes": "Sends formatted analysis report via Gmail. Update SENDER_EMAIL_ADDRESS with actual recipient",
"position": [
2136,
0
],
"webhookId": "90b8f9ad-4226-42a0-971b-7fa9f5f190bd",
"parameters": {
"sendTo": "SENDER_EMAIL_ADDRESS",
"message": "={{ $json.emailHTML }}",
"options": {},
"subject": "={{ $json.subject }}"
},
"credentials": {
"gmailOAuth2": {
"id": "JYZ1uo6n4Jnfozjt",
"name": "Gmail account 3"
}
},
"typeVersion": 2.1
},
{
"id": "1303d6f5-d8a8-44ea-b062-ba25dbb43e6e",
"name": "在 Google 表格上更新状态",
"type": "n8n-nodes-base.googleSheets",
"notes": "Updates video status to 'Mail Sent' to prevent duplicate processing",
"position": [
2356,
0
],
"parameters": {
"columns": {
"value": {
"Id": "={{ $('Pick Video Ids from Google sheet').item.json.Id }}",
"Status": "Mail Sent"
},
"schema": [
{
"id": "Id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Youtube video id",
"type": "string",
"display": true,
"required": false,
"displayName": "Youtube video id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Status",
"type": "string",
"display": true,
"required": false,
"displayName": "Status",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "row_number",
"type": "string",
"display": true,
"removed": true,
"readOnly": true,
"required": false,
"displayName": "row_number",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"Id"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "update",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "GOOGLE_DRIVE_URL",
"cachedResultName": "Youtube_Video "
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1qe6Ovp_pfmwZA2k5c7LmmZx-OKqv3hnu8Dg80Pw4KoY",
"cachedResultUrl": "GOOGLE_DRIVE_URL",
"cachedResultName": "Youtube_Video"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "ApqY25iiOci0QMVA",
"name": "Google Sheets account 4"
}
},
"typeVersion": 4.5
},
{
"id": "f9028f08-170b-4d2f-8c6b-b1dbf470d3a3",
"name": "从 Google 表格中选择视频 ID",
"type": "n8n-nodes-base.googleSheetsTrigger",
"notes": "Triggers on new YouTube videos added to spreadsheet. Polls every minute for changes",
"position": [
0,
0
],
"parameters": {
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "GOOGLE_DRIVE_URL",
"cachedResultName": "Youtube_Video "
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1qe6Ovp_pfmwZA2k5c7LmmZx-OKqv3hnu8Dg80Pw4KoY",
"cachedResultUrl": "GOOGLE_DRIVE_URL",
"cachedResultName": "Youtube_Video"
}
},
"credentials": {
"googleSheetsTriggerOAuth2Api": {
"id": "qr4PWvkowXONSaw4",
"name": "Google Sheets Trigger account 4"
}
},
"typeVersion": 1
}
],
"active": true,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "be4e97c1-bc7f-4a62-bd2a-f636c65fd256",
"connections": {
"If": {
"main": [
[
{
"node": "Limit",
"type": "main",
"index": 0
}
]
]
},
"Limit": {
"main": [
[
{
"node": "Set Video Details",
"type": "main",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[
{
"node": "Prepare HTML for Email",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Set Video Details": {
"main": [
[
{
"node": "Get Youtube Video Details",
"type": "main",
"index": 0
}
]
]
},
"Prepare Comments Data": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Prepare HTML for Email": {
"main": [
[
{
"node": "Gmail Account Configuration",
"type": "main",
"index": 0
}
]
]
},
"Get Youtube Video Details": {
"main": [
[
{
"node": "Get Youtube Video Comments",
"type": "main",
"index": 0
}
]
]
},
"Get Youtube Video Comments": {
"main": [
[
{
"node": "Prepare Comments Data",
"type": "main",
"index": 0
}
]
]
},
"Gmail Account Configuration": {
"main": [
[
{
"node": "Update Status on Google Sheet",
"type": "main",
"index": 0
}
]
]
},
"Update Status on Google Sheet": {
"main": [
[]
]
},
"Pick Video Ids from Google sheet": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 人工智能, 营销
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用AI和Slack审批的LinkedIn帖子自动化
LinkedIn帖子自动化:AI(GPT-4o)生成与Slack审批
If
Set
Code
+11
32 节点Amit Mehta
人工智能
AI YouTube分析助手:评论分析与洞察报告
AI YouTube分析助手:评论分析器与洞察报告生成器
If
Set
Code
+9
19 节点Yaron Been
人工智能
使用AI、ElevenLabs和多平台发布创建和审批POV视频
使用AI、ElevenLabs和多平台发布创建和审批POV视频(TikTok/IG/YT)
If
Set
Code
+20
60 节点Immanuel
设计
使用GPT-4o、WordPress和LinkedIn发布自动化RSS内容到博客文章
使用GPT-4o、WordPress和LinkedIn发布自动化RSS内容到博客文章
If
Set
Code
+21
40 节点Immanuel
人工智能
使用AI、ElevenLabs、PIAPI Shotstack/Creatomate生成视频并发布到YouTube
使用AI、ElevenLabs、PIAPI Shotstack/Creatomate生成视频并发布到YouTube
If
Set
Code
+16
79 节点Immanuel
人工智能
AI YouTube 评论分析器
使用 GPT-4o 进行 YouTube 评论分析并通过 Gmail 发送自动邮件报告
If
Set
Code
+9
18 节点Rahul Joshi
人工智能
工作流信息
难度等级
高级
节点数量18
分类2
节点类型12
作者
Amit Mehta
@amitswbaI'm a workflow automation expert with 15+ years in IT industry. I build smart, scalable n8n workflows for AI automation, marketing, CRM, and SaaS integrations. My focus is on simplifying business processes with tools like OpenAI, WhatsApp, Gmail, and Airtable. I help teams and solopreneurs automate smarter, reduce manual tasks, and grow faster—one workflow at a time.
外部链接
在 n8n.io 查看 →
分享此工作流