VideoStats icon
If icon
DiscordIncomingWebhook icon
Log icon
Schedule icon

Celebrate YouTube View Milestones in Discord

Watch a YouTube video's view count with Kestra. A daily check compares views against a milestone threshold and celebrates in Discord when it crosses.

Categories
Business

A view milestone is a marketing moment, but only if you notice it the day it happens. This blueprint points io.kestra.plugin.youtube.VideoStats at a single hero video once a day, compares the returned view count against a milestone threshold with an If task, and posts a Discord celebration the first morning the number crosses the line, current views, likes, and comments included. Until then, each run leaves a quiet log line, so the execution history doubles as a day-by-day growth record.

How it works

  1. The video_id and view_threshold inputs define which video to watch and what number counts as the milestone, both editable at execution time.
  2. fetch_stats (io.kestra.plugin.youtube.VideoStats) calls the YouTube Data API with the OAuth2 access token for the single video, with snippet metadata enabled so the title travels with the numbers. The output exposes the video at videos[0] with scalar viewCount, likeCount, commentCount, and title fields.
  3. check_milestone (io.kestra.plugin.core.flow.If) casts videos[0].viewCount to a number and compares it against the threshold.
  4. On breach, celebrate posts a Discord message with the scalar stats and the marketing follow-ups the milestone unlocks. Below the threshold, log_progress records today's count in the logs.
  5. The errors block posts a distinct Discord alert when the check fails, and a disabled-by-default Schedule trigger runs the watch every morning at 09:00.

What you get

  • A same-day celebration instead of discovering the milestone a week late in YouTube Studio.
  • The view, like, and comment counts interpolated into the message, so the announcement carries its own proof.
  • A daily log line while the milestone is still ahead, turning run history into a growth chart.
  • A failure alert so an expired token never lets the crossing slip past silently.

Who it's for

  • Marketing teams timing case studies, ads, and social posts to a launch video's milestone.
  • Developer relations teams tracking a flagship tutorial or conference talk toward a round number.
  • Anyone who has ever noticed a milestone three days after the fact and lost the moment.

Why orchestrate this with Kestra

The YouTube Data API returns the view count, but a milestone watch needs someone to ask daily, remember the threshold, branch on the answer, and tell the team at the right moment. Kestra declares all of that in one flow, the schedule, the comparison, the two branches, and the failure alert, with every daily check preserved in execution history.

Prerequisites

  • A Google Cloud project with the YouTube Data API v3 enabled.
  • An OAuth2 access token with YouTube read scope. Pair this flow with the YouTube token refresh blueprint to keep the token fresh.
  • A Discord incoming webhook in the channel where the celebration should land.

Secrets

  • YOUTUBE_ACCESS_TOKEN: OAuth2 bearer token for the YouTube Data API.
  • DISCORD_WEBHOOK_URL: Discord incoming webhook URL.

Quick start

  1. Add the two secrets to your Kestra namespace.
  2. Replace the default video_id with your hero video and set view_threshold to the next milestone.
  3. Execute the flow once and confirm the log line or the celebration, depending on where the count stands.
  4. Set disabled: false on the daily trigger.

How to extend

  • After a celebration, update view_threshold to the next round number and keep the watch running.
  • Add a task in the then branch that creates a ticket or drafts the milestone social post automatically.
  • Watch several videos by looping the flow over a list with a subflow per video ID.
  • Swap Discord for Slack, Teams, or email with the corresponding notification task.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.