Automate YouTube Trend Analysis with n8n & Langchain AI

Discover how this unique n8n workflow empowers YouTube creators by automating trend analysis using Langchain AI and YouTube’s API. Save hours by gaining valuable insights on trending content tailored to your niche without manual research.
agent
chatTrigger
toolWorkflow
+8
Workflow Identifier: 1964
NODES in Use: agent, chatTrigger, toolWorkflow, lmChatOpenAi, memoryBufferWindow, httpRequest, youTube, splitInBatches, if, set, code

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What This Automation Does

This workflow finds trending YouTube videos for a given niche topic.

It solves the problem of wasting hours manually searching for relevant content.

The result is a clear report showing popular videos and trends to help make better content fast.

How This Workflow Works

Input: User sends a niche topic through a chat message.

Processing: AI checks the niche or suggests options.

Then it runs up to three YouTube searches with different keywords related to the niche.

For each found video, detailed metadata is fetched including views and comments.

Videos shorter than 3 minutes 30 seconds are filtered out.

Remaining videos’ data is cleaned and grouped.

AI analyzes tags and trends to find popular themes, not just videos.

Output: The user gets a summary with trending video links, channel info, and insights about content types doing well.


Who Should Use This Workflow

Any YouTube creator wanting quick trend insights in their niche.

Especially helpful for those who spend too long searching manually every day.


Tools and Services Used

  • n8n: the workflow automation platform.
  • Langchain AI nodes: for natural language processing and decision making.
  • YouTube Data API Key: fetch detailed video and channel data.
  • YouTube OAuth2 credentials: used in YouTube search node.
  • HTTP Request node: to make external API calls to Google’s YouTube API.

Optional: use self-host n8n for more control on deployment.


Beginner Step-by-Step: How to Use This Workflow in n8n

Step 1: Import the Workflow

  1. Download the workflow file using the Download button on the page.
  2. Inside the n8n editor, click on “Import from File.”
  3. Select the downloaded workflow file to bring it into n8n.

Step 2: Configure Credentials and Settings

  1. Add your YouTube Data API key in environment variables or credentials manager.
  2. Supply your YouTube OAuth2 credentials inside the YouTube search node.
  3. Check the Tool Workflow node named youtube_search and update any workflow IDs if needed.
  4. Paste or confirm any necessary system messages/prompts inside the AI Agent node. Example prompt is available in the workflow.

Step 3: Test the Workflow

  1. Trigger the chat_message_received node with a sample niche input like { “message”: “digital marketing” } using Postman or curl.
  2. Check that the AI Agent performs YouTube searches and returns summaries correctly.

Step 4: Activate for Production

  1. Turn on the workflow toggle in n8n editor to enable it.
  2. Make sure your webhook URL is publicly accessible.
  3. Use this URL to send niche requests and get trend reports anytime.

Input → Process → Output

Input

A chat message containing the user’s niche topic (example: “digital marketing”).

Process

  • The AI Agent validates or recommends niches.
  • It runs multiple YouTube searches with varied queries from the niche.
  • Fetches full video info using YouTube API.
  • Filters videos less than 210 seconds.
  • Cleans texts, removes emojis & URLs.
  • Stores all data in memory for analysis.
  • AI examines tag patterns to find themes.
  • Prepares a clear text report with links.

Output

A natural language summary of trending videos and channels with direct URLs and niche content insights.


Customization Ideas

  • Change YouTube search region codes in get_videos1 to check trends outside US (e.g., “GB” or “CA”).
  • Adjust the video duration filter in if_longer_than_3_ to select shorter or longer videos.
  • Increase number of searches in AI Agent prompt from 3 to 5 for broader coverage.
  • Modify AI summary style by editing the system prompt in the AI Agent node (professional, casual, etc.).
  • Save aggregated data to a database instead of static memory for trend tracking over time.

Common Issues and Fixes

  • Issue: The chat webhook triggers but AI Agent does not respond.
    Fix: Confirm AI Agent node has correct system prompt and is connected to chat trigger.
  • Issue: No videos return from YouTube search.
    Fix: Check API key validity, OAuth2 credentials, and search query parameters.
  • Issue: Video duration filter excludes valid videos.
    Fix: Verify JavaScript code parses ISO 8601 duration format properly in if_longer_than_3_ node.

Pre-Production Checklist ✅

  • Verify API keys and OAuth2 credentials are set correctly.
  • Test chat webhook input with sample niche message.
  • Run YouTube search workflow alone to confirm data retrieval.
  • Check filtering nodes to ensure video duration logic works.
  • Test AI Agent’s summarization by running complete workflow.
  • Backup workflow JSON before deploying live.

Deployment

Activate workflow toggle in n8n editor.

For self-host n8n, confirm the webhook URL is reachable externally.

Watch executions and logs regularly to fix any errors.

Run this workflow regularly to keep know-how fresh and content timely.


Summary

✓ Saves hours daily by automating YouTube trend discovery.

✓ Provides easy-to-understand, human-like summaries.

✓ Finds recent, relevant videos over multiple search terms.

✓ Filters to quality videos longer than 3m30s.

✓ Analyzes content tag patterns to reveal trending themes.

→ Deliverables include video/channel URLs and actionable insights.


Frequently Asked Questions

Yes, the AI agent adjusts to the niche topic provided in the chat message.
Yes, but it limits API calls to only necessary searches.
Data stays within the n8n environment and Google APIs, so protect API keys and credentials safely.
Review the JavaScript in the duration filter node to correctly parse ISO 8601 formatted durations.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free