n8n

How to Automate YouTube Topic Discovery?

Find trending YouTube topics fast with a chat that acts like your research assistant. Share your niche and get a short list of recent videos with stats you can trust. It suits creators and marketers who plan content each week.

A chat message triggers an AI agent that checks if you set a niche. The agent calls a YouTube search tool that scans the last two days in the US with safe search and picks the top three results. The flow loops through each video, pulls full details from the official API, and keeps only videos longer than three minutes. It stores the best picks in memory and returns a clean summary back to the chat. The system uses OpenAI for language, YouTube for search, a loop for batching, and code nodes to keep the final list in workflow memory.

Connect OpenAI and your YouTube account, add a Google API key, and tune the filters if needed. Expect research time to drop from about one hour to a few minutes while keeping data consistent. Use it for quick topic validation, weekly content planning, or finding angles that match your niche. You can also adjust the minimum video length, date window, or region to fit your channel strategy.

What are the key features?

  • Chat message trigger starts a guided conversation that asks for the niche before searching.
  • AI agent powered by OpenAI handles natural language and tool calling.
  • Tool workflow passes a search term using a defined JSON schema for stable input.
  • YouTube search limits results to the last two days in the US and returns up to three items.
  • HTTP request fetches content details, snippet, and statistics for each video ID.
  • If filter keeps only videos longer than three minutes to avoid shorts.
  • Split in batches loops through results safely and controls flow.
  • Code nodes store and retrieve the final list from workflow memory for clean output.
  • Window buffer memory preserves chat context across messages.

What are the benefits?

  • Reduce manual research from 60 minutes to 5 minutes
  • Find fresh topics posted in the last 48 hours
  • Exclude short videos under 3 minutes to focus on long form ideas
  • Pull accurate view and like counts from the official API
  • Keep context in one chat thread for faster follow ups
  • Connect OpenAI and YouTube in one workspace

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with OpenAI and YouTube. See the Tools Required section above for links to create accounts with these services.
  3. Open the LLM Chat OpenAI node. In the Credential to connect with menu, click Create new credential and paste your OpenAI API key from your OpenAI account. Save the credential and select it.
  4. Open the YouTube node named get_videos1. In the Credential field, click Create new credential and sign in with your Google account to grant YouTube Data API access. Save and select the credential.
  5. Create a Google API key for YouTube Data API v3 in your Google Cloud Console. In n8n Cloud, add an environment variable named GOOGLE_API_KEY with this key, then restart your n8n instance so the HTTP Request node can read it.
  6. Open the Tool Workflow node named youtube_search. Confirm the input schema uses search_term and that the linked workflow ID points to the YouTube search workflow.
  7. Review the YouTube search settings in get_videos1. Confirm Region US, published after the last two days, safe search moderate, and limit 3. Adjust these values to match your market.
  8. Open the If node labeled if_longer_than_3_. Adjust the minimum duration rule if you want a different cutoff for video length.
  9. Check the AI Agent system message to confirm it asks for a niche if the user did not provide one. Update wording if needed.
  10. Activate the workflow and open the n8n AI Chat interface. Send a message with your niche, for example fitness, and ask for trending videos.
  11. Go to Executions and review outputs from group_data1 and response1. Verify each item includes id, viewCount, and other stats, and that the chat returns a clean list.
  12. Troubleshoot common issues: if no results, broaden the query or widen the date range; if quota errors appear, check your Google Cloud YouTube API quota; if the HTTP Request fails, confirm the GOOGLE_API_KEY is set and valid; if the chat does not fire, make sure the workflow is active.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

OpenAI

Sign up

Pay-as-you-go: GPT-5 at $1.25 per 1M input tokens and $10 per 1M output tokens

YouTube

Sign up

Free: $0, default quota 10,000 units/day

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.