🎬 Summarize YouTube video transcripts in Discord with Gemini and Supabase

⚑ 21 views · 🎬 Content Creation & Video

πŸ’‘ Pro Tip β€” YouTube’s API quotas can be a bottleneck when you’re pulling data at scale. ScraperNode is a community node with dedicated scrapers for channels, videos, and comments β€” no quota limits, just structured data.

View All Scrapers

Description

YouTube Video Transcript Summarizer β€” Discord Bot

> Paste a YouTube URL into a Discord channel and this workflow automatically extracts the transcript, uses an LLM to generate a concise summary, and stores everything in a database β€” all in seconds.

> Self-hosted n8n only. This workflow uses the Execute Command node to run yt-dlp inside the n8n container. This requires shell access, which is only available on self-hosted instances (Docker, VPS, etc.) β€” it will not work on n8n Cloud.

Import this workflow into n8n


Prerequisites

ToolPurpose
Discord BotListens for messages and sends replies
yt-dlpDownloads subtitles and video metadata (must be installed in the n8n container)
Google Gemini APISummarizes video transcripts (Gemini 2.5 Flash)
SupabaseStores video data and run logs

Credentials

NodeCredential TypeNotes
Discord TriggerDiscord Bot TriggerBot token with Message Content Intent enabled
Discord Reply / Discord Not YouTube Reply / Discord Error ReplyDiscord BotSame bot, used for sending messages
Message a model (Gemini)Google Gemini (PaLM) APIAPI key from Google AI Studio
Save to Supabase / Log Run / Log Run ErrorSupabaseProject URL + anon key

What It Does

When a user pastes a YouTube URL into a Discord channel, the workflow:

  1. Detects the YouTube URL using RegEx (supports youtube.com, youtu.be, shorts, live)
  2. Extracts the video’s subtitles (English and Vietnamese) and metadata using yt-dlp
  3. Cleans the raw VTT subtitle file into plain-text transcript
  4. Summarizes the transcript using an LLM (Gemini 2.5 Flash) into a TLDR + detailed summary (in the original language)
  5. Stores the video metadata, full transcript, and AI summary in a Supabase database
  6. Logs every run (success or error) to a separate runs table for tracking
  7. Chunks long summaries into Discord-safe messages (≀2000 characters each)
  8. Replies in Discord with the video title, stats, and the full summary

Non-YouTube messages get a friendly β€œnot a YouTube link” reply. Errors are caught, classified, logged to the database, and reported back to Discord.


How It Works

Main Flow (Happy Path)

Discord Trigger β†’ Extract YouTube URL β†’ Is YouTube URL?
  β”œβ”€ Yes β†’ yt-dlp Get Metadata β†’ Parse Metadata β†’ Read Subtitle File β†’ Parse Transcript
  β”‚        β†’ Message a model (Gemini) β†’ Prepare Insert Data β†’ Save to Supabase
  β”‚        β†’ Prepare Success Log β†’ Log Run β†’ Prepare Messages for Discord β†’ Discord Reply
  └─ No  β†’ Discord Not YouTube Reply

Error Flow

Error Trigger β†’ Prepare Error Data β†’ Log Run Error β†’ Discord Error Reply

Node Breakdown

#NodeTypeDescription
1Discord TriggerDiscord Bot TriggerFires on every message in the configured channel
2Extract YouTube URLCodeRegEx extracts video ID from message content
3Is YouTube URL?IFRoutes YouTube URLs to processing, others to rejection reply
4yt-dlp Get MetadataExecute CommandDownloads subtitles (.vtt, English/Vietnamese) and prints metadata JSON
5Parse MetadataCodeExtracts title, channel, views, duration via RegEx; decodes Unicode for multi-language support
6Read Subtitle FileExecute CommandDynamically finds and reads the .vtt file (continueOnFail enabled)
7Parse TranscriptCodeStrips VTT timestamps/tags, deduplicates lines
8Message a modelGoogle GeminiSends transcript to Gemini 2.5 Flash for TLDR + detailed summary (in original language)
9Prepare Insert DataCodeMerges summary with all metadata fields
10Save to SupabaseSupabaseInserts full record into videos table
11Prepare Success LogCodeBuilds success run record
12Log RunSupabaseInserts into runs table
13Prepare Messages for DiscordCodeChunks long summaries into Discord-safe messages (≀2000 chars)
14Discord ReplyDiscordPosts summary preview to channel
15Discord Not YouTube ReplyDiscordReplies when message isn’t a YouTube link
16Error TriggerError TriggerCatches any unhandled node failure
17Prepare Error DataCodeClassifies error type and extracts context
18Log Run ErrorSupabaseLogs error to runs table
19Discord Error ReplyDiscordPosts error message to channel

Setup Guide

1. Discord Bot

  1. Go to the Discord Developer Portal
  2. Create a new Application β†’ Bot
  3. Enable Message Content Intent under Privileged Intents
  4. Copy the Bot Token
  5. Invite the bot to your server with Send Messages + Read Messages permissions
  6. In n8n, create a Discord Bot Trigger credential (for listening) and a Discord Bot credential (for sending replies)
  7. Update the guild ID and channel ID in the Discord Trigger node and all Discord reply nodes

2. yt-dlp

yt-dlp must be installed in your n8n container. For Docker-based installs:

docker exec -it n8n apk add --no-cache python3 py3-pip
docker exec -it n8n pip3 install yt-dlp

Optional: Place a cookies.txt file at /home/node/.n8n/cookies.txt to avoid age-gated or bot-detection issues.

3. Google Gemini API

  1. Go to Google AI Studio
  2. Click Create API Key and copy it
  3. In n8n, click the Gemini node β†’ Credential β†’ Create New
  4. Paste your API key and save

4. Supabase

  1. Create a project at supabase.com
  2. Go to Settings β†’ API and copy the URL and anon key
  3. In n8n, create a Supabase credential with your URL and API key
  4. Run the SQL below in the Supabase SQL Editor to create the required tables

Supabase SQL

-- Videos table: stores video metadata, transcript, and AI summary
CREATE TABLE videos (
  video_id TEXT PRIMARY KEY,
  title TEXT,
  channel TEXT,
  upload_date TEXT,
  duration INT,
  view_count INT,
  description TEXT,
  transcript TEXT,
  ai_summary TEXT,
  thumbnail_url TEXT,
  channel_id TEXT,
  date_added TIMESTAMPTZ DEFAULT now()
);

-- Runs table: logs every workflow execution (success or error)
CREATE TABLE runs (
  video_id TEXT PRIMARY KEY,
  process_status TEXT NOT NULL,
  error_type TEXT,
  notes TEXT,
  date_added TIMESTAMPTZ DEFAULT now()
);

πŸ”— Nodes Used

Discord, Supabase, Google Gemini

πŸ“₯ Import

Download workflow.json and import into n8n: Workflow menu β†’ Import from File

πŸ“– Importing guide Β· πŸ”‘ Credential setup