Generate AI YouTube comments and replies from a video URL using GPT-4 and Google Sheets

How it works

A form trigger accepts any YouTube URL: youtube.com/watch?v=ID, youtu.be/ID, youtube.com/embed/ID, or just a plain video ID A code node normalises the URL and extracts a clean video ID for the YouTube Data API v3 Calls the API to fetch video stats (title, description, tags, views, likes, comment count) Fetches comments from the videos commentThreads endpoint, capped by the form's Max Comments to Process field Flattens each comment into its own item, then merges two ranked lists deduped by commentId: the 5 newest comments by publishedAt and the 5 highest-engagement comments by likes plus replies A GPT-4 agent writes a natural, human-sounding reply for each top comment, responding as a fellow viewer (not as the channel owner) In parallel, a second GPT-4 agent writes one original top-level comment based on the videos title and description A structured output parser guarantees clean JSON for both agents Replies are merged with the top-level comment by videoId, normalised into row shape, and appended to Google Sheets - one row per reply

Set up steps

Setup takes about 5 to 10 minutes Connect a YouTube Data API OAuth2 credential (used by both the Get Video Statistics and Get Video Comments nodes) Connect an OpenAI API credential (defaults to gpt-4.1-mini; swap to any model you prefer) Connect a Google Sheets OAuth2 credential and pick your destination spreadsheet plus tab in the Save to Google Sheets node Create a tab with these column headers in row 1: videoId, videoUrl, videoTitle, commentAuthor, commentText, myReply, myVideoComment, selectionType, videoTags, viewCount, engagementScore, videoDescription, likeCount, commentCount Optional: tweak the system prompts inside each AI agent to match your niche, voice, and brand Submit a YouTube URL via the form trigger to test Detailed per-step notes live inside the workflow as sticky notes

0
Downloads
0
Views
8.43
Quality Score
intermediate
Complexity
Author:Alena - Prodigy AI Sol(View Original β†’)
Created:4/28/2026
Updated:4/28/2026

πŸ”’ Please log in to import templates to n8n and favorite templates

Workflow Visualization

Loading...

Preparing workflow renderer

Comments (0)

Login to post comments