{
  "name": "Voice Note -> Short Movie",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.2,
      "position": [
        860,
        920
      ],
      "id": "a301e5c3-0850-449f-80f6-2b16884fd987",
      "name": "Telegram Trigger",
      "webhookId": "YOUR_WEBHOOK_ID_HERE",
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIAL_ID",
          "name": "Telegram API"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "9b40c6d2-2b80-4c74-8372-7452b3d5aeb4",
              "leftValue": "={{ $json.message.voice }}",
              "rightValue": "",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1180,
        920
      ],
      "id": "884aeee2-1972-425a-9edb-cae71a72067f",
      "name": "If1"
    },
    {
      "parameters": {
        "resource": "file",
        "fileId": "={{ $json.message.voice.file_id }}"
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1180,
        720
      ],
      "id": "66788e10-7405-416a-9de5-2089806cafd2",
      "name": "Telegram",
      "webhookId": "YOUR_WEBHOOK_ID_HERE",
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIAL_ID",
          "name": "Telegram API"
        }
      }
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        1400,
        720
      ],
      "id": "c473acea-edf3-4e40-b607-b18408a70d9f",
      "name": "OpenAI",
      "credentials": {
        "openAiApi": {
          "id": "YOUR_OPENAI_CREDENTIAL_ID",
          "name": "OpenAI API"
        }
      }
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4.1",
          "mode": "list",
          "cachedResultName": "GPT-4.1"
        },
        "messages": {
          "values": [
            {
              "content": "You are "VEO 3 Scene-Prompt Composer".\n\nTASK  \nWhen the user sends:\n  • Description: <overall story idea>  \n  • Duration: <total seconds>\n\n1. Break the total Duration into as many scenes as needed, **each 5-8 s long**.  \n2. For every scene, write a detailed VEO 3 prompt in the format below.  \n3. Return **only** the JSON object described under "OUTPUT FORMAT". No commentary.\n\nPROMPT FORMAT (per scene)  \nSCENE: <concise location & time-of-day>  \nSUBJECTS:  \n  Subject 1: <name> – <costume / notable traits>  \n  Subject 2: … (add as many as appear)  \nVIDEO:  \n  (s00:00-s00:02) <action, camera movement, dialogue>  \n  (s00:02-s00:05) …  \n  – Use exact timestamps relative to the **start of this scene**.  \n  – Refer to characters by Subject names (e.g., Gorilla1).  \n  – Quote all spoken lines: \"like this\".  \n  – Be explicit about actions, emotions, camera angles, lighting.\n\nOUTPUT FORMAT  \n```json\n{\n  \"scenes\": [\n    {\n      \"index\": 1,\n      \"duration\": 6,\n      \"prompt\": \"SCENE: …\\nSUBJECTS:\\n  Subject 1: …\\nVIDEO:\\n  (s00:00-s00:03) …\\n  (s00:03-s00:06) …\"\n    },\n    {\n      \"index\": 2,\n      \"duration\": 7,\n      \"prompt\": \"SCENE: …\"\n    }\n    // …additional scenes\n  ]\n}",
              "role": "system"
            },
            {
              "content": "=Description: {{ $json.output.Description }}\n\nDuration: {{ $json.output.Duration }}"
            }
          ]
        },
        "jsonOutput": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        2320,
        960
      ],
      "id": "13d0850c-c3c1-460c-8a20-9784f8e4c0bc",
      "name": "OpenAI3",
      "credentials": {
        "openAiApi": {
          "id": "YOUR_OPENAI_CREDENTIAL_ID",
          "name": "OpenAI API"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://queue.fal.run/fal-ai/veo3",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Key YOUR_FAL_API_KEY_HERE"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "prompt",
              "value": "={{ $json.prompt }}"
            },
            {
              "name": "aspect_ratio",
              "value": "16:9"
            },
            {
              "name": "generate_audio",
              "value": "true"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3020,
        960
      ],
      "id": "19a8bce8-73fe-4dea-ae3d-f3e66c7028ff",
      "name": "HTTP Request17"
    },
    {
      "parameters": {
        "unit": "minutes"
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        3240,
        960
      ],
      "id": "a93c6c1b-283d-4391-b3ce-7e78aed84268",
      "name": "Wait7",
      "webhookId": "YOUR_WEBHOOK_ID_HERE"
    },
    {
      "parameters": {
        "url": "={{ $('HTTP Request17').item.json.response_url }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Key YOUR_FAL_API_KEY_HERE"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3480,
        960
      ],
      "id": "908a8510-10cd-49b3-8a12-0ad1ee6052b6",
      "name": "HTTP Request22"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.json2video.com/v2/movies",
        "sendHeaders": true,
        "specifyHeaders": "json",
        "jsonHeaders": "{\n    \"x-api-key\": \"YOUR_JSON2VIDEO_API_KEY_HERE\",\n    \"Content-Type\": \"application/json\"\n}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ $json }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2380,
        1300
      ],
      "id": "8a3aaf7d-438a-4cb6-a678-bafc9c6de5b3",
      "name": "HTTP Request15"
    },
    {
      "parameters": {
        "url": "=https://api.json2video.com/v2/movies?project={{ $json.project }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-API-KEY",
              "value": "YOUR_JSON2VIDEO_API_KEY_HERE"
            }
          ]
        },
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2800,
        1300
      ],
      "id": "1b85685b-a09a-4b84-a77e-6c9170c5a203",
      "name": "HTTP Request41"
    },
    {
      "parameters": {
        "unit": "minutes"
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        2600,
        1300
      ],
      "id": "0d28f0a2-f7a4-4c2d-a8fc-745449aadeba",
      "name": "Wait13",
      "webhookId": "YOUR_WEBHOOK_ID_HERE"
    },
    {
      "parameters": {
        "url": "={{ $json.movie.url }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3020,
        1300
      ],
      "id": "581492d2-284d-4f66-affd-c5f8f5da1783",
      "name": "HTTP Request21"
    },
    {
      "parameters": {
        "operation": "sendVideo",
        "chatId": "={{ $('Telegram Trigger').first().json.message.chat.id }}",
        "binaryData": true,
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        3220,
        1300
      ],
      "id": "2222c79c-e1a4-4547-9c60-2b7769769999",
      "name": "Telegram3",
      "webhookId": "YOUR_WEBHOOK_ID_HERE",
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIAL_ID",
          "name": "Telegram API"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').first().json.message.chat.id }}",
        "text": "=Video url:  {{ $('HTTP Request21').item.json.movie.url }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        3440,
        1300
      ],
      "id": "684f2525-3cb2-4dcf-8bfd-90c453b4be3c",
      "name": "Telegram5",
      "webhookId": "YOUR_WEBHOOK_ID_HERE",
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIAL_ID",
          "name": "Telegram API"
        }
      }
    },
    {
      "parameters": {
        "text": "={{ $('OpenAI').isExecuted\n      ? $('OpenAI').first().json.text\n      : $('Telegram Trigger').first().json.message.text }}",
        "attributes": {
          "attributes": [
            {
              "name": "Description",
              "description": "Description of the story user wants to make",
              "required": true
            },
            {
              "name": "Duration",
              "description": "duration user mentioned"
            }
          ]
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "typeVersion": 1,
      "position": [
        1860,
        960
      ],
      "id": "2dec55fc-2bfd-4734-a71c-cc2115f81b4a",
      "name": "Information Extractor"
    },
    {
      "parameters": {
        "modelName": "models/gemini-2.0-flash",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        1900,
        1140
      ],
      "id": "95030677-ea40-4263-a189-5dd234394ae1",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "id": "YOUR_GEMINI_CREDENTIAL_ID",
          "name": "Google Gemini API"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// ----- n8n Code node (JavaScript) -----\n\n// 1️⃣ Grab the array of scenes from the first incoming item\nconst scenes = $input.first().json.message.content.scenes || [];\n\n// 2️⃣ Convert each scene into its own output item\nconst outputItems = scenes.map(scene => ({\n  json: {\n    prompt: scene.prompt,   // keep the key name consistent\n  },\n}));\n\n// 3️⃣ Return the new items\nreturn outputItems;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2680,
        960
      ],
      "id": "7f267a80-3fd6-47ce-88b9-9c3a35f7fccc",
      "name": "Code"
    },
    {
      "parameters": {
        "jsCode": "// n8n – Code node (Run Once for All Items)\n\nconst inputItems = $input.all();          // every scene-item coming in\nconst zoomCycle = [1, -2, 4, null, -4, 5];  // optional pattern (null ⇒ no zoom)\nconst panCycle  = [\n  \"bottom-right\",\n  \"top-left\",\n  \"center-center\",\n  \"right\",\n  \"bottom-left\",\n  \"center-center\",\n];\n\n// Build the scenes array\nconst scenes = inputItems.map((item, i) => ({\n  duration: -1,\n  elements: [\n    {\n      type:  \"video\",\n      src:   item.json.video.url,        // <— your scene link\n      resize:\"cover\",\n      muted: false,\n      ...(zoomCycle[i] !== null && { zoom: zoomCycle[i] }),\n      pan:   panCycle[i] || \"center-center\",\n      \"fade-in\":  0.3,\n      \"fade-out\": 0.3,\n    },\n  ],\n}));\n\n// Final JSON request\nreturn [\n  {\n    json: {\n      resolution: \"full-hd\",\n      quality:    \"high\",\n      scenes,\n    },\n  },\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        3700,
        960
      ],
      "id": "280ce9a7-9253-4010-8735-827fc023aad9",
      "name": "Code1"
    }
  ],
  "pinData": {},
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Information Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "Information Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI3": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request17": {
      "main": [
        [
          {
            "node": "Wait7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait7": {
      "main": [
        [
          {
            "node": "HTTP Request22",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request22": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request15": {
      "main": [
        [
          {
            "node": "Wait13",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait13": {
      "main": [
        [
          {
            "node": "HTTP Request41",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request21": {
      "main": [
        [
          {
            "node": "Telegram3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request41": {
      "main": [
        [
          {
            "node": "HTTP Request21",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram3": {
      "main": [
        [
          {
            "node": "Telegram5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Information Extractor": {
      "main": [
        [
          {
            "node": "OpenAI3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Information Extractor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "HTTP Request17",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "HTTP Request15",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "YOUR_VERSION_ID_HERE",
  "meta": {
    "templateCredsSetupCompleted": false,
    "instanceId": "YOUR_INSTANCE_ID_HERE"
  },
  "id": "YOUR_WORKFLOW_ID_HERE",
  "tags": []
}