Quick overview
This workflow runs manually to find this week’s most popular YouTube videos for a niche using Apify, collects top comments from the highest-viewed videos, and uses OpenAI to produce a concise audience insight report with themes, questions, complaints, and video ideas.
How it works
- Runs when you execute the workflow manually in n8n.
- Sends a request to Apify’s sedgelabs/youtube-search-scraper actor to fetch up to 20 US YouTube videos uploaded this week for the specified niche query.
- Sorts the results by view count and keeps the top N videos based on your topVideos setting.
- Sends the selected video URLs to Apify’s sedgelabs/youtube-comments-scraper actor to retrieve up to maxComments top comments per video.
- Groups and trims the comments into a size-capped prompt and asks OpenAI to generate a plain-text report of themes, viewer questions, common complaints, and video ideas using only the provided comments.
- Outputs a final JSON report containing the niche, the top videos list, the number of comments analysed, and the OpenAI-generated summary.
Setup
- Create an Apify account, generate an API token, and add an n8n Header Auth credential that sends
Authorization: Bearer <token> for the Apify HTTP requests.
- Add an OpenAI API key credential in n8n and select it on the OpenAI node.
- Update the Settings values (niche, topVideos, maxComments, and openaiModel) to match the topic and output size you want, then execute the workflow.
Requirements
- An Apify account with an API token, and an OpenAI API key. A run costs at most about $0.33 on Apify, plus the OpenAI call.
Customization
- Keep the niche phrase tight: a broad one can pull in brand or celebrity videos that only mention the topic.
Additional info
By Sedge Labs (sedgelabs.dev). Actors: YouTube Search Scraper (https://apify.com/sedgelabs/youtube-search-scraper) and YouTube Comments Scraper (https://apify.com/sedgelabs/youtube-comments-scraper). The workflow uses built-in n8n nodes only.