{
  "name": "YouTube Description to Tweet Thread",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "yt-to-tweets",
        "responseMode": "lastNode",
        "options": {}
      },
      "id": "ydtt0001-0001-4000-8000-000000000001",
      "name": "Receive Video URL Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [240, 300]
    },
    {
      "parameters": {
        "resource": "video",
        "operation": "get",
        "videoId": "={{ $json.body.videoId }}",
        "fields": "snippet,statistics",
        "options": {}
      },
      "id": "ydtt0001-0002-4000-8000-000000000002",
      "name": "Fetch YouTube Video Data",
      "type": "n8n-nodes-base.youTube",
      "typeVersion": 1,
      "position": [460, 300]
    },
    {
      "parameters": {
        "resource": "text",
        "operation": "message",
        "modelId": {
          "__rl": true,
          "value": "gpt-4o",
          "mode": "list"
        },
        "messages": {
          "values": [
            {
              "content": "Convert this YouTube video information into an engaging tweet thread. Create exactly 5 tweets numbered 1/5 through 5/5. Tweet 1 should hook readers and mention the video title. Tweets 2-4 should each highlight a key insight from the description. Tweet 5 should be a call-to-action with the video URL. Each tweet must be under 280 characters including the numbering. Return as a JSON array of strings.\n\nVideo title: {{ $json.snippet.title }}\nDescription: {{ $json.snippet.description }}\nVideo URL: https://youtube.com/watch?v={{ $('Receive Video URL Webhook').item.json.body.videoId }}"
            }
          ]
        },
        "options": {
          "temperature": 0.6,
          "responseFormat": "json_object"
        }
      },
      "id": "ydtt0001-0003-4000-8000-000000000003",
      "name": "Generate Tweet Thread",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1,
      "position": [680, 300]
    },
    {
      "parameters": {
        "jsCode": "const content = JSON.parse($input.item.json.message.content);\nconst tweets = content.tweets || content;\nconst tweetArray = Array.isArray(tweets) ? tweets : Object.values(tweets);\nreturn tweetArray.map((text, i) => ({ json: { tweet_text: String(text), position: i + 1, total: tweetArray.length, video_title: $('Fetch YouTube Video Data').item.json.snippet.title } }));"
      },
      "id": "ydtt0001-0004-4000-8000-000000000004",
      "name": "Split into Tweet Items",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [900, 300]
    },
    {
      "parameters": {
        "text": "={{ $json.tweet_text }}",
        "additionalFields": {}
      },
      "id": "ydtt0001-0005-4000-8000-000000000005",
      "name": "Post Each Tweet",
      "type": "n8n-nodes-base.twitter",
      "typeVersion": 2,
      "position": [1120, 300]
    }
  ],
  "connections": {
    "Receive Video URL Webhook": {
      "main": [[{ "node": "Fetch YouTube Video Data", "type": "main", "index": 0 }]]
    },
    "Fetch YouTube Video Data": {
      "main": [[{ "node": "Generate Tweet Thread", "type": "main", "index": 0 }]]
    },
    "Generate Tweet Thread": {
      "main": [[{ "node": "Split into Tweet Items", "type": "main", "index": 0 }]]
    },
    "Split into Tweet Items": {
      "main": [[{ "node": "Post Each Tweet", "type": "main", "index": 0 }]]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "meta": {},
  "pinData": {}
}
