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
Automate YouTube trends with n8n and Langchain AI

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

Learn how to Build this Workflow with AI:

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.

Automate YouTube trends with n8n and Langchain AI

Visit through Desktop to Interact with the Workflow.

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 Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.