AI YouTube分析助手:评论分析与洞察报告
高级
这是一个AI、Marketing领域的自动化工作流,包含 19 个节点。主要使用 If、Set、Code、Gmail、Limit 等节点,结合人工智能技术实现智能自动化。 AI YouTube分析助手:评论分析器与洞察报告生成器
前置要求
- •Google 账号和 Gmail API 凭证
- •可能需要目标 API 的认证凭证
- •Google Sheets API 凭证
- •OpenAI API Key
使用的节点 (19 个)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "5aaf4236c70e34e423fbdb2c7b754d19253a933bb1476d548f75848a01e473cf",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "e0eae618-d330-4b74-b5a4-528a28ec91c6",
"name": "便签12",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1260,
220
],
"parameters": {
"color": 4,
"width": 480,
"height": 740,
"content": "======================================="
},
"typeVersion": 1
},
{
"id": "e73f0186-b1a7-4ab9-a23e-94a38d51f8bb",
"name": "工作流概述",
"type": "n8n-nodes-base.stickyNote",
"position": [
-640,
420
],
"parameters": {
"color": 2,
"width": 350,
"height": 820,
"content": "# 📊 YouTube 评论分析器工作流"
},
"typeVersion": 1
},
{
"id": "606f8cb5-54a5-4a90-be41-089d7ccae72f",
"name": "触发器文档",
"type": "n8n-nodes-base.stickyNote",
"position": [
-260,
320
],
"parameters": {
"color": 3,
"width": 380,
"height": 340,
"content": "## 🚀 触发器部分"
},
"typeVersion": 1
},
{
"id": "f225b68e-272e-4414-82c2-2f79cfbcc381",
"name": "YouTube API 部分",
"type": "n8n-nodes-base.stickyNote",
"position": [
560,
440
],
"parameters": {
"width": 280,
"height": 200,
"content": "## 📹 YouTube 数据收集"
},
"typeVersion": 1
},
{
"id": "628d65ff-007c-4b7a-862e-64158fa80e7c",
"name": "AI 分析文档",
"type": "n8n-nodes-base.stickyNote",
"position": [
1300,
420
],
"parameters": {
"color": 5,
"width": 320,
"height": 250,
"content": "## 🤖 AI 分析部分"
},
"typeVersion": 1
},
{
"id": "85b58261-88e1-499a-a082-548713da293e",
"name": "邮件与状态更新",
"type": "n8n-nodes-base.stickyNote",
"position": [
1820,
460
],
"parameters": {
"color": 4,
"width": 300,
"height": 220,
"content": "## 📧 邮件和更新部分"
},
"typeVersion": 1
},
{
"id": "e0ba6c37-8b04-406b-9158-aef610274135",
"name": "数据处理说明",
"type": "n8n-nodes-base.stickyNote",
"position": [
1060,
900
],
"parameters": {
"color": 6,
"width": 250,
"height": 180,
"content": "⚠️ **数据准备**"
},
"typeVersion": 1
},
{
"id": "d7edbd68-9213-426b-ae6b-71a13bb23690",
"name": "限制",
"type": "n8n-nodes-base.limit",
"notes": "Limits processing to 1 item at a time to prevent API overload",
"position": [
220,
700
],
"parameters": {},
"typeVersion": 1
},
{
"id": "42f0f581-57a0-438d-b1a1-29a89e984554",
"name": "AI Agent",
"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": [
1320,
700
],
"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": "35abbd58-e69a-4d86-963e-0a758aaff7b2",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1420,
920
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {
"responseFormat": "json_object"
}
},
"typeVersion": 1.2
},
{
"id": "747fb13b-ee39-4dd7-8338-8db07e3b568e",
"name": "条件判断",
"type": "n8n-nodes-base.if",
"notes": "Filters rows to process only videos with 'Pending' status",
"position": [
0,
700
],
"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": "6895d6b4-4ae4-4092-9302-33b1c69167d6",
"name": "设置视频详情",
"type": "n8n-nodes-base.set",
"notes": "Prepares video ID and sets max comments limit (100)",
"position": [
440,
700
],
"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": "df200d75-d932-4bb4-9e57-16a940963db3",
"name": "获取 YouTube 视频详情",
"type": "n8n-nodes-base.youTube",
"notes": "Fetches video metadata including title, channel name, and other details",
"position": [
660,
700
],
"parameters": {
"options": {},
"videoId": "={{ $json.videoId }}",
"resource": "video",
"operation": "get"
},
"typeVersion": 1
},
{
"id": "5346229d-9386-497b-99c7-192e75896bf2",
"name": "获取 YouTube 视频评论",
"type": "n8n-nodes-base.httpRequest",
"notes": "Retrieves top 100 comments ordered by relevance using YouTube API",
"position": [
880,
700
],
"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"
},
"typeVersion": 4.2
},
{
"id": "ffee99ec-ad6d-4ac9-b0ad-e466a18ad7de",
"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": [
1100,
700
],
"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": "7eab55e1-e9e2-4750-a07d-f02941c7a8c6",
"name": "准备邮件 HTML 内容",
"type": "n8n-nodes-base.code",
"notes": "Converts AI analysis into formatted HTML email with statistics, insights, and professional styling",
"position": [
1700,
700
],
"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": "f789c4e0-813b-4f6d-9584-86a274fba969",
"name": "Gmail 账户配置",
"type": "n8n-nodes-base.gmail",
"notes": "Sends formatted analysis report via Gmail. Update SENDER_EMAIL_ADDRESS with actual recipient",
"position": [
1920,
700
],
"webhookId": "90b8f9ad-4226-42a0-971b-7fa9f5f190bd",
"parameters": {
"sendTo": "SENDER_EMAIL_ADDRESS",
"message": "={{ $json.emailHTML }}",
"options": {},
"subject": "={{ $json.subject }}"
},
"typeVersion": 2.1
},
{
"id": "309d2e7d-2da0-439b-b2ac-87196d9f5733",
"name": "在 Google Sheets 中更新状态",
"type": "n8n-nodes-base.googleSheets",
"notes": "Updates video status to 'Mail Sent' to prevent duplicate processing",
"position": [
2140,
700
],
"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"
}
},
"typeVersion": 4.5
},
{
"id": "b62a4e3a-c843-4ed2-9ee4-cbfb1a218259",
"name": "从 Google Sheets 中选取视频 ID",
"type": "n8n-nodes-base.googleSheetsTrigger",
"notes": "Triggers on new YouTube videos added to spreadsheet. Polls every minute for changes",
"position": [
-220,
700
],
"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"
}
},
"typeVersion": 1
}
],
"pinData": {},
"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
}
]
]
},
"Pick Video Ids from Google sheet": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
这是一个高级难度的工作流,适用于AI、Marketing等场景。适合高级用户,包含 16+ 个节点的复杂工作流
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
YouTube 评论抓取器
使用 GPT-4o 的 YouTube 评论抓取与分析器 + 邮件摘要报告
If
Set
Code
+9
18 节点Amit Mehta
AI
使用AI、ElevenLabs和多平台发布创建和审批POV视频
使用AI、ElevenLabs和多平台发布创建和审批POV视频(TikTok/IG/YT)
If
Set
Code
+20
60 节点Immanuel
Design
使用 GPT-4 自动生成并分发 LinkedIn 帖子到个人资料和群组
使用 GPT-4 自动生成并分发 LinkedIn 帖子到个人资料和群组
If
Code
Limit
+8
14 节点Yaron Been
AI
AI YouTube 评论分析器
使用 GPT-4o 进行 YouTube 评论分析并通过 Gmail 发送自动邮件报告
If
Set
Code
+9
18 节点Rahul Joshi
AI
使用AI、ElevenLabs、PIAPI Shotstack/Creatomate生成视频并发布到YouTube
使用AI、ElevenLabs、PIAPI Shotstack/Creatomate生成视频并发布到YouTube
If
Set
Code
+16
79 节点Immanuel
AI
使用GPT-4o、WordPress和LinkedIn发布自动化RSS内容到博客文章
使用GPT-4o、WordPress和LinkedIn发布自动化RSS内容到博客文章
If
Set
Code
+21
40 节点Immanuel
AI
工作流信息
难度等级
高级
节点数量19
分类2
节点类型12
作者
Yaron Been
@yaron-nofluffBuilding AI Agents and Automations | Growth Marketer | Entrepreneur | Book Author & Podcast Host
外部链接
在 n8n.io 上查看 →
分享此工作流