Skip to main content

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

Workflow preview

Workflow preview
100%
Generate AI YouTube comments and replies from a video URL using GPT-4 and Google Sheets preview
Open on n8n.io

1. Workflow Overview

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...

Best for

  • Social Media automation workflows
  • Multimodal AI automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.formtrigger, n8n-nodes-base.code, n8n-nodes-base.httprequest, n8n-nodes-base.set, @n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.lmchatopenai, @n8n/n8n-nodes-langchain.outputparserstructured, n8n-nodes-base.merge

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Alena - Prodigy AI Sol.

Original n8n.io source

1.1 Workflow description

Title
Generate AI YouTube comments and replies from a video URL using GPT-4 and Google Sheets
Workflow name
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

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Video URL Input Form

Type / Role
n8n-nodes-base.formTrigger - formTrigger
Config choices
Version 2.2

Block 2 - Extract Video ID from URL

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 3 - Get Video Statistics

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.3

Block 4 - Format Video Data

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 5 - Get Video Comments

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.3

Block 6 - Extract Comments

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 7 - Process Each Comment

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 8 - Select Top 10 Comments

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 9 - Comment Response Generator

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 3

Block 10 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.3

Block 11 - Structured Output Parser

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.3

Block 12 - Add VideoId to Replies

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 13 - Video Comment Generator

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 3

Block 14 - Video Comment Parser

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.3

Block 15 - Add VideoId to VideoComments

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 16 - Merge Wait for Video Comment

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.1

Block 17 - Prepare Sheet Data

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 18 - Save to Google Sheets

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.7

Block 19 - Sticky Note 0001

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 20 - Sticky Note 0002

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 21 - Sticky Note 0003

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 22 - Sticky Note 0004

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 23 - Sticky Note 0005

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 24 - Sticky Note 0006

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Showing the first 24 of 25 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Generate AI YouTube comments and replies from a video URL using GPT-4 and Google Sheets
Complexity advanced
Nodes 25
Categories Social Media, Multimodal AI
Author Alena - Prodigy AI Sol
Published 20 Apr 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/15175/15175.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

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

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...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Social Media, Multimodal AI use case.