VideoTrigger icon
If icon
Exit icon
Set icon
OAuth2 icon
VideoStats icon
LoopUntil icon
Request icon
Download icon
ChatCompletion icon
Anthropic icon
Parallel icon
Write icon
SlackIncomingWebhook icon
Loop icon
Pause icon

YouTube Video Repurposing Pack with AI

Turn each new YouTube upload into chapters, an SEO description, an X thread, a LinkedIn post and a newsletter draft with captions, Claude and Kestra.

Categories
AIBusiness

Publishing the video is only half the job. Creators then spend hours writing chapters and an SEO description, and turning the same ideas into posts for X, LinkedIn and their newsletter. This blueprint does that groundwork every time you upload. It waits for the video's captions, condenses the transcript into a factual brief, and drafts each format in parallel. You get the drafts in Slack to review and copy, plus one Markdown file holding the whole pack. Optionally, after you approve, it writes the new description and chapters straight to the video. Nothing changes on YouTube without that approval.

How it works

  1. The on_new_upload trigger (io.kestra.plugin.youtube.VideoTrigger) polls your channel every 5 minutes and starts an execution for each new upload, including unlisted ones, since it reads your uploads with your own token. Each poll looks back over the interval plus 5 minutes, so dedupe_trigger_runs records the video ID in the KV store (yt_pack_<videoId>, kept for 30 days) and stops any later run for the same video. For manual runs and backfills, pass a video_id instead; manual runs are never skipped.
  2. get_token (io.kestra.plugin.youtube.OAuth2) exchanges your refresh token for an access token, and video_details (io.kestra.plugin.youtube.VideoStats) reads the title, description and duration.
  3. wait_for_captions (io.kestra.plugin.core.flow.LoopUntil) checks the YouTube captions API every 15 minutes for up to 6 hours. YouTube's auto-generated captions are often not ready the moment a video goes live, so this lets the flow wait without failing. It gets a new token on every check.
  4. list_captions and download_transcript (io.kestra.plugin.core.http.Download) fetch the captions as SRT, preferring a human-made track over the auto-generated one. The timestamps are what make accurate chapters possible.
  5. content_brief (io.kestra.plugin.ai.completion.ChatCompletion with Claude Opus 5.5 through the Anthropic provider) turns the transcript into a brief: summary, key points, chapters, verbatim quotes and keywords. The model is told to use only what is said in the video.
  6. drafts (io.kestra.plugin.core.flow.Parallel) writes four drafts from that brief at the same time: a YouTube description with chapters, an X thread, a LinkedIn post and a newsletter section, all in your brand_voice.
  7. save_pack (io.kestra.plugin.core.storage.Write) stores everything as one Markdown file, exposed as the content_pack flow output. announce_pack and post_drafts (io.kestra.plugin.core.flow.Loop) post the drafts to Slack, one message per format, in a fixed order.
  8. With apply_to_youtube: true, publish_to_youtube asks for approval in Slack and pauses (io.kestra.plugin.core.flow.Pause) for up to 24 hours. When you resume the execution, it re-reads the video's current snippet and calls videos.update with the new description. The title, category, tags and default language are sent back unchanged, because the update replaces the whole snippet. YouTube turns the 00:00 lines into chapters. If nobody approves, the execution is cancelled and the video is left alone.
  9. If anything fails, for example no captions within 6 hours or a revoked token, alert_failure posts to Slack.

What you get

  • A YouTube description with chapters taken from real transcript timestamps, either to paste into YouTube Studio or written to the video for you after approval.
  • Drafts for X, LinkedIn and your newsletter, all written from the same brief and in the same voice.
  • One Markdown file per video with the brief and every draft, downloadable from the execution's Outputs tab.
  • The SRT transcript saved as a second output, for subtitles, blog posts or search.
  • A pipeline that waits for captions instead of failing, and processes each upload once even though polls overlap.

Who it's for

  • YouTube creators and small media teams who repurpose every video by hand today.
  • Developer advocates and course creators who publish tutorials and want chapters and social posts for each one.
  • Agencies running content for several channels, with one flow per channel.

Why orchestrate this with Kestra

The hard parts here are not the prompts. They are waiting hours for captions without holding a process open, refreshing short-lived OAuth tokens, writing four drafts at once, and keeping every output tied to the video it came from. Kestra handles the waiting with LoopUntil, runs the drafts with Parallel, keeps secrets out of the flow, and records each run with its transcript and pack as downloadable outputs. If one draft fails, you can replay just that task, and swapping Claude for another provider is a single provider change.

Prerequisites

  • A YouTube channel. Captions can only be downloaded for your own videos, so use one of your own video IDs when testing.
  • A Google Cloud project with the YouTube Data API v3 enabled and an OAuth client. Generate a refresh token with the https://www.googleapis.com/auth/youtube.force-ssl scope, which the captions download requires.
  • An Anthropic API key from the Claude Console (console.anthropic.com), created inside a workspace. A key that isn't scoped to a workspace is rejected because Kestra can't send the anthropic-workspace-id header.
  • A Slack incoming webhook for the review channel.
  • For the trigger: a fresh access token in the namespace KV store under YOUTUBE_ACCESS_TOKEN. The youtube-token-refresh blueprint does this. Schedule it at least every 45 minutes (for example */45 * * * *), since access tokens expire after an hour.

Secrets

  • YOUTUBE_CLIENT_ID: OAuth client ID from Google Cloud.
  • YOUTUBE_CLIENT_SECRET: OAuth client secret.
  • YOUTUBE_REFRESH_TOKEN: refresh token for your channel, granted the youtube.force-ssl scope.
  • ANTHROPIC_API_KEY: Anthropic API key used for the brief and the drafts.
  • SLACK_WEBHOOK_URL: Slack incoming webhook that receives the drafts and failure alerts.

Inputs

  • video_id (STRING, optional, no default): video to process on manual runs. Trigger runs use the detected upload instead.
  • brand_voice (STRING, default Friendly and practical, plain language, no hype, no emojis.): tone applied to every draft.
  • apply_to_youtube (BOOL, default false): after approval, replace the video's description with the generated one, which adds chapters. Leave it off to only receive drafts. To enable it for uploads detected by the trigger, change the default.

Outputs

  • {{ outputs.content_pack }} (flow output) / {{ outputs.save_pack.uri }}: Markdown file with the brief and all four drafts.
  • {{ outputs.transcript }} (flow output) / {{ outputs.download_transcript.uri }}: the SRT transcript.
  • {{ outputs.content_brief.textOutput }}: the brief (summary, key points, chapters, quotes, keywords).
  • {{ outputs.seo_description.textOutput }}, {{ outputs.x_thread.textOutput }}, {{ outputs.linkedin_post.textOutput }}, {{ outputs.newsletter.textOutput }}: the individual drafts.
  • {{ outputs.content_brief.tokenUsage }}: tokens used for the brief, useful for tracking cost.
  • {{ fromJson(outputs.current_snippet.body).items[0].snippet.description }}: the video's description before the write-back, kept for rollback.

Quick start

  1. Create the five secrets above.
  2. Save the flow and run it with video_id set to one of your own captioned videos. The run finishes in under a minute when captions already exist.
  3. Review the drafts in Slack, and download content_pack from the execution's Outputs tab. To have the description and chapters written to the video, run with apply_to_youtube: true and resume the execution when Slack asks for approval.
  4. To automate it, set channelId on the trigger to your channel ID (it starts with UC), schedule youtube-token-refresh every 45 minutes, and remove disabled: true from the trigger.

How to extend

  • Post the thread to Bluesky with io.kestra.plugin.bluesky.BlueskyTemplate after approval.
  • Put the draft social posts through the same approval and publish them after approve_publish, for example with io.kestra.plugin.x.XTemplate.
  • Add formats such as a blog post, Instagram caption or Shorts script by adding a branch under drafts and its id to post_drafts.
  • Prefer a caption language by changing the jq filter in download_transcript, for example to select .snippet.language == "en" first.
  • Save packs to Notion or Google Drive instead of Slack for a content calendar.
  • Lower the cost by setting claude_model to claude-sonnet-5-5 or claude-haiku-4-5, or swap in OpenAI, Gemini, Mistral or a local Ollama model by changing provider.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.