{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "fb423c16-9910-4bff-8167-7bfa59e1c783",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1040,
        624
      ],
      "parameters": {
        "color": 5,
        "width": 528,
        "height": 640,
        "content": "## Muhammad Farooq Iqbal - Automation Expert & n8n Creator\n\nI am a passionate automation expert and recognized n8n Creator specializing in intelligent workflow automation. With extensive experience in n8n, AI automation, Zapier, and Make.com, I have created innovative workflow templates with 2500+ downloads across the global automation community\n\n### Expertise\n- **Workflow Automation**: n8n, Zapier, Make.com, AI automation\n- **AI Integration**: Gemini AI, API integration, data processing\n- **Platform Mastery**: Google Sheets, Google Drive, custom scripts\n\n## Need Help with This Workflow?\n\nIf you face any issues with this workflow or need customization support, feel free to reach out:\n\n**\ud83d\udce7 Email**: mfarooqiqbal143@gmail.com  \n**\ud83d\udcf1 Phone**: +923036991118  \n**\ud83d\udcbc LinkedIn**: [Connect with me](https://linkedin.com/in/muhammadfarooqiqbal)  \n**\ud83c\udf10 Portfolio**: [View my work](https://mfarooqone.github.io/n8n/)\n**UpWork**: [Upwork Profile](https://www.upwork.com/freelancers/~011aeba159896e2eba)\n\n*I'm always excited to help with automation challenges and workflow optimization!*\n"
      },
      "typeVersion": 1
    },
    {
      "id": "f684de7c-b9de-47c6-8cd1-e3054a568226",
      "name": "Submit Video Generation Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        464,
        656
      ],
      "parameters": {
        "url": "https://api.kie.ai/api/v1/jobs/createTask",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"model\": \"bytedance/seedance-1.5-pro\",\n    \"input\": {\n      \"prompt\": \"{{ $json.prompt }}\",\n      \"input_urls\": [\n        \"{{ $json.image_url }}\"\n      ],\n      \"aspect_ratio\": \"9:16\",\n      \"resolution\": \"720p\",\n      \"duration\": \"8\"\n    }\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth"
      },
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2
    },
    {
      "id": "eca71e15-d79a-43bf-b6fb-99b58afb969d",
      "name": "Switch Video Generation Status",
      "type": "n8n-nodes-base.switch",
      "onError": "continueRegularOutput",
      "position": [
        448,
        880
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "fail",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "fail-state-condition",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.data.state }}",
                    "rightValue": "fail"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "success",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "success-state-condition",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.data.state }}",
                    "rightValue": "success"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "generating",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "generating-state-condition",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.data.state }}",
                    "rightValue": "generating"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "queuing",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "queuing-state-condition",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.data.state }}",
                    "rightValue": "queuing"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "waiting",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "waiting-state-condition",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.data.state }}",
                    "rightValue": "waiting"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "retryOnFail": true,
      "typeVersion": 3.2
    },
    {
      "id": "dd4b7f69-4435-4068-98b7-8dfc4002d724",
      "name": "Check Video Generation Status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        224,
        928
      ],
      "parameters": {
        "url": "https://api.kie.ai/api/v1/jobs/recordInfo",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "taskId",
              "value": "={{ $json.data.taskId }}"
            }
          ]
        }
      },
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2
    },
    {
      "id": "b5744a12-3661-4ff9-bcff-d866df61a908",
      "name": "Wait for Video Generation",
      "type": "n8n-nodes-base.wait",
      "position": [
        64,
        928
      ],
      "parameters": {
        "unit": "seconds",
        "amount": 5
      },
      "retryOnFail": true,
      "typeVersion": 1
    },
    {
      "id": "93166ea9-1a04-4284-bc05-05e06ba1737c",
      "name": "Extract Video URL",
      "type": "n8n-nodes-base.code",
      "position": [
        672,
        896
      ],
      "parameters": {
        "jsCode": "// n8n Function node\nconst items = $input.all();\nconst out = [];\n\nfor (const item of items) {\n  // Your HTTP node sometimes returns an array at top-level\n  const payload = item.json;\n  const first = Array.isArray(payload) ? payload[0] : payload;\n\n  // Get the stringified resultJson safely\n  const resultJsonStr = first?.data?.resultJson ?? '';\n\n  // Parse and extract\n  let resultUrls = [];\n  try {\n    const parsed = JSON.parse(resultJsonStr);\n    resultUrls = parsed?.resultUrls ?? [];\n  } catch (e) {\n    // leave resultUrls as []\n  }\n\n  out.push({ json: { resultUrls } });\n}\n\nreturn out;\n"
      },
      "retryOnFail": true,
      "typeVersion": 2
    },
    {
      "id": "5e1da3d9-c4c7-4aa2-b1ea-9b4b12c7c13a",
      "name": "Download Video File",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        672,
        1120
      ],
      "parameters": {
        "url": "={{ $json.resultUrls[0] }}",
        "options": {}
      },
      "typeVersion": 4.3
    },
    {
      "id": "5ce6b136-a127-4e83-aa2e-24c16b85ca74",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -496,
        624
      ],
      "parameters": {
        "width": 450,
        "height": 724,
        "content": "## \ud83d\udd27 Setup & Integration Guide\n\n**\ud83d\udccb Required API Keys:**\n\n1. **KIE.AI API Key**\n   \u2022 Get from: https://kie.ai/\n   \u2022 Used for: ByteDance Seedance 1.5 Pro video generation\n   \u2022 Add as HTTP Bearer Auth credential\n   \u2022 Or replace 'YOUR_KIE_AI_API_KEY' placeholder\n\n**\u26a1 Quick Setup:**\n1. Get KIE.AI API key\n2. Add as Bearer Auth credential or update HTTP Request nodes\n3. Set prompt in 'Set Video Parameters' node\n4. Set image_url (publicly accessible URL)\n5. Configure aspect_ratio (9:16, 16:9, 1:1, etc.)\n6. Set resolution (720p, 1080p, etc.)\n7. Set duration in seconds\n8. Test with manual trigger\n\n**\ud83d\udcc1 Image Requirements:**\n\u2022 Publicly accessible URL (HTTPS recommended)\n\u2022 Supported formats: PNG, JPG, JPEG\n\u2022 Image should match desired aspect ratio\n\n**\ud83c\udfac Video Settings:**\n\u2022 Aspect Ratio: 9:16 (vertical), 16:9 (horizontal), 1:1 (square)\n\u2022 Resolution: 720p, 1080p, etc.\n\u2022 Duration: In seconds (e.g., 8, 10, 15)\n\n**\u23f1\ufe0f Processing Time:**\n\u2022 Varies based on video length and KIE.AI queue\n\u2022 Typical: 1-5 minutes\n\u2022 Polling checks every 5 seconds"
      },
      "typeVersion": 1
    },
    {
      "id": "23686360-6751-4eed-a91d-a65358468f84",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -16,
        624
      ],
      "parameters": {
        "color": 4,
        "width": 976,
        "height": 640,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "d862bb3a-f945-4946-8d59-eef359090650",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        96,
        656
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "9e593459-7572-4e24-aab9-8425fde51309",
      "name": "Set Properties",
      "type": "n8n-nodes-base.set",
      "position": [
        272,
        656
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "774ed91a-11bd-4584-ad9c-418e9caf88df",
              "name": "prompt",
              "type": "string",
              "value": "=YOUR_VIDEO_PROMPT_DESCRIPTION"
            },
            {
              "id": "344f15cb-68ae-438f-bff9-fdef1339851a",
              "name": "image_url",
              "type": "string",
              "value": "=YOUR_IMAGE_URL"
            }
          ]
        }
      },
      "typeVersion": 3.4
    }
  ],
  "connections": {
    "Extract Video URL": {
      "main": [
        [
          {
            "node": "Download Video File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Video Generation": {
      "main": [
        [
          {
            "node": "Check Video Generation Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Video Generation Status": {
      "main": [
        [
          {
            "node": "Switch Video Generation Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch Video Generation Status": {
      "main": [
        [
          {
            "node": "Submit Video Generation Request",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract Video URL",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait for Video Generation",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait for Video Generation",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait for Video Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Submit Video Generation Request": {
      "main": [
        [
          {
            "node": "Wait for Video Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Set Properties",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}