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.
- 1
Trigger on new YouTube video
Add a
Schedule Triggernode 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
Fetch latest video from YouTube
Add an
HTTP Requestnode. Set Method toGETand URL tohttps://www.googleapis.com/youtube/v3/search. Add query parameters:part=snippet,channelId=YOUR_CHANNEL_ID,maxResults=1,order=date,type=video, andkey=YOUR_YOUTUBE_API_KEY. This returns the most recent video title and description. - 3
Generate Twitter thread with Anthropic Claude
Add an
HTTP Requestnode pointed athttps://api.anthropic.com/v1/messages. Set Method toPOST. In Headers addx-api-key: YOUR_ANTHROPIC_KEYandanthropic-version: 2023-06-01. In the JSON Body, setmodeltoclaude-3-haiku-20240307,max_tokensto600, and inmessages[0].contentwrite 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 inthreadText. - 4
Parse thread into individual tweets
Add a
Setnode. Create a field calledtweetsand 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
Post thread to Twitter
Add an
HTTP Requestnode to post to Twitter. Set Method toPOSTand URL tohttps://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 passreply.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.