{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "e5946662-78f4-4051-ba5c-65328551140a",
      "name": "\ud83d\udccb Setup Guide",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1776,
        -320
      ],
      "parameters": {
        "width": 476,
        "height": 968,
        "content": "## \ud83c\udfac Video \u2192 AI Clips \u2192 Google Drive\n\n**What it does:**\nUser pastes a video URL in chat (YouTube, etc). WayinVideo AI automatically finds the best short clips, adds captions, reframes to 9:16, and uploads them to Google Drive.\n\n**How it works:**\n1. \ud83d\udcac User sends a video URL via chat\n2. \ud83c\udfac Video is submitted to WayinVideo API for clip generation\n3. \u23f3 Waits 30s, then polls until clips are ready\n4. \ud83d\udd04 If not ready \u2192 waits 30s again (loop)\n5. \u2699\ufe0f Extracts clip title, download link, score & tags\n6. \u2b07\ufe0f Downloads each clip file\n7. \u2601\ufe0f Uploads each clip to your Google Drive folder\n\n---\n\n**\ud83d\udd11 Credentials to Add:**\n- Google Drive \u2192 Connect OAuth2 credential\n\n**\ud83d\udd27 Placeholders to Fill:**\n\n`YOUR_WAYINVIDEO_API_KEY`\n\u2192 Your WayinVideo API Bearer token\n  Get it from: wayinvideo.com/dashboard/api\n\n`YOUR_GOOGLE_DRIVE_FOLDER_ID`\n\u2192 The folder ID from Google Drive URL\n  e.g. drive.google.com/drive/folders/**THIS_PART**\n\n---\n\n**\u2699\ufe0f Customise (in Submit node):**\n- `target_duration` \u2192 DURATION_30_60 (change clip length)\n- `limit` \u2192 3 (how many clips to generate)\n- `resolution` \u2192 HD_720 or FULL_HD_1080\n- `ratio` \u2192 RATIO_9_16 (vertical) or RATIO_16_9\n- `project_name` \u2192 Change naming convention\n\n---\n\n**\u26a0\ufe0f Note:**\nIf video is long, processing may take >30s.\nThe workflow auto-retries every 30s until clips are ready."
      },
      "typeVersion": 1
    },
    {
      "id": "0d68a3dc-c481-408d-87cd-b7870fc4d195",
      "name": "\ud83c\udfac Submit Video to WayinVideo API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1168,
        160
      ],
      "parameters": {
        "url": "https://wayinvideo-api.wayin.ai/api/v2/clips",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "video_url",
              "value": "={{ $json.chatInput }}"
            },
            {
              "name": "project_name",
              "value": "=Podcast Clips - {{ new Date().toISOString().split('T')[0] }}"
            },
            {
              "name": "target_duration",
              "value": "DURATION_30_60"
            },
            {
              "name": "limit",
              "value": 3
            },
            {
              "name": "enable_export",
              "value": true
            },
            {
              "name": "resolution",
              "value": "HD_720"
            },
            {
              "name": "enable_caption",
              "value": true
            },
            {
              "name": "caption_display",
              "value": "original"
            },
            {
              "name": "cc_style_tpl",
              "value": "temp-7"
            },
            {
              "name": "enable_ai_reframe",
              "value": true
            },
            {
              "name": "ratio",
              "value": "RATIO_9_16"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "x-wayinvideo-api-version",
              "value": "v2"
            },
            {
              "name": "Authorization",
              "value": "Bearer YOUR_TOKEN_HERE"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "1fdc4b1c-e744-4419-9a26-bdff9a748b2a",
      "name": "\u23f3 Wait 30 Seconds",
      "type": "n8n-nodes-base.wait",
      "position": [
        -848,
        160
      ],
      "parameters": {
        "unit": "seconds",
        "amount": 30
      },
      "typeVersion": 1
    },
    {
      "id": "cd70538d-78a0-43e2-9211-fffbed248d9d",
      "name": "\ud83d\udd04 Poll for Clip Results",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -560,
        160
      ],
      "parameters": {
        "url": "=https://wayinvideo-api.wayin.ai/api/v2/clips/results/{{ $('\ud83c\udfac Submit Video to WayinVideo API').item.json.data.id }}",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_TOKEN_HERE"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "x-wayinvideo-api-version",
              "value": "v2"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "8abd5935-8293-45d0-8b8f-ec81f2c5e9eb",
      "name": "\u2705 Clips Ready?",
      "type": "n8n-nodes-base.if",
      "position": [
        -320,
        160
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "d25403b5-efc7-4262-8f7d-3e6ed7a47caf",
              "operator": {
                "type": "array",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.data.clips }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "547a364c-7c59-45ba-bce5-23c2db7b2619",
      "name": "\u2699\ufe0f Extract Clip Details",
      "type": "n8n-nodes-base.code",
      "position": [
        128,
        144
      ],
      "parameters": {
        "jsCode": "const clips = $json.data.clips;\n\nreturn clips.map(clip => ({\n  json: {\n    title: clip.title,\n    export_link: clip.export_link,\n    score: clip.score,\n    tags: clip.tags,\n    desc: clip.desc,\n    begin_ms: clip.begin_ms,\n    end_ms: clip.end_ms\n  }\n}));"
      },
      "typeVersion": 2
    },
    {
      "id": "0ea44c90-35ca-41e9-93b0-b11b6e554179",
      "name": "\u2b07\ufe0f Download Clip File",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        464,
        144
      ],
      "parameters": {
        "url": "={{ $json.export_link }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "c7042cb0-d32e-45cd-b708-f5e1ce493be7",
      "name": "\u2601\ufe0f Upload Clip to Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        736,
        144
      ],
      "parameters": {
        "name": "={{ $('\u2699\ufe0f Extract Clip Details').item.json.title }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_DRIVE_FOLDER_ID",
          "cachedResultUrl": "https://drive.google.com/drive/folders/YOUR_GOOGLE_DRIVE_FOLDER_ID",
          "cachedResultName": "Your Clips Folder"
        },
        "inputDataFieldName": "=data"
      },
      "typeVersion": 3
    },
    {
      "id": "f06f33ce-dbf1-4244-b8f8-12f30cf90a3f",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1280,
        -48
      ],
      "parameters": {
        "color": 7,
        "width": 336,
        "height": 256,
        "content": "## \ud83c\udfac Submit Video for Processing\n\n\u2022 Sends video URL to WayinVideo API\n\u2022 Starts AI clip generation process\n\u2022 Applies settings (duration, captions, format)\n\n\ud83d\udc49 This is where clip creation begins"
      },
      "typeVersion": 1
    },
    {
      "id": "8e92fc58-457c-4faa-82c8-99ab7add9750",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -848,
        -48
      ],
      "parameters": {
        "color": 7,
        "width": 384,
        "height": 256,
        "content": "## \u23f3 Wait & Check Processing Status\n\n\u2022 Waits 30 seconds before checking\n\u2022 Requests API to check if clips are ready\n\u2022 Uses job ID to fetch results\n\n\ud83d\udc49 Prevents instant API calls & allows processing time"
      },
      "typeVersion": 1
    },
    {
      "id": "fa48d725-e2b4-4901-a122-67c64be8643a",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        -48
      ],
      "parameters": {
        "color": 7,
        "width": 336,
        "height": 256,
        "content": "## \ud83d\udd01 Check if Clips are Ready\n\n\u2022 Checks if clips data is available\n\u2022 If NOT ready \u2192 waits again (loop)\n\u2022 If ready \u2192 moves to next step\n\n\ud83d\udc49 Smart loop until clips are generated"
      },
      "typeVersion": 1
    },
    {
      "id": "663307a2-ecd4-4460-a848-90f8d55a997b",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        -48
      ],
      "parameters": {
        "color": 7,
        "width": 336,
        "height": 240,
        "content": "## \u2699\ufe0f Extract Clip Information\n\n\u2022 Loops through all generated clips\n\u2022 Extracts title, link, score, tags\n\u2022 Prepares clean structured output\n\n\ud83d\udc49 Converts API response into usable data"
      },
      "typeVersion": 1
    },
    {
      "id": "3d323aa3-5126-41be-aa14-2461a669db84",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        -48
      ],
      "parameters": {
        "color": 7,
        "width": 368,
        "height": 240,
        "content": "## \ud83d\udce5 Download & Save Clips\n\n\u2022 Downloads clip using export link\n\u2022 Uploads file to Google Drive\n\u2022 Saves with clip title\n\n\ud83d\udc49 Final storage of generated clips"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "\u2705 Clips Ready?": {
      "main": [
        [
          {
            "node": "\u2699\ufe0f Extract Clip Details",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\u23f3 Wait 30 Seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u23f3 Wait 30 Seconds": {
      "main": [
        [
          {
            "node": "\ud83d\udd04 Poll for Clip Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u2b07\ufe0f Download Clip File": {
      "main": [
        [
          {
            "node": "\u2601\ufe0f Upload Clip to Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83d\udd04 Poll for Clip Results": {
      "main": [
        [
          {
            "node": "\u2705 Clips Ready?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u2699\ufe0f Extract Clip Details": {
      "main": [
        [
          {
            "node": "\u2b07\ufe0f Download Clip File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83c\udfac Submit Video to WayinVideo API": {
      "main": [
        [
          {
            "node": "\u23f3 Wait 30 Seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}