{"id":"IJ4YYLsaOiD1z9Oz","meta":{"instanceId":"ed6d846a2fce1f660ede2e7da800724cca01dc3d0685524a3c917881b7cfcfe9","templateCredsSetupCompleted":true},"name":"YouTube - Audience Comment Analyzer","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":"Split Out","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 Chat Model","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":"When clicking ‘Test workflow’","type":"n8n-nodes-base.manualTrigger","position":[-360,220],"parameters":{},"typeVersion":1},{"id":"69c74c11-d4a5-4b27-9058-60ad46f9421c","name":"HTTP Request - Get Comments","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":"Loop Over Items","type":"n8n-nodes-base.splitInBatches","position":[320,220],"parameters":{"options":{}},"typeVersion":3},{"id":"40dba5d2-e175-443d-a417-45bdec5e84ec","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[-1180,-320],"parameters":{"width":660,"height":1820,"content":"## [n8n Automation] YouTube Comments Analyzer - Try It Out!\n\n**This n8n workflow demonstrates how to use this AI Agent to extract, process, and analyze YouTube video comments to understand your audience beyond the view count.**\n\nUse cases are many: Whether you're **a YouTube creator** exploring feedback, **a social media manager** fine-tuning engagement strategy, **a brand team** monitoring campaign sentiment, or **a marketing agency** conducting audits – this tool brings audience voice to the forefront with structured insights.\n\n## How It Works\n- The workflow starts when you manually click **Test Workflow** or **Execute Workflow** in n8n.\n- It collects all the rows marked as **Ready** in **Column A** in the **Video URLs** tab of your connected Google Sheet.\n- The tool checks if the URLs are not empty first, then it loops through each valid video URL and sends a **GET** request to the **YouTube API** to fetch its comments.\n- It checks the response from the YouTube API. If the call is successful, the comment data is extracted and split into individual entries. \n- The tool then checks whether the video URL has any comment.\n- If no comment is found, the video URL’s status in **Column A** in the **Video URLs** tab is updated to **Finished** right away.\n- If comments are available, they are passed to the **AI Agent - Analyze Sentiment Of Every Comment** using **the Google Gemini chat model**, where each comment is analyzed and classified by sentiment: **Positive**, **Neutral**, or **Negative**. \n- Next, the analysis results are saved to the **Results** tab in your connected Google Sheet. \n- Finally, the original video URL’s status in **Column A** in the **Video URLs** tab is updated to **Finished**, ensuring it won’t be reprocessed in the loop.\n\n## How To Set Up\n- Download the working package and import it into your n8n interface.\n- Duplicate the [**YouTube Comment Analyzer**](https://docs.google.com/spreadsheets/d/18-3CmJPbC73MycmNiSWotdsyGBAAzqESf33vktwnYmM/edit?gid=426418282#gid=426418282) Google Sheet template to your Google Sheets account.\n- Set up necessary credentials for tools access and usability:\n    + For **Google Sheets** access, ensure each node is properly connected to the correct tab in your connected Google Sheet template: \n     Node **Get Video URLs** → connected to the **Video URLs** tab\n     Node **Insert Comment Data & Analysis** → connected to the **Results** tab\n     Node **Update Video Status** → connected to the **Video URLs** tab\n    + For **YouTube** access, connect to its API in the following node:\n    Node **HTTP Request - Get Comments**\n    + For **Google Gemini** access, connect to its API in the following node:\n    Node **Google Gemini Chat Model**\n- Enter video URLs in **Column B** in the **Video URLs** tab in your connected Google Sheet and mark their status in **Column A** as **Ready**.\n- Click **Test Workflow** or **Execute Workflow** to run the process.\n- Check the results in the **Results** tab of the connected Google Sheet template to view all collected comments along with their sentiment analysis.\n\n## Requirements\n- Basic setup in Google Cloud Console (OAuth or API Key method enabled) with enabled access to YouTube and Google Sheets.\n- API access to **Google Gemini** for sentiment analysis.\n## How To Customize\n- By default, the workflow is manually triggered in N8N. However, you can automate the process by adding a **Google Sheets trigger** that monitors new entries in your connected Google Sheet template and starts the workflow automatically.\n- In the **AI Agent - Analyze Sentiment Of Every Comment** node, you can also change the AI chat model. By default, it uses **Google Gemini**, but you can easily replace it with any other compatible provider such as Deepseek, Grok, etc.\n- You can customize the sentiment categories and instruction prompt for the AI Agent in the **AI Agent – Analyze Sentiment Of Every Comment** node following your needs. Then, the Agent can return sentiment results that align more closely with your intended use case.\n- Also, feel free to integrate additional nodes (like Telegram or Email) to notify you and your team whenever updates and analysis succeed or fail.\n\n## Need Help?\nIf you’d like this workflow customized, or if you’re looking to build a tailored AI Agent for your own business - please feel free to reach out to [**Agent Circle**](https://www.agentcircle.ai/). We’re always here to support and help you to bring automation ideas to life.\n\nJoin our community on different platforms for assistance, inspiration and tips from others.\n\nWebsite: https://www.agentcircle.ai/\nEtsy: https://www.etsy.com/shop/AgentCircle\nGumroad: http://agentcircle.gumroad.com/\nDiscord Global: https://discord.gg/d8SkCzKwnP\nFB Page Global: https://www.facebook.com/agentcircle/\nFB Group Global: https://www.facebook.com/groups/aiagentcircle/\nX: https://x.com/agent_circle\nYouTube: https://www.youtube.com/@agentcircle\nLinkedIn: https://www.linkedin.com/company/agentcircle\n\n\n"},"typeVersion":1},{"id":"44b7e7f9-dab4-41d2-b0fd-c985da58480c","name":"Google Gemini Chat Model","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":"Check If Video URL is Not Empty","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":"Check If - Success Response","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":"Check If - Comment Exists","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":"Update Video Status","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":"Get Video URLs","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":"Insert Comment Data & Analysis","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 Agent - Analyze Sentiment Of Every Comment","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":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[-420,-240],"parameters":{"color":4,"width":420,"height":940,"content":"## 1. Read Ready Video URLs\n- The workflow begins by pulling all the rows marked as **Ready** in **Column A** from the **Video URLs** tab of your connected Google Sheet. These are the entries queued for processing."},"typeVersion":1},{"id":"bee35409-3dd4-4e03-aa76-12007a785384","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[1080,-240],"parameters":{"color":4,"width":880,"height":940,"content":"## 3. Analyze Comment Sentiment, Update Results And Video Status\n- The tool then checks whether the video URL has any comment.\n- If no comment is found, the video URL’s status in **Column A** in the **Video URLs** tab is updated to **Finished** right away.\n- If comments are available, they are passed to **the Google Gemini chat model**, where each comment is analyzed and labeled as: **Positive**, **Neutral**, or **Negative**. \n- Next, the analysis results are saved to the **Results** tab in your connected Google Sheet. \n- Finally, the original video URL’s status in **Column A** in the **Video URLs** tab is updated to **Finished**, ensuring it won’t be reprocessed in the loop."},"typeVersion":1},{"id":"73644694-fd5c-4962-8412-6249766024c1","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[40,-240],"parameters":{"color":4,"width":1020,"height":940,"content":"## 2. Fetch Comments Via YouTube API\n- The tool checks if the URLs are not empty first, then it loops through each valid video URL and sends a **GET** request to the **YouTube API** to fetch its comments.\n- It checks the response from the YouTube API. If the call is successful, the comment data is extracted and split into individual entries. "},"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}]]}}}