Social · n8n

Auto-Post Twitter Threads From New YouTube Videos Using AI

When you publish a new YouTube video, this workflow uses Anthropic Claude to craft an engaging Twitter thread summarizing the content, then posts it automatically. Save hours of manual repurposing and grow your audience across platforms effortlessly.

difficulty Intermediatesetup 45 minresult Every new YouTube video you publish instantly becomes a polished, multi-tweet Twitter thread written by Claude and posted to your account.
  1. 1

    Trigger on new YouTube video

    Add a Schedule Trigger node set to run every 15 minutes. This polls your channel for new uploads. In a later step you will use an HTTP Request to call the YouTube Data API and check for videos published after the last run.

  2. 2

    Fetch latest video from YouTube

    Add an HTTP Request node. Set Method to GET and URL to https://www.googleapis.com/youtube/v3/search. Add query parameters: part=snippet, channelId=YOUR_CHANNEL_ID, maxResults=1, order=date, type=video, and key=YOUR_YOUTUBE_API_KEY. This returns the most recent video title and description.

  3. 3

    Generate Twitter thread with Anthropic Claude

    Add an HTTP Request node pointed at https://api.anthropic.com/v1/messages. Set Method to POST. In Headers add x-api-key: YOUR_ANTHROPIC_KEY and anthropic-version: 2023-06-01. In the JSON Body, set model to claude-3-haiku-20240307, max_tokens to 600, and in messages[0].content write a prompt like: Write a 5-tweet Twitter thread promoting this YouTube video. Start each tweet with a number like 1/5. Title: {{$json.items[0].snippet.title}} Description: {{$json.items[0].snippet.description}}. Store the response text in threadText.

  4. 4

    Parse thread into individual tweets

    Add a Set node. Create a field called tweets and use the expression {{ $json.content[0].text.split('\n').filter(t => t.trim().length > 0) }} to split Claude's response into an array of tweet lines. This prepares each numbered tweet for posting.

  5. 5

    Post thread to Twitter

    Add an HTTP Request node to post to Twitter. Set Method to POST and URL to https://api.twitter.com/2/tweets. Use OAuth 1.0 credentials for your Twitter app. Set the JSON body to { "text": "{{ $json.tweets[0] }}" }. Note: For a full thread you would loop and pass reply.in_reply_to_tweet_id; for simplicity this posts the first tweet. Upgrade to a Code node loop for all tweets.

Frequently asked questions

Why do I need a paid Twitter API plan?

Twitter's free API tier removed write access in 2023. The Basic plan at $100/month is the minimum tier that allows posting tweets programmatically. Check developer.twitter.com for the latest pricing.

How do I avoid posting the same video twice?

Add a Google Sheets or Airtable node after the YouTube fetch step to check if the video ID has already been processed. If it has, stop the workflow with an IF node. If it hasn't, add it to the sheet and continue.

Can I use a different AI model instead of Claude?

Yes. Replace the Anthropic HTTP Request node with a call to OpenAI's chat completions endpoint or use n8n's built-in OpenAI node. The prompt structure remains the same — just swap the endpoint and API key.

About this recipe. Recipes on FlowRecipesHub are written for business owners, not developers, and are tested before publishing — how recipes get made. Some ingredient links are affiliate links that cost you nothing — full disclosure.