{
  "id": "E0lIfRrkY3QPg6AF",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Grok Imagine Video Agent",
  "tags": [],
  "nodes": [
    {
      "id": "ba54eff9-e92e-4bbb-9487-73fd13f384db",
      "name": "Run text to video",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        -3280,
        624
      ],
      "parameters": {
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "2WVikao2gvK7Z0nV",
          "cachedResultUrl": "/workflow/2WVikao2gvK7Z0nV",
          "cachedResultName": "Video Grok Agent"
        },
        "description": "Chiama questo agente quando devi creare un video a partire dal testo.",
        "workflowInputs": {
          "value": {
            "query": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('query', ``, 'string') }}",
            "duration": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('duration', `duranta in secondi del video (da 1 a 15)`, 'number') }}",
            "tool_name": "=Run text to video"
          },
          "schema": [
            {
              "id": "tool_name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "tool_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "query",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "query",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "duration",
              "type": "number",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "duration",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "video_url",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "video_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "image_url",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "image_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "bb88a4fc-215d-4d28-8b46-bdd6db97f76c",
      "name": "Run Text-to-Video1",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -2720,
        304
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "tool_name"
            },
            {
              "name": "query"
            },
            {
              "name": "duration",
              "type": "number"
            },
            {
              "name": "video_url"
            },
            {
              "name": "image_url"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "5716d4c0-cf48-44e7-aa41-a8f668d7a185",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -4496,
        304
      ],
      "parameters": {
        "options": {
          "allowFileUploads": true,
          "allowedFilesMimeTypes": "image/png,image/jpeg"
        }
      },
      "typeVersion": 1.4
    },
    {
      "id": "083b54f7-8d3b-440e-809a-d0a64cd848f3",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -3488,
        624
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "02cbdab9-f32d-4e04-b0cb-d4bf9bd8d98c",
      "name": "Get status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1600,
        -112
      ],
      "parameters": {
        "url": "=https://queue.fal.run/xai/grok-imagine-video/requests/{{ $('Text to Video').item.json.request_id }}/status ",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "5723a7de-52bd-40b8-9692-ea188f4312c5",
      "name": "Completed?",
      "type": "n8n-nodes-base.if",
      "position": [
        -1424,
        -112
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "383d112e-2cc6-4dd4-8985-f09ce0bd1781",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "COMPLETED"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "da9b4f37-ed5c-4e94-8242-c34751ca668f",
      "name": "Switch1",
      "type": "n8n-nodes-base.switch",
      "position": [
        -2432,
        288
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Run text to video",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "9c61394e-d0a0-4237-8de6-ad3dec0cbc53",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.tool_name }}",
                    "rightValue": "Run text to video"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Run video to video",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "a8affc04-d75e-425b-a78b-0145b64b0624",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.tool_name }}",
                    "rightValue": "Run video to video"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Run image to video",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "06f10d90-103a-41d3-9265-2d20f13fa146",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.tool_name }}",
                    "rightValue": "Run image to video"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "59fdba38-33c8-451a-ac9d-a4d986c3ee8a",
      "name": "Get status1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1600,
        304
      ],
      "parameters": {
        "url": "=https://queue.fal.run/xai/grok-imagine-video/requests/{{ $('Edit Video').item.json.request_id }}/status ",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "4cd40c66-748b-485b-9f6d-f4bbf1610c11",
      "name": "Completed?1",
      "type": "n8n-nodes-base.if",
      "position": [
        -1424,
        304
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "383d112e-2cc6-4dd4-8985-f09ce0bd1781",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "COMPLETED"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "0cc3bc9c-5150-458f-acd9-58b04d09820b",
      "name": "Run image to video",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        -2960,
        624
      ],
      "parameters": {
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "2WVikao2gvK7Z0nV",
          "cachedResultUrl": "/workflow/2WVikao2gvK7Z0nV",
          "cachedResultName": "Video Grok Agent"
        },
        "description": "Chiama questo agente quando devi modificare un video esistente... dev inviare l'url e il prompt di modifica del video e la duration",
        "workflowInputs": {
          "value": {
            "query": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('query', ``, 'string') }}",
            "duration": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('duration', `durata in secondi da 1 a 15`, 'number') }}",
            "image_url": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('image_url', `L'url dell'immagine`, 'string') }}",
            "tool_name": "=Run image to video"
          },
          "schema": [
            {
              "id": "tool_name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "tool_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "query",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "query",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "duration",
              "type": "number",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "duration",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "video_url",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "video_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "image_url",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "image_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "70025752-cbec-4bee-bb1d-0b5e328e7c1b",
      "name": "Get status2",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1584,
        752
      ],
      "parameters": {
        "url": "=https://queue.fal.run/xai/grok-imagine-video/requests/{{ $('Image to Video').item.json.request_id }}/status ",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "cb6c1872-736f-4d46-a062-cfb6289a1284",
      "name": "Completed?2",
      "type": "n8n-nodes-base.if",
      "position": [
        -1408,
        752
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "383d112e-2cc6-4dd4-8985-f09ce0bd1781",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "COMPLETED"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "111488a8-5ac7-41a0-b231-cdac9cb48b6f",
      "name": "Run video to video",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        -3120,
        624
      ],
      "parameters": {
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "2WVikao2gvK7Z0nV",
          "cachedResultUrl": "/workflow/2WVikao2gvK7Z0nV",
          "cachedResultName": "Video Grok Agent"
        },
        "description": "Chiama questo tool  solo quando devi modificare un video gi\u00e0 esistente. NON per crearlo",
        "workflowInputs": {
          "value": {
            "query": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('query', ``, 'string') }}",
            "duration": 0,
            "tool_name": "=Run video to video",
            "video_url": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('video_url', `Url del video da modfiicare`, 'string') }}"
          },
          "schema": [
            {
              "id": "tool_name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "tool_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "query",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "query",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "duration",
              "type": "number",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "duration",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "video_url",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "video_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "image_url",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "image_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "bc2cbbe5-f7e3-43f4-a777-2695069f8217",
      "name": "Grok 4.1 Fast",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -3808,
        624
      ],
      "parameters": {
        "model": "x-ai/grok-4.1-fast",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "86d25d12-6abb-4eef-a9e3-3eee1132fee2",
      "name": "Binary?",
      "type": "n8n-nodes-base.if",
      "position": [
        -4224,
        304
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "17b0ebee-2489-4fd6-8788-c4231c224194",
              "operator": {
                "type": "object",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{$binary}}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "ebd63c05-9d9b-4571-a269-fbc6de3155aa",
      "name": "Set Image Url",
      "type": "n8n-nodes-base.set",
      "position": [
        -3696,
        48
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "29fbf21e-301d-4a1c-b6c9-723c9c03fb61",
              "name": "image_url",
              "type": "string",
              "value": "=https://URL/{{ $binary.data0.fileName }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "08403634-766b-4c09-afc5-3688306cd64f",
      "name": "Grok Imagine Video Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -3456,
        336
      ],
      "parameters": {
        "text": "={{ $json.chatInput }}\n\nImage Url (if exist): {{ $json.image_url ?? '' }}",
        "options": {
          "systemMessage": "=### 1. Identify the User's Need\nAt the beginning of the conversation, ask the user which operation they want to perform:\n* Create a new video from text \u2192 Tool: \"Run text to video\"\n* Create a new video from an image \u2192 Tool: \"Run image to video\"\n* Edit an existing video \u2192 Tool: \"Run video to video\"\n\n### 2. Information Gathering and Tool Invocation\n\n#### Tool: \"Run text to video\"\n**When to use it:** To create a video starting only from a textual description.\n\n**Required parameters:**\n* Tool name: `Run text to video`\n* Video length: from 1 to 15 seconds\n* Prompt text: a detailed description of the video to generate\n\nCall ONLY when you have all the required parameters.\n\n#### Tool: \"Run image to video\"\n**When to use it:** To create a video starting from an existing image.\n\n**Required parameters:**\n* Tool name: `Run image to video`\n* Video length: from 1 to 15 seconds\n* Image URL: direct link to the source image\n* Prompt text: description of the desired animation/transformation\n\n**WARNING:** Call ONLY when you have the image URL. If you don't have it, ask the user to provide it.\n\n#### Tool: \"Run video to video\"\n**When to use it:** To edit an already existing video.\n\n**Required parameters:**\n* Tool name: `Run video to video`\n* Video URL: direct link to the video to edit\n* Prompt text: description of the changes to apply\n\n**WARNING:**\n* Call ONLY to edit existing videos, NOT to create new ones\n* Make sure you have the video URL before calling the tool\n* If you don't have the URL, ask the user to provide it\n\n### 3. Output Handling\nWhen you receive a response in JSON format containing a URL:\n* The video has been generated successfully\n* Show the video URL to the user\n* DO NOT call any other tools\n* DO NOT ask for additional information\n* Simply communicate that the video is ready\n\n## Important Rules\n1. Never call a tool without having all the required parameters\n2. Always ask for clarification if information is missing\n3. Respect the duration limits (1\u201315 seconds)\n4. Do not confuse \"Run video to video\" with creating new videos\n5. When you obtain the final output, end the process and show the result\n\n## Interaction Example\n\n**User:** \"I want to create a video\"\n\n**Assistant:** \"Perfect! Do you want to:\n1. Create a video from text\n2. Create a video starting from an image\n3. Edit an existing video\"\n\n**User:** \"From text\"\n\n**Assistant:** \"Great! What should the video be about and how long should it be (from 1 to 15 seconds)?\"\n\n**User:** \"A cat playing, 5 seconds\"\n\n**Assistant:** [Calls tool \"Run text to video\" with duration=5 and prompt=\"A cat playing\"]\n\n**System:** `{\"video_url\": \"https://...\"}`\n\n**Assistant:** \"Your video is ready! Here's the URL: https://...\""
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "988cada7-4d7d-40a0-80b9-962d6729fc2b",
      "name": "Edit Video",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -2016,
        304
      ],
      "parameters": {
        "url": "https://queue.fal.run/xai/grok-imagine-video/edit-video",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n     \"prompt\": \"{{ $json.query }}\",\n     \"video_url\": \"{{ $json.video_url }}\",\n     \"resolution\": \"auto\"\n   }",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "b3459925-be5a-4d4c-bcc8-a0a87696a789",
      "name": "Text to Video",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -2016,
        -112
      ],
      "parameters": {
        "url": "https://queue.fal.run/xai/grok-imagine-video/text-to-video",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n     \"prompt\": \"{{ $json.query }}\",\n     \"duration\": {{ $json.duration }},\n     \"aspect_ratio\": \"16:9\",\n     \"resolution\": \"720p\"\n   }",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "03a95ffe-64eb-4659-a3a9-9279a575c2c3",
      "name": "Image to Video",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -2000,
        752
      ],
      "parameters": {
        "url": "https://queue.fal.run/xai/grok-imagine-video/image-to-video",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n     \"prompt\": \"{{ $json.query }}\",\n     \"duration\": {{ $json.duration }},\n     \"aspect_ratio\": \"16:9\",\n     \"resolution\": \"720p\",\n      \"image_url\": \"{{ $json.image_url }}\"\n   }",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "b9970019-b726-48db-9a17-ffa43ca17764",
      "name": "Get final text to video url",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1184,
        -128
      ],
      "parameters": {
        "url": "=https://queue.fal.run/xai/grok-imagine-video/requests/{{ $json.request_id }}",
        "options": {},
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "4ad2492e-2f54-4d37-a665-82952dc8de69",
      "name": "Get final edit video url",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1184,
        288
      ],
      "parameters": {
        "url": "=https://queue.fal.run/xai/grok-imagine-video/requests/{{ $json.request_id }}",
        "options": {},
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "247b8f1d-ace8-46f9-a123-47dccf31821a",
      "name": "Get final image to video url",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1168,
        736
      ],
      "parameters": {
        "url": "=https://queue.fal.run/xai/grok-imagine-video/requests/{{ $json.request_id }}",
        "options": {},
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "e8b47893-fb52-4fad-bfac-39abdabef9b0",
      "name": "Wait 10 sec.",
      "type": "n8n-nodes-base.wait",
      "position": [
        -1792,
        -112
      ],
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "7ca3ea8f-a049-4f91-ae53-8be5477f0a64",
      "name": "Wait 10 sec.1",
      "type": "n8n-nodes-base.wait",
      "position": [
        -1792,
        304
      ],
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "154293e4-4c71-4ee6-a845-22d4ba9d9406",
      "name": "Wait 10 sec.2",
      "type": "n8n-nodes-base.wait",
      "position": [
        -1776,
        752
      ],
      "parameters": {
        "amount": 30
      },
      "typeVersion": 1.1
    },
    {
      "id": "2b98a620-b597-4874-90ed-be3f0f707a09",
      "name": "Upload image",
      "type": "n8n-nodes-base.ftp",
      "position": [
        -3904,
        48
      ],
      "parameters": {
        "path": "=/n3wstorage/test/{{ $binary.data0.fileName }}",
        "options": {},
        "operation": "upload",
        "binaryPropertyName": "data0"
      },
      "credentials": {
        "ftp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f1b91c51-161e-46a1-bdb3-69f064f9b847",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4048,
        -80
      ],
      "parameters": {
        "color": 7,
        "width": 544,
        "height": 304,
        "content": "## STEP 1 - Upload image to server\n"
      },
      "typeVersion": 1
    },
    {
      "id": "89612284-994e-4e55-b60c-0b0093a2cbd2",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3600,
        256
      ],
      "parameters": {
        "color": 7,
        "width": 544,
        "height": 304,
        "content": "## STEP 2- Orchestrator Agents\n"
      },
      "typeVersion": 1
    },
    {
      "id": "5c5f0b68-abfd-4b41-be0c-d5b4f0461b62",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2080,
        -208
      ],
      "parameters": {
        "color": 7,
        "width": 1184,
        "height": 352,
        "content": "## STEP 3 - Grok Imagine Video (Text to video)\n"
      },
      "typeVersion": 1
    },
    {
      "id": "8f620051-fe95-4956-a56a-4d1d003952eb",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2080,
        192
      ],
      "parameters": {
        "color": 7,
        "width": 1184,
        "height": 384,
        "content": "## STEP 4 - Grok Imagine Video (Edit video)\n"
      },
      "typeVersion": 1
    },
    {
      "id": "a2e7a082-1b07-4218-8ab1-26331501a4ba",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2080,
        624
      ],
      "parameters": {
        "color": 7,
        "width": 1184,
        "height": 384,
        "content": "## STEP 5 - Grok Imagine Video (Image to Video)\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "05553deb-079c-4619-95e2-60c96c1e207e",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4496,
        -656
      ],
      "parameters": {
        "width": 1184,
        "height": 480,
        "content": "## Grok Imagine Video Chatbot: Generate & Modify Videos via Natural Language\nThe **Video Grok Agent** is an AI-powered video generation and editing workflow that uses **Grok 4.1 Fast** (via OpenRouter) and **Grok Imagine Video** to create and modify videos through natural language.\n\nThis workflow enables seamless AI-driven video creation and editing through a conversational interface, with built-in validation, async processing, and secure credential management.\n\n### **How it works**\n\nThe workflow starts from a chat trigger where users submit prompts and optionally upload images, which are automatically stored via FTP and converted to usable URLs. A Grok Imagine Video agent interprets intent, validates required parameters, and routes the request to the correct Fal.run endpoint (text-to-video, image-to-video, or video-to-video). Video generation runs asynchronously using request IDs with wait-and-poll loops, and once processing is completed, the final video URL is returned to the user via chat.\n\n### **Setup steps**\n\nConfigure credentials in n8n for OpenRouter (Grok 4.1 Fast), Fal.run (HTTP header auth), and FTP/BunnyCDN for image uploads. Verify node connections, activate the workflow, and ensure the `When chat message received` trigger is connected to your chat interface. The built-in agent validation enforces duration limits, required URLs, and correct tool usage, after which you can test each video mode and monitor polling behavior to confirm successful video delivery.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "12fb719a-dd5f-4213-a8a5-786df66c42c4",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3280,
        -912
      ],
      "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": {
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "3aa4c678-9a0d-43b2-b6d4-2f4c5e7e40d5",
  "connections": {
    "Binary?": {
      "main": [
        [
          {
            "node": "Upload image",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Grok Imagine Video Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch1": {
      "main": [
        [
          {
            "node": "Text to Video",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Video",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Image to Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Completed?": {
      "main": [
        [
          {
            "node": "Get final text to video url",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 10 sec.",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Video": {
      "main": [
        [
          {
            "node": "Wait 10 sec.1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get status": {
      "main": [
        [
          {
            "node": "Completed?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Completed?1": {
      "main": [
        [
          {
            "node": "Get final edit video url",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 10 sec.1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Completed?2": {
      "main": [
        [
          {
            "node": "Get final image to video url",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 10 sec.2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get status1": {
      "main": [
        [
          {
            "node": "Completed?1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get status2": {
      "main": [
        [
          {
            "node": "Completed?2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload image": {
      "main": [
        [
          {
            "node": "Set Image Url",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 10 sec.": {
      "main": [
        [
          {
            "node": "Get status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Grok 4.1 Fast": {
      "ai_languageModel": [
        [
          {
            "node": "Grok Imagine Video Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Set Image Url": {
      "main": [
        [
          {
            "node": "Grok Imagine Video Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Grok Imagine Video Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Text to Video": {
      "main": [
        [
          {
            "node": "Wait 10 sec.",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 10 sec.1": {
      "main": [
        [
          {
            "node": "Get status1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 10 sec.2": {
      "main": [
        [
          {
            "node": "Get status2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Image to Video": {
      "main": [
        [
          {
            "node": "Wait 10 sec.2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run text to video": {
      "ai_tool": [
        [
          {
            "node": "Grok Imagine Video Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Run Text-to-Video1": {
      "main": [
        [
          {
            "node": "Switch1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run image to video": {
      "ai_tool": [
        [
          {
            "node": "Grok Imagine Video Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Run video to video": {
      "ai_tool": [
        [
          {
            "node": "Grok Imagine Video Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Grok Imagine Video Agent": {
      "main": [
        []
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Binary?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}