{
  "name": "ShortsMaker",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.2,
      "position": [
        -480,
        -140
      ],
      "id": "376f1359-f253-4873-a142-c19cd23f5eb5",
      "name": "Telegram Trigger",
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIAL_ID",
          "name": "Telegram Bot API"
        }
      }
    },
    {
      "parameters": {
        "amount": 30
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        280,
        -140
      ],
      "id": "dff9ec78-70f4-44ef-b405-e8f81d0565d6",
      "name": "Wait"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.klap.app/v2/tasks/video-to-shorts",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_KLAP_API_KEY"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"source_video_url\": \"{{ $json.message.text }}\",\n  \"language\": \"en\",\n  \"max_duration\": 20,\n  \"max_clip_count\": 5,\n  \"editing_options\": {\n    \"intro_title\": false,\n    \"captions\": true,\n    \"reframe\": true\n  }\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        100,
        -260
      ],
      "id": "1b8629f8-08aa-4154-8538-43ec2cdee597",
      "name": "Clip YouTube"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.klap.app/v2/videos",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_KLAP_API_KEY"
            }
          ]
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "name": "generate_shorts",
              "value": "true"
            },
            {
              "name": "clips_count",
              "value": "5"
            },
            {
              "name": "aspect_ratio",
              "value": "9:16"
            },
            {
              "name": "add_captions",
              "value": "true"
            },
            {
              "name": "language",
              "value": "en"
            },
            {
              "parameterType": "formBinaryData",
              "name": "data"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        100,
        -60
      ],
      "id": "3e56626b-d4a1-421f-8548-1d493d23fa53",
      "name": "Clip File"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": "youtube",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "id": "0e8d8ed9-9d8c-4e8a-931d-3f6834957d69"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "YOUTUBE"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "b0bd609f-209c-4c91-8c85-1900f96a8cf5",
                    "leftValue": "",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "FILE"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -300,
        -140
      ],
      "id": "52186599-be6c-4cd8-a716-e4cca3fb391d",
      "name": "Switch"
    },
    {
      "parameters": {
        "resource": "file",
        "fileId": "jh"
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -100,
        -60
      ],
      "id": "17d7e8b6-3bb3-493e-8c5f-66ccbdfc7f53",
      "name": "Telegram",
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIAL_ID",
          "name": "Telegram Bot API"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "aa7c34fc-3a35-4b91-8ed7-99a0046c8794",
              "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": [
        660,
        -140
      ],
      "id": "f2c30c3b-0663-42d1-9fca-31c6dbb2162a",
      "name": "If"
    },
    {
      "parameters": {
        "url": "=https://api.klap.app/v2/tasks/{{ $json.id }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_KLAP_API_KEY"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        480,
        -140
      ],
      "id": "24734efb-0474-4617-92bf-3e09ef0a1c4e",
      "name": "CheckStatus1"
    },
    {
      "parameters": {
        "url": "=https://api.klap.app/v2/projects/{{ $json.folder_id }}/{{ $json.project_id }}/exports/{{ $json.id }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_KLAP_API_KEY"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        680,
        120
      ],
      "id": "e186f6ed-7b71-4d05-a1a7-751e691f4d62",
      "name": "CheckExportStatus"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "aa7c34fc-3a35-4b91-8ed7-99a0046c8794",
              "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": [
        980,
        120
      ],
      "id": "49fa2442-8423-4ec1-a738-cbad34a1d428",
      "name": "If Export Complete"
    },
    {
      "parameters": {
        "amount": 15
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        260,
        300
      ],
      "id": "f892dffb-ca36-4d15-817b-9d2246c6131e",
      "name": "Wait15Seconds"
    },
    {
      "parameters": {
        "url": "={{ $json.src_url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        520,
        300
      ],
      "id": "ce4cf7bb-1821-46f1-8d8b-05ae7b12f8b9",
      "name": "DownloadVideo"
    },
    {
      "parameters": {
        "url": "=https://api.klap.app/v2/projects/{{ $json.output_id }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_KLAP_API_KEY"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        880,
        -160
      ],
      "id": "28b80b3f-dfa7-43bc-801a-ad542e4b325f",
      "name": "GetClips1"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        280,
        100
      ],
      "id": "3c0c26c8-f9d0-45cb-b38e-7816812c327b",
      "name": "Loop Over Items1"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.klap.app/v2/projects/{{ $json.folder_id }}/{{ $json.id }}/exports",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_KLAP_API_KEY"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        480,
        120
      ],
      "id": "8c8a7cbc-4021-438b-887d-176b816c4bce",
      "name": "ExportVideo1"
    },
    {
      "parameters": {
        "operation": "sendVideo",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "binaryData": true,
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        760,
        300
      ],
      "id": "5c477909-1fe5-4c92-872d-ce63ea086f21",
      "name": "Telegram1",
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIAL_ID",
          "name": "Telegram Bot API"
        }
      }
    },
    {
      "parameters": {
        "chatId": "YOUR_CHAT_ID",
        "text": "Processing complete!",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1020,
        -160
      ],
      "id": "a4eca0ea-09d7-4d26-966f-a28ec34c0983",
      "name": "Telegram2",
      "executeOnce": true,
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIAL_ID",
          "name": "Telegram Bot API"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{ $json.result.chat.id }}",
        "text": "=Full Quality Video: {{ $('DownloadVideo').item.json.src_url }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        980,
        300
      ],
      "id": "2f5fff92-82cf-41cd-a316-a9549faf3f94",
      "name": "Telegram3",
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIAL_ID",
          "name": "Telegram Bot API"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "CheckStatus1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clip YouTube": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clip File": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Clip YouTube",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram": {
      "main": [
        [
          {
            "node": "Clip File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "GetClips1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CheckStatus1": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CheckExportStatus": {
      "main": [
        [
          {
            "node": "If Export Complete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Export Complete": {
      "main": [
        [
          {
            "node": "DownloadVideo",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait15Seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait15Seconds": {
      "main": [
        [
          {
            "node": "CheckExportStatus",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GetClips1": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items1": {
      "main": [
        [
          {
            "node": "Telegram2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "ExportVideo1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ExportVideo1": {
      "main": [
        [
          {
            "node": "CheckExportStatus",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DownloadVideo": {
      "main": [
        [
          {
            "node": "Telegram1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram1": {
      "main": [
        [
          {
            "node": "Telegram3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram3": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "tags": []
}