Automate YouTube Trend Discovery with n8n and Langchain AI

Discover how this unique n8n workflow uses Langchain AI and YouTube API to find trending videos in specific niches, helping creators save hours analyzing data and focus on content creation.
agent
chatTrigger
toolWorkflow
+8
Workflow Identifier: 1056
NODES in Use: agent, chatTrigger, toolWorkflow, lmChatOpenAi, httpRequest, youTube, set, code, splitInBatches, if, stickyNote

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 workflow does

This workflow collects trending YouTube videos in a chosen niche from the last 2 days. It filters out short videos under 3 minutes 30 seconds to focus on detailed content. Then, it cleans data by removing emojis and URLs and analyzes patterns to report trending themes, not just individual videos.

The main problem solved is saving content creators hours spent on manual YouTube trend research. The output is a clear summary of recent trends tailored to the niche.


Who should use this workflow

Creators who want fast insights from YouTube trend data in specific topics without wasting time searching manually.

Users with some access to Google APIs and basic n8n knowledge gain the most.


Tools and services used

  • n8n: to run and connect automation nodes.
  • Langchain AI Agent and Chat Trigger nodes: understand user input and decide search queries.
  • YouTube Data API with OAuth2: to search videos and retrieve detailed video data.
  • HTTP Request node: to fetch extended video info from the YouTube API.

Beginner step-by-step: How to build this in n8n

Import the workflow

  1. Download the workflow file using the Download button on this page.
  2. Inside the n8n editor, click “Import from File” and select the downloaded workflow.

Configure credentials and settings

  1. Add Google OAuth2 credentials for YouTube Data API in n8n.
  2. Insert your Google API key where required, especially inside the HTTP Request node.
  3. Make sure workflow IDs for any sub-workflows, like the YouTube search tool workflow, are updated if needed.
  4. Verify any hardcoded IDs, emails, or channel names are correct for your use.

Test and activate

  1. Run the workflow manually to test if it gets YouTube videos and processes them correctly.
  2. If successful, activate the workflow to listen for incoming chat messages and start trend detection in real time.

For better control and privacy, consider running self-host n8n.


Workflow input, processing steps, and output

Inputs

  • User sends a chat message with a niche or topic.
  • YouTube search queries from the niche terms.

Processing steps

  • Langchain Chat Trigger listens for incoming user messages with niche input.
  • Langchain AI Agent checks if the niche is given, and decides up to three search terms.
  • Langchain Tool Workflow calls a helper sub-workflow to run YouTube searches.
  • YouTube node retrieves up to 3 videos published in the last 48 hours per search term, filtered for region and duration.
  • If node filters out videos shorter than 3 minutes 30 seconds using ISO 8601 duration parsing.
  • HTTP Request node fetches detailed metadata including view count, likes, tags, and descriptions.
  • Set node formats and groups relevant video data.
  • Code node cleans text by removing emojis and URLs, then saves all video data into static workflow memory.
  • SplitInBatches node loops over each video for processing.
  • Set node compiles final responses for the AI Agent to return.

Outputs

The AI Agent returns a clear summary of trending themes and insights about recent videos fitting the niche.


Handling errors and edge cases

  • If Google API keys run out of quota or credentials are invalid, the workflow will error out during video search or data fetching.
  • If no niche is provided, the AI Agent asks the user to clarify before proceeding.
  • Overly narrow search terms or wrong region codes may return no videos.
  • Error in ISO duration parsing can cause all videos to be filtered incorrectly.
  • If the code node script for cleaning or data saving has syntax errors, collected data may be lost.

Customization ideas

  • Change the max number of YouTube search queries in the AI Agent prompt.
  • Adjust YouTube node regionCode to target different countries.
  • Modify the minimum video duration filter in the If node to include shorter videos.
  • Expand AI prompt to analyze video tags or channel reputation.
  • Add calls to other platforms such as TikTok or Instagram for wider trend data.

Summary of benefits and results

✓ Saves hours weekly by automating YouTube trend research.

✓ Filters and cleans video data for quality and clarity.

✓ Produces concise trend summaries tailored to chosen niches.

✓ Reduces manual work and risk of missing hot topics.

Frequently Asked Questions

Yes, the AI Agent adapts search terms based on user input if there is enough YouTube content for the niche.
Yes, each video search and each detailed data fetch counts against YouTube Data API quota.
All user messages and results remain inside the n8n instance; security depends on the n8n setup.
The workflow limits each search to 3 videos and batches processing to help scale, but managing API quotas is necessary for large volumes.

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 in n8n

A complete beginner guide to building an AI-powered 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