Quick Overview
This workflow accepts a YouTube video URL via Telegram, pulls the video metadata and top 100 comments using the YouTube Data API, analyzes audience sentiment and themes with Google Gemini, generates new video ideas, logs the report to Google Sheets, and replies with the results in Telegram.
How it works
- Triggers when a Telegram bot receives a message containing a YouTube video URL.
- Validates the URL, extracts the video ID, and replies in Telegram with an error if the URL is invalid.
- Calls the YouTube Data API to fetch the video’s details and the top 100 most relevant comment threads.
- Cleans the comment list by extracting key fields, removing empty entries, and deduplicating by comment text.
- Sends the video metadata and aggregated comments to Google Gemini to produce a structured audience analysis including sentiment, repeated questions, and scored content opportunities.
- Uses Google Gemini again to generate exactly seven new video ideas based on the top repeated questions and highest-scoring opportunities.
- Appends the final report to Google Sheets and sends a formatted summary back to the requester in Telegram.
Setup
- Create/connect a Telegram bot credential in n8n and start a chat with the bot so it can receive messages.
- Add a YouTube Data API key and replace the placeholder values in both YouTube HTTP requests (video details and commentThreads).
- Add Google Gemini (Google PaLM) API credentials for the two Gemini chat model nodes.
- Connect Google Sheets using a Google Service Account, share the target spreadsheet with that service account, and select the document and sheet to append results to.
- Review the Telegram reply formatting and ensure the workflow sends the response to the incoming chat ID.