HomeAI AutomationHow to Analyze Trending YouTube Videos…
AI Automation

How to Analyze Trending YouTube Videos with n8n, Apify, OpenAI, and Google Sheets

How to Analyze Trending YouTube Videos with n8n, Apify, OpenAI, and Google Sheets

Burning hours on YouTube topic research is a creator tax nobody should pay. This n8n template turns a keyword into a stream of high-performing video ideas, thumbnail notes, and AI-written outlines inside Google Sheets – without opening a single YouTube tab.

In this tutorial you’ll import a ready-made workflow that combines n8n Apify OpenAI GPT-4.1 GPT-4o-mini Vision Google Sheets to automate the exact research loop most YouTubers run by hand every week.

What the workflow does

The template exposes a simple n8n form that accepts a keyword or topic. From there, everything is automatic:

  1. Scrape trending videos with Apify’s YouTube search actor – last 60 days, mid-length, newest first, capped at 100 results per run.
  2. Filter outliers: keep only videos with more than 1,000 views and more views than the channel has subscribers. This surfaces videos the algorithm is actively amplifying.
  3. Deduplicate against your sheet so you never re-process the same video twice.
  4. Analyze the thumbnail with GPT-4o-mini Vision – layout, subjects, color palette, mood – in one natural-language paragraph.
  5. Fetch the transcript via a second Apify actor.
  6. Generate an SEO-tuned title plus a 3-5 word thumbnail overlay with GPT-4.1-mini (JSON mode).
  7. Write an original outline with GPT-4.1 that borrows the structure of the winning video but takes a fresh angle – no copy-paste.
  8. Update the Google Sheet with the enriched row: new title, thumbnail text, thumbnail description, transcript, and outline.
Tip: Every node is renamed for clarity and has a sticky note next to it. The workflow is a single-screen flow once you import it – no hunting for connections.

Why this beats manual YouTube research

A manual research session typically takes 60-90 minutes for ten candidate topics: searching, skimming, noting view counts, checking sub counts, screenshotting thumbnails, drafting titles. This workflow runs the same loop in roughly 3-5 minutes per keyword and stores everything in a sortable sheet you can revisit for months.

The outlier filter is the secret sauce. A video with 200k views on a channel that has 30k subscribers is statistically winning right now. Those are the ideas you want to study – not the evergreen giants sitting on top of the search results.

Prerequisites

  • An n8n instance – self-hosted (Docker, VPS, Render) or n8n Cloud. Version 1.70+.
  • Apify account with API token. Free tier is enough for testing.
  • OpenAI API key with access to gpt-4o-mini, gpt-4.1-mini, and gpt-4.1.
  • Google Workspace account and a spreadsheet you control.

You’ll find the exact step-by-step to obtain every credential in the Credentials Guide PDF included with the download, and a full import walkthrough in the Setup Guide PDF. Grab the template here.

Step 1 – Prepare the Google Sheet

Create a new Google Sheet, rename the first tab to Step 1, and paste this header row across the top:

id | title | url | fromYTUrl | thumbnailUrl | channelName | channelUrl | duration | likes | numberOfSubscribers | viewCount | videoTranscript | thumbnailDescription | thumbnailText | newTitle | newOutline

Order doesn’t matter – n8n maps columns by name – but every field above must exist or the workflow will error out on write.

Step 2 – Import the n8n workflow

  1. Open n8n and hit + New > Import from File.
  2. Select analyze-trending-youtube-videos-apify-openai-sheets-n8n.json from the ZIP.
  3. n8n will open the canvas. You’ll see 12 nodes: a form trigger, two Apify HTTP calls, an IF filter, a Google Sheets dedupe + append, three OpenAI nodes, a merge, an update row, and a sticky note with setup instructions.

Step 3 – Paste your Apify token

Click Scrape Trending Videos (Apify), then Fetch Transcript (Apify). Each has an Authorization header set to Bearer YOUR_APIFY_TOKEN. Replace the placeholder with your real token from console.apify.com/account/integrations.

Which Apify actors? The template uses streamers/youtube-scraper for search and pintostudio/youtube-transcript-scraper for captions. Both have public IDs baked in – you do not need to fork them.

Step 4 – Attach OpenAI credentials

Open Analyze Thumbnail, YouTube Title Generator, and Generate Original Outline. For each, pick or create an OpenAI credential with your API key. The models are pre-selected:

  • Analyze Thumbnail: gpt-4o-mini in image mode (~$0.00015 per thumbnail).
  • YouTube Title Generator: gpt-4.1-mini in JSON mode.
  • Generate Original Outline: gpt-4.1 for deeper structure – swap to gpt-4.1-mini if you want to save 60% on that node.

Budget roughly $0.01-$0.02 per video analyzed at default settings.

Step 5 – Connect Google Sheets

Click each of the three Google Sheets nodes (Find Duplicate Entries, Step 1 Results, Update Rows) and:

  1. Attach your Google Sheets OAuth2 credential.
  2. Open the Document dropdown and pick the sheet you prepared in Step 1.
  3. Open the Sheet dropdown and choose the Step 1 tab.

Step 6 – Activate and run

Toggle the workflow active in the top-right corner. n8n exposes a public form at the URL shown on the On form submission node. Open it, type a keyword like “ai automation” or “home workout for seniors”, and submit.

Within a couple of minutes your sheet fills up with filtered videos, AI-optimized titles, and fresh outlines ready for scripting. Sort by viewCount / numberOfSubscribers in a helper column to see the strongest outliers first.

How the filter works under the hood

The Filter High-Potential Videos node enforces two conditions with an AND combinator:

viewCount > 1000
viewCount > numberOfSubscribers

The first condition removes noise – brand-new uploads with a handful of views. The second is the outlier signal: a video whose views already beat the uploader’s subscriber count is almost certainly being pushed by YouTube’s recommendation engine. That’s the exact moment to study the thumbnail, hook, and structure.

Customization ideas

  • Daily cron: replace the form trigger with a Schedule node that runs a rotating list of keywords every morning.
  • Slack digest: add a Slack node after Update Rows to post the top five new outliers to #content channel.
  • Notion sync: mirror the sheet into a Notion database so writers can claim outlines from their side.
  • Shorts mode: swap lengthFilter to "under4" in the scrape node to hunt trending Shorts instead of long-form.
  • Voice cloning prep: pipe the generated outline into ElevenLabs for a rough voiceover of the hook.

Troubleshooting

“Unauthorized” from Apify: the Bearer token is missing or has a trailing space. Paste it again without the word Bearer duplicated.

Google Sheets node errors on missing column: double-check the header row spelling. Column names are case-sensitive.

OpenAI returns a non-JSON outline: the Generate Original Outline node is in text mode on purpose (outlines are prose). If you want structured JSON, toggle JSON Output on and update the system prompt.

Transcript is empty: the Apify transcript actor occasionally fails on age-restricted or auto-generated-caption-disabled videos. The workflow continues gracefully – the row simply has a blank videoTranscript and a weaker outline.

Skip the rebuild – get the finished template

Download the ready-to-import JSON plus the Setup and Credentials guides. Save an afternoon of wiring.

Get the YouTube Trends n8n Template

Final thoughts

YouTube research used to be a research skill. Now it’s a workflow you run on a coffee break. Hook this into your weekly content planning, let it pre-fill your sheet with validated topics, and spend your actual creative energy on the hook and delivery – the parts AI still can’t do for you.