Auto-generate YouTube chapters with Gemini AI & YouTube Data API v3
$20/month : Unlimited workflows
2500 executions/month
THE #1 IN WEB SCRAPING
Scrape any website without limits
HOSTINGER 🎉 Early Black Friday Deal
DISCOUNT 20% Try free
DISCOUNT 20%
Self-hosted n8n
Unlimited workflows - from $4.99/mo
#1 hub for scraping, AI & automation
6000+ actors - $5 credits/mo
Auto-Generate YouTube Chapters with AI-Powered Transcript Analysis
Overview
This workflow uses YouTube Data API v3 and Google Gemini 1.5 Flash AI to automatically generate timestamped chapters for videos by analyzing SRT captions. It enhances viewer navigation, improves SEO , and saves creators time by automating manual tasks.
Prerequisites
YouTube API Setup
Create a Google Cloud Project
- Go to the Google Cloud Console.
- Click Select a project > New Project and name it (e.g., "YouTube Chapters Automation") .
Enable YouTube Data API v3
- Navigate to APIs & Services > Library.
- Search for "YouTube Data API v3" and click Enable .
Configure OAuth Consent Screen
- Go to APIs & Services > OAuth consent screen.
- Select External (public) or Internal (testing), then add required details (app name, support email) .
Generate OAuth 2.0 Credentials
- Under Credentials, click Create Credentials > OAuth client ID.
- Choose Web app, then download the JSON key file .
Add Credentials to n8n
Other Requirements
- Google Gemini API: Configure access for the
gemini-1.5-flash-8b-exp-0924model by getting the api key.
Workflow Steps
Set Video ID
- Input the target video ID (e.g.,
r1wqsrW2vmE) using theSet Video IDnode.
- Input the target video ID (e.g.,
Fetch Video Metadata
- Use the YouTube API node to retrieve the video’s title, category, and existing description .
Download SRT Captions
- Get Caption ID: Call
https://www.googleapis.com/youtube/v3/captionsto fetch the caption track ID . - Download Transcript: Use the ID to retrieve SRT data via
https://www.googleapis.com/youtube/v3/captions/{{ID}}?tfmt=srt.
- Get Caption ID: Call
Analyze Transcript with Gemini AI
- Process the SRT file with Google Gemini AI to identify chapters using a prompt like:
"Classify this transcript into timestamped chapters (e.g., 00:00 - Introduction)." - Validate output with a structured parser (e.g.,
Structured Captionsnode) .
- Process the SRT file with Google Gemini AI to identify chapters using a prompt like:
Update Video Description
- Append chapters to the description using the YouTube API’s
videos.updatemethod .
- Append chapters to the description using the YouTube API’s
Value Proposition
- Viewer Experience: Chapters improve navigation and reduce drop-off rates .
- SEO Benefits: Structured descriptions enhance search visibility .
- Time Savings: Eliminates manual chapter creation .