{
  "name": "YouTube to Viral Shorts Clipper",
  "nodes": [
    {
      "parameters": {
        "content": "## Publish Videos",
        "height": 1080,
        "width": 600,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1120,
        -700
      ],
      "id": "9ca20dd1-3c9e-4062-b89d-32147dbc7fd7",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## Schedule Videos",
        "height": 220,
        "width": 1000,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1160,
        -940
      ],
      "id": "c0fcaf15-fde9-4059-a060-3d5984e777ff",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "## YouTube to Short Videos",
        "height": 400,
        "width": 1380,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -240,
        -1120
      ],
      "id": "29e5e0d4-6445-4a1e-a4a0-e99ece5c6be3",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "content": "## Get YouTube Video",
        "height": 240,
        "width": 280
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -560,
        -1080
      ],
      "id": "d43549cb-ff4d-4b0d-ada5-ed4c4c53cdc0",
      "name": "Sticky Note3"
    },
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.2,
      "position": [
        -540,
        -1000
      ],
      "id": "7fb2dff9-6fef-44aa-a154-462db1c42ba9",
      "name": "Telegram Trigger",
      "webhookId": "3b7af581-5793-479a-9732-eef6fd5cc646",
      "credentials": {
        "telegramApi": {
          "id": "9q2BHsi4GHHRuvvv",
          "name": "Telegram account 27"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const message = $input.first().json.message.text;\nconst chatId = $input.first().json.message.chat.id;\n\n// Split by space to get URL and number\nconst parts = message.trim().split(/\\s+/);\n\n// Find the URL part\nconst urlPart = parts.find(part => part.includes('youtube.com') || part.includes('youtu.be'));\n\n// Find the number part\nconst numberPart = parts.find(part => /^\\d+$/.test(part));\n\nif (urlPart && numberPart) {\n  const number = parseInt(numberPart);\n  \n  // Validate number range\n  if (number >= 1 && number <= 10) {\n    return [{\n      json: {\n        action: 'process',\n        'YouTube URL': urlPart,\n        'How many shorts to generate?': number,\n        chat_id: chatId\n      }\n    }];\n  } else {\n    return [{\n      json: {\n        action: 'invalid_number',\n        chat_id: chatId,\n        message: 'Please use a number between 1 and 10'\n      }\n    }];\n  }\n} else {\n  return [{\n    json: {\n      action: 'invalid_format',\n      chat_id: chatId,\n      message: 'Send: YouTube_URL Number\\nExample: https://youtu.be/abc123 5'\n    }\n  }];\n}\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -420,
        -1000
      ],
      "id": "3e4fe1c3-8e03-419c-9fa6-55d0bdf95b26",
      "name": "Split"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.klap.app/v2/tasks/video-to-shorts",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "INSERT_API_KEY"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"source_video_url\": \"{{ $json['YouTube URL'] }}\",\n  \"language\": \"en\",\n  \"target_clip_count\": {{ $json['How many shorts to generate?'] }},\n  \"max_clip_count\": {{ $json['How many shorts to generate?'] }},\n  \"editing_options\": {\n    \"captions\": true,\n    \"reframe\": true,\n    \"emojis\": true,\n    \"remove_silences\": true,\n    \"intro_title\": true\n  },\n  \"min_duration\": 15,\n  \"max_duration\": 60,\n  \"target_duration\": 30\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -180,
        -1060
      ],
      "id": "0a6bceb9-af2b-466f-be82-252ed954a16e",
      "name": "Analyse Video"
    },
    {
      "parameters": {
        "url": "=https://api.klap.app/v2/tasks/{{ $json.id }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "INSERT_API_KEY"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -20,
        -1060
      ],
      "id": "0fd793a1-8e28-449a-965b-57328e0fff0b",
      "name": "Check Status"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "65d16a85-00f2-49b7-9578-6e8dcac01f1c",
              "leftValue": "={{ $json.status }}",
              "rightValue": "ready",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        100,
        -1060
      ],
      "id": "aadeb6d8-acef-4d02-b71e-79ae6686664b",
      "name": "If"
    },
    {
      "parameters": {
        "amount": 30
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        240,
        -920
      ],
      "id": "ced6986d-d7ed-4253-b834-1b3d564c3619",
      "name": "Wait",
      "webhookId": "c1c9208c-db2d-4ffd-9d45-64b3d144059a"
    },
    {
      "parameters": {
        "url": "=https://api.klap.app/v2/projects/{{ $json.output_id }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "INSERT_API_KEY"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        240,
        -1060
      ],
      "id": "91b931be-c036-4c6a-8bec-de3ced49f6c2",
      "name": "Get Ideas"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.klap.app/v2/projects/{{ $('Check Status').item.json.output_id }}/{{ $json.id }}/exports ",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "INSERT_API_KEY"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        360,
        -1060
      ],
      "id": "8f4bb6bd-dd6c-42db-b604-d50d018ce5f0",
      "name": "Make HD Short"
    },
    {
      "parameters": {
        "url": "=https://api.klap.app/v2/projects/{{ $json.folder_id }}/{{ $json.project_id }}/exports/{{ $json.id }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "INSERT_API_KEY"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        520,
        -1060
      ],
      "id": "91cc4954-4392-45f5-8410-272e2194a98d",
      "name": "Get Final Shorts",
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "amount": 30
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        980,
        -940
      ],
      "id": "c4873c61-f834-426b-8add-7cfb167d3ab5",
      "name": "Wait1",
      "webhookId": "8d665466-8bd9-46af-9b71-3bc06f3dc1ec"
    },
    {
      "parameters": {
        "url": "=https://www.youtube.com/oembed?url={{ $('Split').first().json['YouTube URL'] }}&format=json",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        980,
        -1100
      ],
      "id": "d6ab4f27-5f39-405f-bccb-14fe3a6c1747",
      "name": "Get YT Title"
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1ZTSNqgoKqKsKrMidd1v2z6uNvFyPoIx--HJ99wyCTN4",
          "mode": "list",
          "cachedResultName": "Demo 19.6. - YouTube to Shorts Automation - autonoma.agency",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ZTSNqgoKqKsKrMidd1v2z6uNvFyPoIx--HJ99wyCTN4/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": 1908817481,
          "mode": "list",
          "cachedResultName": "Schedule",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ZTSNqgoKqKsKrMidd1v2z6uNvFyPoIx--HJ99wyCTN4/edit#gid=1908817481"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.6,
      "position": [
        1180,
        -880
      ],
      "id": "06161cdc-c48a-4026-a64d-1bd51a9100b3",
      "name": "Get Schedule",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "IP5LL0b0CC8J0Cyi",
          "name": "Google Sheets account 31"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "let postsPerDay;\nlet startHour;\nlet endHour;\n\nfor (const item of items) {\n  const setting = item.json[\"Publishing Settings\"];\n  const value = item.json[\"col_2\"];\n\n  if (setting === \"Post per Day\") {\n    postsPerDay = parseInt(value, 10);\n  } else if (setting === \"Start Time\") {\n    startHour = parseInt(value.split(\":\")[0], 10);\n  } else if (setting === \"End Time\") {\n    endHour = parseInt(value.split(\":\")[0], 10);\n  }\n}\n\nreturn [\n  {\n    json: {\n      postsPerDay,\n      startHour,\n      endHour\n    }\n  }\n];\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1320,
        -880
      ],
      "id": "b77b58d5-204c-4471-8597-d3a19ca636d1",
      "name": "Schedule Settings"
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1ZTSNqgoKqKsKrMidd1v2z6uNvFyPoIx--HJ99wyCTN4",
          "mode": "list",
          "cachedResultName": "Demo 19.6. - YouTube to Shorts Automation - autonoma.agency",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ZTSNqgoKqKsKrMidd1v2z6uNvFyPoIx--HJ99wyCTN4/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Content",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ZTSNqgoKqKsKrMidd1v2z6uNvFyPoIx--HJ99wyCTN4/edit#gid=0"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.6,
      "position": [
        1480,
        -880
      ],
      "id": "9a19467a-eb73-4dbf-aa80-b75d5ab7fbf7",
      "name": "Get Existing Schedule",
      "alwaysOutputData": true,
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "IP5LL0b0CC8J0Cyi",
          "name": "Google Sheets account 31"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Get existing scheduled posts\nconst existingPosts = $input.all();\n\n// Safe fallback: if the sheet is empty, use an empty object\nconst scheduleSettings = ($('Get Existing Schedule').first() || { json: {} }).json;\n\n// Find the latest scheduled time\nlet lastScheduledTime = new Date();\n\nif (existingPosts.length > 0) {\n  // Get all scheduled times and find the latest\n  const scheduledTimes = existingPosts\n    .map(post => new Date(post.json['Schedule Time']))\n    .filter(date => !isNaN(date))\n    .sort((a, b) => b - a); // Sort descending\n  \n  if (scheduledTimes.length > 0) {\n    lastScheduledTime = scheduledTimes[0];\n  }\n}\n\n// Pass this to the next node\nreturn [{\n  json: {\n    lastScheduledTime: lastScheduledTime.toISOString(),\n    postsPerDay: scheduleSettings.postsPerDay,\n    startHour: scheduleSettings.startHour,\n    endHour: scheduleSettings.endHour\n  }\n}];\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1640,
        -880
      ],
      "id": "58d4000b-f5f7-4fc6-ad90-b1c6f63b6feb",
      "name": "Get Last Time"
    },
    {
      "parameters": {
        "jsCode": "const postsPerDay = parseInt($('Schedule Settings').first().json.postsPerDay);\nconst startHour = parseInt($('Schedule Settings').first().json.startHour);\nconst endHour = parseInt($('Schedule Settings').first().json.endHour);\nconst lastScheduledTime = new Date($input.first().json.lastScheduledTime);\n\n// Get video data\nconst videos = $('Get Ideas').all();\nconst finalShorts = $('Get Final Shorts').all();\n\nconst now = new Date();\nconst totalHours = endHour - startHour;\nconst intervalMs = (totalHours * 60 * 60 * 1000) / postsPerDay;\n\n// Start from the day after the last scheduled post\nlet startDate = new Date(lastScheduledTime);\nstartDate.setDate(startDate.getDate() + 1);\nstartDate.setHours(startHour, 0, 0, 0);\n\n// If starting date is in the past, use tomorrow\nif (startDate < now) {\n  startDate = new Date();\n  startDate.setDate(startDate.getDate() + 1);\n  startDate.setHours(startHour, 0, 0, 0);\n}\n\nconst result = [];\nlet videoIndex = 0;\nlet currentDate = new Date(startDate);\nlet dailyPostCount = 0;\n\nwhile (videoIndex < videos.length) {\n  // Calculate time slot\n  const baseTime = new Date(currentDate);\n  baseTime.setHours(startHour + (dailyPostCount * (totalHours / postsPerDay)), 0, 0, 0);\n  \n  // Add randomness ±30 min\n  const offset = (Math.random() - 0.5) * 60 * 60 * 1000;\n  const scheduledTime = new Date(baseTime.getTime() + offset);\n  \n  // Get video data\n  const video = videos[videoIndex].json;\n  const finalShort = finalShorts[videoIndex].json;\n  \n  result.push({\n    json: {\n      scheduled_at: scheduledTime.toISOString(),\n      video_name: video.name,\n      video_virality_score: video.virality_score,\n      video_caption: video.publication_captions.youtube,\n      video_tiktok_caption: video.publication_captions.tiktok,\n      video_url: finalShort.src_url,\n      video_id: video.id\n    }\n  });\n  \n  videoIndex++;\n  dailyPostCount++;\n  \n  // Move to next day if daily limit reached\n  if (dailyPostCount >= postsPerDay) {\n    currentDate.setDate(currentDate.getDate() + 1);\n    dailyPostCount = 0;\n  }\n}\n\nreturn result;\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1800,
        -880
      ],
      "id": "65477efc-4090-49f3-a117-7a13200f5500",
      "name": "Schedule Videos"
    },
    {
      "parameters": {
        "jsCode": "return $input.all().map(item => {\n  const utc = item.json.scheduled_at;\n  const local = new Date(utc).toLocaleString(\"en-US\", {\n    timeZone: \"Europe/Berlin\",\n    timeZoneName: \"short\",\n    hour12: false\n  });\n\n  return {\n    json: {\n      ...item.json, // This includes all the video data\n      local_time: local\n    }\n  };\n});\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1940,
        -880
      ],
      "id": "b6b1403b-986a-42dc-bd85-c298dab2b1b6",
      "name": "Convert Times"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1ZTSNqgoKqKsKrMidd1v2z6uNvFyPoIx--HJ99wyCTN4",
          "mode": "list",
          "cachedResultName": "Demo 19.6. - YouTube to Shorts Automation - autonoma.agency",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ZTSNqgoKqKsKrMidd1v2z6uNvFyPoIx--HJ99wyCTN4/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Content",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ZTSNqgoKqKsKrMidd1v2z6uNvFyPoIx--HJ99wyCTN4/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Video Title": "={{ $('Get YT Title').first().json.title }}",
            "Video URL": "={{ $('Split').first().json['YouTube URL'] }}",
            "Video Clip Idea": "={{ $json.video_name }}",
            "Clip Virality Score": "={{ $json.video_virality_score }}",
            "Clip Caption": "={{ $json.video_tiktok_caption }}",
            "Clip URL": "={{ $json.video_url }}",
            "Schedule Time": "={{ $json.scheduled_at }}",
            "Schedule Time (local)": "={{ $json.local_time }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Video Title",
              "displayName": "Video Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Video URL",
              "displayName": "Video URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Video Clip Idea",
              "displayName": "Video Clip Idea",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Clip Virality Score",
              "displayName": "Clip Virality Score",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Clip Caption",
              "displayName": "Clip Caption",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Clip URL",
              "displayName": "Clip URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Schedule Time",
              "displayName": "Schedule Time",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Schedule Time (local)",
              "displayName": "Schedule Time (local)",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.6,
      "position": [
        2060,
        -880
      ],
      "id": "fa132b86-a172-44a4-b48e-c47155e41bc4",
      "name": "Save Info",
      "alwaysOutputData": true,
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "IP5LL0b0CC8J0Cyi",
          "name": "Google Sheets account 31"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://backend.blotato.com/v2/media",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "blotato-api-key",
              "value": "INSERT_API_KEY"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "=url",
              "value": "={{ $json['Clip URL'] }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1140,
        -240
      ],
      "id": "528ca673-5760-4173-8b42-6750e63caf1d",
      "name": "Upload Video"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://backend.blotato.com/v2/posts",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "blotato-api-key",
              "value": "INSERT_API_KEY"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"post\": {\n    \"accountId\": \"INSERT_ACCOUNT_ID\",\n    \"content\": {\n      \"text\": \"{{ $('Save Info').item.json['Clip Caption'] }}\",\n      \"mediaUrls\": [\n        \"{{ $json.url }}\"\n      ],\n      \"platform\": \"tiktok\"\n    },\n    \"target\": {\n      \"targetType\": \"tiktok\",\n      \"privacyLevel\": \"PUBLIC_TO_EVERYONE\",\n      \"disabledComments\": false,\n      \"disabledDuet\": false,\n      \"disabledStitch\": false,\n      \"isBrandedContent\": false,\n      \"isYourBrand\": true,\n      \"isAiGenerated\": false\n    }\n  },\n  \"scheduledTime\": \"{{ $('Save Info').item.json['Schedule Time'] }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1360,
        -640
      ],
      "id": "40b4ba79-a17d-410d-bcd3-47a4c1020900",
      "name": "TikTok"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://backend.blotato.com/v2/posts",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "blotato-api-key",
              "value": "INSERT_API_KEY"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"post\": {\n    \"accountId\": \"INSERT_ACCOUNT_ID\",\n    \"content\": {\n      \"text\": \"{{ $('Save Info').item.json['Clip Caption'] }}\",\n      \"mediaUrls\": [\n        \"{{ $json.url }}\"\n      ],\n      \"platform\": \"instagram\"\n    },\n    \"target\": {\n      \"targetType\": \"instagram\",\n      \"privacyLevel\": \"PUBLIC_TO_EVERYONE\",\n      \"disabledComments\": false,\n      \"disabledDuet\": false,\n      \"disabledStitch\": false,\n      \"isBrandedContent\": false,\n      \"isYourBrand\": true,\n      \"isAiGenerated\": false\n    }\n  },\n  \"scheduledTime\": \"{{ $('Save Info').item.json['Schedule Time'] }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1360,
        -480
      ],
      "id": "d474ee25-8346-4d74-b228-5e5d70f359bf",
      "name": "Instagram"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://backend.blotato.com/v2/posts",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "blotato-api-key",
              "value": "INSERT_API_KEY"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"post\": {\n    \"accountId\": \"INSERT_ACCOUNT_ID\",\n    \"content\": {\n      \"text\": \"{{ $('Save Info').item.json['Clip Caption'] }}\",\n      \"mediaUrls\": [\n        \"{{ $json.url }}\"\n      ],\n      \"platform\": \"facebook\"\n    },\n    \"target\": {\n      \"targetType\": \"facebook\",\n      \"pageId\": \"INSERT_PAGE_ID\",\n      \"privacyLevel\": \"PUBLIC_TO_EVERYONE\",\n      \"disabledComments\": false,\n      \"disabledDuet\": false,\n      \"disabledStitch\": false,\n      \"isBrandedContent\": false,\n      \"isYourBrand\": true,\n      \"isAiGenerated\": false\n    }\n  },\n  \"scheduledTime\": \"{{ $('Save Info').item.json['Schedule Time'] }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1360,
        40
      ],
      "id": "2075de0d-730e-4c70-a04c-6eb5b5365244",
      "name": "Facebook"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://backend.blotato.com/v2/posts",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "blotato-api-key",
              "value": "INSERT_API_KEY"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"post\": {\n    \"accountId\": \"INSERT_ACCOUNT_ID\",\n    \"content\": {\n      \"text\": \"{{ $('Save Info').item.json['Clip Caption'] }}\",\n      \"mediaUrls\": [\n        \"{{ $json.url }}\"\n      ],\n      \"platform\": \"linkedin\"\n    },\n    \"target\": {\n      \"targetType\": \"linkedin\",\n      \"privacyLevel\": \"PUBLIC_TO_EVERYONE\",\n      \"disabledComments\": false,\n      \"disabledDuet\": false,\n      \"disabledStitch\": false,\n      \"isBrandedContent\": false,\n      \"isYourBrand\": true,\n      \"isAiGenerated\": false\n    }\n  },\n  \"scheduledTime\": \"{{ $('Save Info').item.json['Schedule Time'] }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1360,
        -300
      ],
      "id": "7fcfa7ea-0c46-4854-8784-784c471c753a",
      "name": "LinkedIn"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://backend.blotato.com/v2/posts",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "blotato-api-key",
              "value": "INSERT_API_KEY"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"post\": {\n    \"accountId\": \"INSERT_ACCOUNT_ID\",\n    \"content\": {\n      \"text\": \"{{ $('Save Info').item.json['Clip Caption'] }}\",\n      \"mediaUrls\": [\n        \"{{ $json.url }}\"\n      ],\n      \"platform\": \"youtube\"\n    },\n    \"target\": {\n      \"targetType\": \"youtube\",\n      \"title\": \"{{ $('Save Info').item.json['Video Clip Idea'] }}\",\n      \"privacyStatus\": \"public\",\n      \"shouldNotifySubscribers\": true,\n      \"isMadeForKids\": false\n    }\n  },\n  \"scheduledTime\": \"{{ $('Save Info').item.json['Schedule Time'] }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1360,
        -120
      ],
      "id": "c0c9e85d-78c5-48b7-b4f4-970648ec0816",
      "name": "YouTube"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://backend.blotato.com/v2/posts",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "blotato-api-key",
              "value": "INSERT_API_KEY"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"post\": {\n    \"accountId\": \"INSERT_ACCOUNT_ID\",\n    \"content\": {\n      \"text\": \"{{ $('Save Info').item.json['Clip Caption'] }}\",\n      \"mediaUrls\": [\n        \"{{ $json.url }}\"\n      ],\n      \"platform\": \"twitter\"\n    },\n    \"target\": {\n      \"targetType\": \"twitter\"\n    }\n  },\n  \"scheduledTime\": \"{{ $('Save Info').item.json['Schedule Time'] }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1360,
        220
      ],
      "id": "e488c32f-aad1-4b5c-8c30-d1ce143ff2b9",
      "name": "Twitter"
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').first().json.message.chat.id }}",
        "text": "=Your YouTube video \"{{ $('Get YT Title').first().json.title }}\" was converted into {{ $('Split').first().json['How many shorts to generate?'] }} shorts and scheduled for publication on Tiktok, Instagram, Facebook, LinkedIn, Twitter and YouTube at these times: \n\n{{ $('Convert Times').all().map(item => item.json.local_time).join('\\n') }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1520,
        220
      ],
      "id": "a8bb7b77-9a20-43e1-95ce-9de2882d782c",
      "name": "Telegram",
      "webhookId": "4ee07076-cc1a-4418-8e34-a6feadcefc4f",
      "executeOnce": true,
      "credentials": {
        "telegramApi": {
          "id": "9q2BHsi4GHHRuvvv",
          "name": "Telegram account 27"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const allVideos = $input.all();\nconst totalExpected = $('Get Ideas').all().length;\nconst readyCount = allVideos.filter(v => v.json.status === 'ready').length;\n\nconst allReady = readyCount === totalExpected;\n\n// Add a field that says if everything is ready or not\nreturn allVideos.map(video => ({\n  json: {\n    ...video.json,\n    is_everything_ready: allReady ? true : false\n  }\n}));\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        660,
        -1060
      ],
      "id": "f86848ec-353d-47cc-9b35-22b0e5c01d95",
      "name": "Check Ready",
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "c3fc3089-a100-408a-9212-6966d7886488",
              "leftValue": "={{ $json.is_everything_ready }}",
              "rightValue": "true",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        800,
        -1060
      ],
      "id": "fcb0c86d-4d98-4baf-980a-32c3f2cac7c5",
      "name": "If1"
    }
  ],
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Split",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split": {
      "main": [
        [
          {
            "node": "Analyse Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyse Video": {
      "main": [
        [
          {
            "node": "Check Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Status": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Get Ideas",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Check Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Ideas": {
      "main": [
        [
          {
            "node": "Make HD Short",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Make HD Short": {
      "main": [
        [
          {
            "node": "Get Final Shorts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Final Shorts": {
      "main": [
        [
          {
            "node": "Check Ready",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "Get Final Shorts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get YT Title": {
      "main": [
        [
          {
            "node": "Get Schedule",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Schedule": {
      "main": [
        [
          {
            "node": "Schedule Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Settings": {
      "main": [
        [
          {
            "node": "Get Existing Schedule",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Existing Schedule": {
      "main": [
        [
          {
            "node": "Get Last Time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Last Time": {
      "main": [
        [
          {
            "node": "Schedule Videos",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Videos": {
      "main": [
        [
          {
            "node": "Convert Times",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert Times": {
      "main": [
        [
          {
            "node": "Save Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Info": {
      "main": [
        [
          {
            "node": "Upload Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Video": {
      "main": [
        [
          {
            "node": "TikTok",
            "type": "main",
            "index": 0
          },
          {
            "node": "Instagram",
            "type": "main",
            "index": 0
          },
          {
            "node": "Facebook",
            "type": "main",
            "index": 0
          },
          {
            "node": "LinkedIn",
            "type": "main",
            "index": 0
          },
          {
            "node": "YouTube",
            "type": "main",
            "index": 0
          },
          {
            "node": "Twitter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Instagram": {
      "main": [
        []
      ]
    },
    "Twitter": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Ready": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Get YT Title",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a396300c-967b-4fed-ac23-bfd33c81e5f1",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "7ff6625f0127f3e9a7865e3493009de1c48f57dc5ed87def3ae3316be7f6b238"
  },
  "id": "b6aJQpZpP37bMtpS",
  "tags": []
}