Use this powerful n8n workflow to automatically search YouTube for recent videos, filter by length, and extract sanitized metadata for trend analysis. A highly efficient component for larger n8n templates.
Download this n8n workflow template and start using it instantly.
Content Marketers: Automating competitive analysis and identifying emerging content trends.
Data Analysts: Needing structured, cleaned YouTube data for ingestion into databases or analytics platforms.
AI Developers: Preparing clean, aggregated text data (descriptions, titles, tags) for large language models (LLMs).
n8n Automation Specialists: Users looking for advanced examples of flow control, data sanitization, and sub-workflow construction within n8n.
Spotting fast-moving trends on platforms like YouTube requires rapid, systematic data extraction. This specific n8n workflow is designed as a reusable sub-component to solve the challenge of efficiently gathering comprehensive statistics and textual data (like descriptions and tags) from newly uploaded videos relevant to a search query.
Triggered by a primary parent workflow, this n8n workflow executes a focused search, limiting results to videos published within the last 48 hours. Critically, it uses an If n8n node to filter out excessively short content (like Shorts or clips under 3.5 minutes), ensuring the collected data is relevant for long-form content trend analysis. The gathered information is sanitized using custom JavaScript code, stripping out URLs and emojis, making the final output perfectly clean for processing by LLMs or further analysis in other n8n templates. This optimization significantly reduces processing load and improves the quality of data ingested by the next steps in your master n8n workflow.
This automation acts as a sub-routine, starting with the When Executed by Another Workflow n8n trigger. This specialized n8n trigger waits for execution signals and input parameters from a parent workflow, specifically receiving a search_term query.
Youtube - Get Video n8n node executes a search using the provided term, limiting results to three recent videos (published within the last two days).Loop Over Items n8n node processes each video result individually.HTTP - Find Video Data n8n node performs a second API call using the video ID to retrieve complete statistics and content details, which are not available in the initial search results.If - Longer Than 3 n8n node applies a crucial filter. It uses JavaScript logic to parse the ISO 8601 duration and only continues the workflow if the video is longer than 210 seconds (3 minutes 30 seconds).Field - Group Data n8n node structures key metrics like viewCount, likeCount, commentCount, description, and title into standardized fields.Code - Save Data To Memory n8n node cleans the description data (removing links, emojis, and unnecessary formatting) and writes the entire item object to the workflow's static memory, aggregating all accepted video data into one large JSON string.Code - Retrieve Data From Memory n8n node retrieves the aggregated string, and the Field - Response n8n node prepares this final output to be passed back to the originating parent n8n workflow.To deploy this powerful n8n workflow and start aggregating YouTube data, follow these steps:
Youtube - Get Video and the HTTP - Find Video Data n8n node.search_term parameter in its input data structure. When Executed by Another Workflow (n8n trigger): Initiates the sub-workflow when called by a parent flow, receiving search parameters.
Youtube - Get Video (n8n node): Searches the YouTube API using an input term (search_term). Crucially configured to only look at recent videos (last 48 hours) and retrieve a maximum of 3 results.
HTTP - Find Video Data (n8n node): Uses a raw HTTP request to the YouTube Data API to fetch detailed statistics and content duration, leveraging the same OAuth2 credential.
If - Longer Than 3 (n8n node): A condition n8n node that uses a custom JavaScript expression to filter videos, ensuring the duration is greater than 3.5 minutes (210 seconds).
Code - Save Data To Memory (n8n node): A custom code n8n node that sanitizes the video description (removing URLs, emojis, and line breaks) and aggregates the structured output data into the workflow's static memory for collection upon loop completion.
Field - Group Data (n8n node): A Set n8n node used to map complex API statistics fields (like items[0].statistics.viewCount) into clean, standardized variable names for easier use in subsequent n8n templates.
Deploy this advanced n8n workflow to transform YouTube playlists and videos into a searchable RAG knowledge base using Google Gemini and Qdrant. Perfect n8n template for conversational AI.

Automate fetching YouTube video comments, perform deep sentiment analysis using GPT-4o, and generate structured email reports using this powerful n8n workflow.

Deploy an advanced AI WhatsApp support agent using n8n. This n8n workflow integrates Gemini, Twilio, and a Supabase RAG knowledge base with intelligent, time-based human handoff logic.

Leverage this sophisticated n8n workflow template to find fast-moving YouTube trends using an n8n AI Agent. Automatically analyze video stats, tags, and content patterns in any niche.









































