{
  "id": "4A5bemb2vyi97z5B",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Generate Viral AI Motion Video",
  "tags": [],
  "nodes": [
    {
      "id": "df8154f8-f3f8-4ca2-a02c-181cf6d0633c",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -448,
        80
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "2e02deb1-a689-4183-a813-03e20b8524df",
      "name": "Get File Video",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        464,
        464
      ],
      "parameters": {
        "url": "={{ $json.resultUrl }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "2880297d-9df7-4bdf-a6f6-92e102b1f867",
      "name": "TikTok",
      "type": "n8n-nodes-postiz.postiz",
      "position": [
        1088,
        544
      ],
      "parameters": {
        "date": "={{ $now.format('yyyy-LL-dd') }}T{{ $now.format('HH:ii:ss') }}",
        "posts": {
          "post": [
            {
              "value": {
                "contentItem": [
                  {
                    "image": {
                      "imageItem": [
                        {
                          "id": "={{ $json.id }}",
                          "path": "={{ $json.path }}"
                        }
                      ]
                    },
                    "content": "={{ $('Set params').item.json.tiktok_desc }}"
                  }
                ]
              },
              "integrationId": "XXX"
            }
          ]
        },
        "shortLink": true
      },
      "credentials": {
        "postizApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2f31c615-84f5-429e-bbc7-dbda5b74425a",
      "name": "Upload Video to Postiz",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        768,
        544
      ],
      "parameters": {
        "url": "https://api.postiz.com/public/v1/upload",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "file",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "data"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "c452299d-f536-4f9c-8b75-deee7b36a2a6",
      "name": "Set params",
      "type": "n8n-nodes-base.set",
      "position": [
        -128,
        80
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f0475adc-868e-4732-8c21-75ad9aeb28db",
              "name": "image_url",
              "type": "string",
              "value": "https://n3wstorage.b-cdn.net/test/goku.png"
            },
            {
              "id": "3e2b24cf-b84e-45a5-b76e-5d763d761931",
              "name": "video_url",
              "type": "string",
              "value": "https://n3wstorage.b-cdn.net/test/kling-v2-6-std-motion-control.mp4"
            },
            {
              "id": "23d7ef27-c55d-4bcb-aa9b-c56990715859",
              "name": "tiktok_desc",
              "type": "string",
              "value": "xxx"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "44fcb5d4-d87f-4a1b-b85a-2f6d095dadee",
      "name": "Run Kling v2.6 Motion Control",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        160,
        80
      ],
      "parameters": {
        "url": "https://api.kie.ai/api/v1/jobs/createTask",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"model\": \"kling-2.6/motion-control\",\n  \"callBackUrl\": \"{{ $execution.resumeUrl }}\",\n  \"input\": {\n    \"prompt\": \"Make the character in the image follow the movements of the character in the video.\",\n    \"input_urls\": [\n      \"{{ $json.image_url }}\"\n    ],\n    \"video_urls\": [\n      \"{{ $json.video_url }}\"\n    ],\n    \"character_orientation\": \"video\",\n    \"mode\": \"720p\"\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "headerParameters": {
          "parameters": [
            {}
          ]
        }
      },
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "10a43f06-aec8-4743-a0e3-9b5a0331cabb",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        464,
        80
      ],
      "parameters": {
        "resume": "webhook",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 1.1
    },
    {
      "id": "d19e47a9-f598-4ce1-ab7e-3ee331f4e117",
      "name": "Result",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        768,
        80
      ],
      "parameters": {
        "url": "=https://api.kie.ai/api/v1/jobs/recordInfo",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "taskId",
              "value": "={{ $('Run Kling v2.6 Motion Control').item.json.data.taskId }}"
            }
          ]
        }
      },
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "f0dea53d-d85d-4145-ac63-80ce737696d5",
      "name": "Parsing",
      "type": "n8n-nodes-base.set",
      "position": [
        1104,
        80
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "74799abc-534e-4935-b9c0-f94bfc2d4d61",
              "name": "result",
              "type": "string",
              "value": "={{ $json.data.resultJson }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "132d3463-088a-4349-92ad-709461dd9cb5",
      "name": "Get ResulUrl",
      "type": "n8n-nodes-base.code",
      "position": [
        176,
        464
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\n\nreturn items.map(item => {\n  const parsed = JSON.parse(item.json.result);\n\n  return {\n    json: {\n      resultUrl: parsed.resultUrls[0]\n    }\n  };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "41e26f24-2b3f-4be7-a1c0-23db14002bfc",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        96,
        -800
      ],
      "parameters": {
        "width": 912,
        "height": 688,
        "content": "## Generate Viral AI Motion Video using Kling 2.6 Kie AI & Auto-Post to TikTok\n\nThis workflow automates the creation and publishing of **AI-generated motion videos for TikTok**. The process starts with an image and a reference motion video. \n\nUsing the **Kling v2.6 Motion Control** AI model, the workflow generates a new animated video where the character from the image replicates the movements from the reference video. \n\nOnce the AI-generated video is produced, the workflow automatically retrieves the result, uploads it to Postiz, and publishes it directly to TikTok with a predefined caption.\n\nStart: [Watch the starting video](https://iframe.mediadelivery.net/play/580928/707dae0c-0eac-42be-88ea-0210a5c3c906)\nResult: [Watch the final video](https://iframe.mediadelivery.net/play/580928/7019158a-e731-4d10-9fea-e5b81c3c634b)\n\n### How it works:\n\nThis workflow is manually triggered and starts by setting three inputs: a static `image_url`, a motion reference `video_url`, and a `tiktok_desc` caption. It then calls the Kling v2.6 Motion Control model via the Kie AI API to generate an animated video where the image character follows the reference video\u2019s movements, passing an n8n webhook `callBackUrl` so the job can notify the workflow when finished. Execution pauses on a Wait node until the callback resumes the run, after which the workflow fetches the completed job details and extracts the `resultUrl`. The generated video is downloaded from the temporary URL, uploaded to Postiz as a file, and finally used to create/schedule a TikTok post in Postiz using the returned video ID plus the predefined caption.\n\n### Setup steps:\n\nUpdate the **\u201cSet params\u201d** node with your own direct URLs for `image_url` (character image) and `video_url` (reference motion video), and set `tiktok_desc` to the caption you want published. Configure **Kie AI** authentication by adding your `httpBearerAuth` credentials (Bearer token) in both **\u201cRun Kling v2.6 Motion Control\u201d** and **\u201cResult\u201d** nodes so the workflow can submit and later retrieve the job output. Configure **Postiz** authentication by adding your `httpHeaderAuth` API key in **\u201cUpload Video to Postiz\u201d** for multipart upload authorization. Finally, in the **\u201cTikTok (Postiz)\u201d** node, replace the `integrationId` placeholder (`\"XXX\"`) with the real Postiz TikTok Integration ID to ensure posts are published to the correct account.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "db0c938f-07ca-4d0a-97b5-01a18e2953f2",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -224,
        -80
      ],
      "parameters": {
        "color": 7,
        "width": 288,
        "height": 336,
        "content": "## STEP 1 - Set params\n\nreplace the example image_url, video_url, and tiktok_desc with your own values."
      },
      "typeVersion": 1
    },
    {
      "id": "a3565f35-79f0-41e1-b100-1c93a9991c07",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        96,
        -80
      ],
      "parameters": {
        "color": 7,
        "width": 912,
        "height": 336,
        "content": "## STEP 2 - Generate Video\n\nSet your [Kie AI API Key](https://kie.ai?ref=188b79f5cb949c9e875357ac098e1ff5) You will need to provide credentials for httpBearerAuth"
      },
      "typeVersion": 1
    },
    {
      "id": "d764d3dd-b92c-4d5f-a870-0e443c845115",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        96,
        304
      ],
      "parameters": {
        "color": 7,
        "width": 592,
        "height": 320,
        "content": "## STEP 3 - Get Video\n\nGet video url and Binary"
      },
      "typeVersion": 1
    },
    {
      "id": "ede3f491-500b-4901-87ce-0806bf44995d",
      "name": "Upload video",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        768,
        720
      ],
      "parameters": {
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "root",
          "cachedResultName": "/ (Root folder)"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "26d35276-b2f8-4c89-85f9-65c42a315fc5",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        304
      ],
      "parameters": {
        "color": 7,
        "width": 592,
        "height": 576,
        "content": "## STEP 4 - Publish on TikTok & Google Drive\n\n- Create an account on [Postiz](https://postiz.com/?ref=n3witalia) FREE 7 days-trial\n- Get your API Key and set it in Postiz node and Upload Image node\n- In Calendar tab on [Postiz](https://postiz.com/?ref=n3witalia) click on \"Add channel\" and connect your social networks (TikTok)\n- Once connected, copy the \"ChannelId\" for each social network and insert the appropriate one into the Postiz nodes, replacing the \"XXX\" string. "
      },
      "typeVersion": 1
    },
    {
      "id": "2e6aa311-061b-4b65-9e11-133ff2cb12b5",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1056,
        -848
      ],
      "parameters": {
        "color": 7,
        "width": 736,
        "height": 736,
        "content": "## MY NEW YOUTUBE CHANNEL\n\ud83d\udc49 [Subscribe to my new **YouTube channel**](https://youtube.com/@n3witalia). Here I\u2019ll share videos and Shorts with practical tutorials and **FREE templates for n8n**.\n\n[![image](https://n3wstorage.b-cdn.net/n3witalia/youtube-n8n-cover.jpg)](https://youtube.com/@n3witalia)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "6facd05c-0282-4f34-9514-362fa0a26966",
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Result": {
      "main": [
        [
          {
            "node": "Parsing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parsing": {
      "main": [
        [
          {
            "node": "Get ResulUrl",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set params": {
      "main": [
        [
          {
            "node": "Run Kling v2.6 Motion Control",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get ResulUrl": {
      "main": [
        [
          {
            "node": "Get File Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get File Video": {
      "main": [
        [
          {
            "node": "Upload Video to Postiz",
            "type": "main",
            "index": 0
          },
          {
            "node": "Upload video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Video to Postiz": {
      "main": [
        [
          {
            "node": "TikTok",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Kling v2.6 Motion Control": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Set params",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}