{
  "name": "Bodycam Youtube Shorts Otomasyonu (prompt)",
  "nodes": [
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -720,
        208
      ],
      "id": "f23b73b1-0284-4727-8400-5e0c21e92bbe",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n\t\"video_prompt\": \"\",\n    \"video_title\": \"\",\n    \"video_description\": \"\"\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        -576,
        192
      ],
      "id": "36818221-9591-4eba-a11e-c2ec9f7a1792",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "errorMessage": "=Error while generating the video: {{ $json.message || data.failMsg }}"
      },
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        -336,
        224
      ],
      "id": "037e9f27-0ea5-4ce9-b3e2-320966238c5f",
      "name": "Stop and Error"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "defd1dcb-4c75-47bc-83c4-bb29f6d1b1fd",
              "name": "task_id",
              "value": "={{ $json.data.taskId }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -864,
        448
      ],
      "id": "ed0ebd9e-538b-4758-8cef-abc60d91c713",
      "name": "Set task id"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -272,
        624
      ],
      "id": "f37c3530-a35b-415f-975e-a040fa57e170",
      "name": "Wait"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "c335417b-f320-4f9b-a5c8-48d7b6e8f0e6",
              "leftValue": "={{ $json.code }}",
              "rightValue": 200,
              "operator": {
                "type": "number",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -1088,
        352
      ],
      "id": "1c6b6c48-e423-4e45-a44c-82a1dffdfbfb",
      "name": "Successful start?"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=You are an AI Video Prompt Generator specialized in creating **viral short-form video concepts**.\n\nYour job:\n- Take ANY user input (funny story, situation, characters, objects, actions, ideas).\n- Turn it into a **cinematic, extremely entertaining, viral-style short video prompt**.\n- You may produce ANY video style (bodycam, cinematic, drone, comedy, POV, found footage, security cam, chaotic chase, vlog-style, surreal animation, etc.)\n- The output MUST ALWAYS follow the exact same output formatting below.\n\n\ud83d\udeab **Do not use copyrighted characters** (Spider-Man, Spongebob, etc.)\n\u2714\ufe0f You may use imaginary, generic, or parody characters.\n\nUser Input: {{ $json.Instructions }}\n\n## Output Rules  \nALWAYS output in this structure:\n\n<VideoTitle>\nA short, viral-style, catchy title for the video.\n</VideoTitle>\n\n<VideoPrompt>\nA detailed cinematic prompt describing the full video scene.\nIt must be highly entertaining, unexpected, and visually rich.\n</VideoPrompt>\n\nIf the user sends change requests:\n\nIf `$json.change_requests` exists, apply the following format:\n\nThe post was already generated, please apply the change requests\n\n<VideoTitle>\n${$json.video_title}\n</VideoTitle>\n\n<VideoPrompt>\n${$json.video_prompt}\n</VideoPrompt>\n\n<ChangeRequests>\n${$json.change_requests}\n</ChangeRequests>\n\n---\n\n## Important:\n- The video prompt should ALWAYS match the user's input topic\n- Keep everything original, funny, and optimized for viral potential.\n- NEVER break the output structure.\n",
        "hasOutputParser": true,
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.7,
      "position": [
        -720,
        16
      ],
      "id": "924f532e-d091-4c27-95b1-6892cd7b21c6",
      "name": "Create video prompt"
    },
    {
      "parameters": {
        "url": "https://api.kie.ai/api/v1/jobs/recordInfo",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "taskId",
              "value": "={{ $('Set task id').item.json.task_id }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [
        -688,
        448
      ],
      "id": "3ecc693e-a945-43ab-a55c-5ce7f392bfb4",
      "name": "Get status of the video",
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "4b32c886-1289-402c-9288-e565b03b4d05",
                    "leftValue": "={{ $json.data.state }}",
                    "rightValue": "fail",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "fail"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "b6b8b96b-ed7c-4df8-9d11-bc0d6cbceb6b",
                    "leftValue": "={{ $json.data.state }}",
                    "rightValue": "success",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "success"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ ['waiting', 'queuing', 'generating'].includes($json.data.state) }}",
                    "rightValue": "waiting",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "id": "e08c646f-f98d-458a-8d27-ff73e48b2c00"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "waiting"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.3,
      "position": [
        -480,
        432
      ],
      "id": "ab2593c9-48f1-4f34-be34-57d285595aae",
      "name": "Route based on the status"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://www.googleapis.com/upload/youtube/v3/videos?part=snippet,status&uploadType=resumable",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "youTubeOAuth2Api",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "X-Upload-Content-Type",
              "value": "video/mp4"
            }
          ]
        },
        "sendBody": true,
        "contentType": "raw",
        "rawContentType": "RAW/JSON",
        "body": "={{ \n  JSON.stringify(\n    {\n      \"snippet\": {\n        title: $('Create video prompt').last().json.output.video_title,\n        description: $('Create video prompt').last().json.output.video_description,\n        tags: \"\",\n        categoryId: \"24\",\n        defaultLanguage: \"en\",\n        defaultAudioLanguage: \"en\"\n      },\n      status: {\n        privacyStatus: \"public\",\n        license: \"youtube\",\n        embeddable: true,\n        publicStatsViewable: true,\n        madeForKids: false\n      }\n    }\n  ) \n}}",
        "options": {
          "response": {
            "response": {
              "fullResponse": true
            }
          }
        }
      },
      "id": "75c44be8-9ffe-4120-bd6f-952e59f8db3e",
      "name": "Start Youtube upload",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        176,
        288
      ],
      "credentials": {
        "youTubeOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "PUT",
        "url": "={{ $('Download the video1').item.json.headers.location }}",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "youTubeOAuth2Api",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "video/mp4"
            }
          ]
        },
        "sendBody": true,
        "contentType": "binaryData",
        "inputDataFieldName": "data",
        "options": {}
      },
      "id": "4b20958c-421d-4ae1-90d2-4fe8e83d3945",
      "name": "Upload video to YouTube",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        544,
        288
      ],
      "credentials": {
        "youTubeOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "url": "={{ $('Setup video url').last().json.video_url }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        352,
        288
      ],
      "id": "1de9dffc-40e0-49f9-9dbf-9e16ce4495ff",
      "name": "Download the video1"
    },
    {
      "parameters": {
        "formTitle": "Sora 2 video maker",
        "formDescription": "Create a viral body-cam footage video with Sora 2\n\nYou can add your instructions below, but make sure to avoid using copyrighted material",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Aspect ratio",
              "fieldType": "dropdown",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Landscape"
                  },
                  {
                    "option": "Portrait"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldLabel": "Instructions",
              "fieldType": "textarea",
              "placeholder": "optional"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.3,
      "position": [
        -928,
        16
      ],
      "id": "1bf6f3f5-d42b-4920-87bf-711327d7811d",
      "name": "On form submission"
    },
    {
      "parameters": {
        "formFields": {
          "values": [
            {
              "fieldLabel": "Do you approve?",
              "fieldType": "radio",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Yes"
                  },
                  {
                    "option": "No"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldLabel": "If you selected no, what changes do you want to apply?",
              "fieldType": "textarea",
              "placeholder": "Be as thorough as possible"
            }
          ]
        },
        "options": {
          "formDescription": "=Here's the title:\n{{ $json.output.video_title }}\n\nHere's the description:\n{{ $json.output.video_description }}\n\nThis is the video prompt:\n{{ $json.output.video_prompt }}"
        }
      },
      "type": "n8n-nodes-base.form",
      "typeVersion": 2.3,
      "position": [
        -432,
        16
      ],
      "id": "b4a07ef0-b5cb-4048-8bd7-c05e95381365",
      "name": "Video plan approval"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "4c919b7b-8ddc-4c10-afa4-68cd7edf2176",
              "leftValue": "={{ $json['Do you approve?'] }}",
              "rightValue": "Yes",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -240,
        16
      ],
      "id": "84f05a4a-8e95-451b-a28f-49de12e00d7b",
      "name": "Approve video plan?"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a6d99474-863d-4926-bbf6-6f8d96502ca4",
              "name": "change_requests",
              "value": "={{ $json['If you selected no, what changes do you want to apply?'] }}",
              "type": "string"
            },
            {
              "id": "2b67b23c-bb56-4e31-adbf-3c5596098822",
              "name": "video_prompt",
              "value": "={{ $('Create video prompt').last().json.output.video_prompt }}",
              "type": "string"
            },
            {
              "id": "7cafc015-bb66-4ce4-9406-2d9485008430",
              "name": "video_title",
              "value": "={{ $('Create video prompt').last().json.output.video_title }}",
              "type": "string"
            },
            {
              "id": "13785ce7-7770-46bd-9a07-13a20c7f985d",
              "name": "video_description",
              "value": "={{ $('Create video prompt').last().json.output.video_description }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -128,
        160
      ],
      "id": "76d91741-40d1-43d2-b206-1e60befb96ae",
      "name": "Set video plan variables"
    },
    {
      "parameters": {
        "formFields": {
          "values": [
            {
              "fieldLabel": "Do you approve?",
              "fieldType": "radio",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Yes"
                  },
                  {
                    "option": "No"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldLabel": "If you selected no, what changes do you want to apply?",
              "fieldType": "textarea",
              "placeholder": "Be as thorough as possible"
            }
          ]
        },
        "options": {
          "formDescription": "=Video title: {{ $('Create video prompt').last().json.output.video_title }}\n\nVideo description: {{ $('Create video prompt').last().json.output.video_description }}\n\n\nHere's the generated video:\n<video width=\"100%\" controls>\n  <source src=\"{{ $json.video_url }}\" type=\"video/mp4\">\n  Your browser does not support the video tag.\n</video>\n\n\nVideo prompt:\n{{ $('Create video prompt').last().json.output.video_prompt }}"
        }
      },
      "type": "n8n-nodes-base.form",
      "typeVersion": 2.3,
      "position": [
        -96,
        448
      ],
      "id": "170c85b5-28ee-4892-b12b-d85d5c5424bf",
      "name": "Video approval"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "4c919b7b-8ddc-4c10-afa4-68cd7edf2176",
              "leftValue": "={{ $json['Do you approve?'] }}",
              "rightValue": "Yes",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        48,
        448
      ],
      "id": "e46d1f9c-2168-424b-ade5-c1f646318a3b",
      "name": "Approve video?"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "0ef1a380-6eec-4fa2-bdd0-b90209606b44",
              "name": "change_requests",
              "value": "={{ $json['If you selected no, what changes do you want to apply?'] }}",
              "type": "string"
            },
            {
              "id": "6ab73f03-24e1-40be-8a98-3148546f18d6",
              "name": "video_prompt",
              "value": "={{ $('Create video prompt').last().json.output.video_prompt }}",
              "type": "string"
            },
            {
              "id": "c992075b-eb82-4868-b4a7-24f250cc66ac",
              "name": "video_title",
              "value": "={{ $('Create video prompt').last().json.output.video_title }}",
              "type": "string"
            },
            {
              "id": "00a1eb18-1d86-4c01-8ba6-5eaacdd47154",
              "name": "video_description",
              "value": "={{ $('Create video prompt').last().json.output.video_description }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        160,
        608
      ],
      "id": "73df8807-69fd-44ea-9cb6-a1fd6f2c0ada",
      "name": "Video variables"
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const result = JSON.parse($json.data.resultJson);\n$input.item.json.video_url = result.resultUrls[0];\n$input.item.json.video_watermark_url = result.resultWaterMarkUrls[0];\n\nreturn $input.item;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -272,
        448
      ],
      "id": "08ad82b0-7de0-4329-a06e-2e75058263ad",
      "name": "Setup video url"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.kie.ai/api/v1/jobs/createTask",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{\n\n  JSON.stringify({\n  \"model\": \"sora-2-text-to-video\",\n  \"callBackUrl\": \"https://your-domain.com/api/callback\",\n  \"input\": {\n    \"prompt\": $('Create video prompt').last().json.output.video_prompt,\n    \"aspect_ratio\": $('On form submission').first().json['Aspect ratio'].toLowerCase(),\n    \"n_frames\": \"10\",\n    \"remove_watermark\": true\n  }\n}, null, 2)\n\n}}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [
        0,
        0
      ],
      "id": "bdd5d154-b57d-4a5e-b523-dc5c6fcbe63d",
      "name": "Start generating the video",
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {
          "formDescription": "=Here is the video link: https://youtube.com/shorts/{{ $json.id }}"
        }
      },
      "type": "n8n-nodes-base.form",
      "typeVersion": 2.3,
      "position": [
        752,
        288
      ],
      "id": "cd74e6aa-cbc6-4cfc-8c52-aca632d34822",
      "name": "Form"
    }
  ],
  "connections": {
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Create video prompt",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Create video prompt",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Set task id": {
      "main": [
        [
          {
            "node": "Get status of the video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Get status of the video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Successful start?": {
      "main": [
        [
          {
            "node": "Set task id",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Stop and Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create video prompt": {
      "main": [
        [
          {
            "node": "Video plan approval",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get status of the video": {
      "main": [
        [
          {
            "node": "Route based on the status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route based on the status": {
      "main": [
        [
          {
            "node": "Stop and Error",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Setup video url",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start Youtube upload": {
      "main": [
        [
          {
            "node": "Download the video1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download the video1": {
      "main": [
        [
          {
            "node": "Upload video to YouTube",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Create video prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Video plan approval": {
      "main": [
        [
          {
            "node": "Approve video plan?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Approve video plan?": {
      "main": [
        [
          {
            "node": "Start generating the video",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set video plan variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set video plan variables": {
      "main": [
        [
          {
            "node": "Create video prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Video approval": {
      "main": [
        [
          {
            "node": "Approve video?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Approve video?": {
      "main": [
        [
          {
            "node": "Start Youtube upload",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Video variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Video variables": {
      "main": [
        [
          {
            "node": "Create video prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Setup video url": {
      "main": [
        [
          {
            "node": "Video approval",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start generating the video": {
      "main": [
        [
          {
            "node": "Successful start?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload video to YouTube": {
      "main": [
        [
          {
            "node": "Form",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "d202b648-a5a2-4182-9eb7-3f07773baf4c",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "7i72Us1qAJf1YmMY",
  "tags": []
}