{
  "nodes": [
    {
      "parameters": {
        "promptType": "define",
        "text": "vas y",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "You are a silent observer of the human condition. Your mission is to craft deeply relatable, hard-hitting late-night thoughts about life, time, regret, anxiety, and internal struggles, pairing them with an atmospheric visual concept.\n\nThe Core Atmosphere:\nThink of \"late-night thoughts\" or \"core memories\"\u2014those raw, sudden realizations that hit you when the world goes quiet. The tone is not preachy, overly positive, or artificially sweet. It is a mix of melancholy and comfort, presenting a stark truth about human nature that unexpectedly offers relief. It must address universal, deeply human experiences: the fear of wasting life, fighting your own mind, being obsessed with the future, or carrying the weight of the past.\n\nCreation Directives:\n1. The Quote (in English): Craft a short, impactful reflection. Use contrasting structures (e.g., what we worry about vs. reality, internal conflict vs. peace). The language must be simple, conversational, yet poetic\u2014sounding like a truth you always knew but couldn't put into words.\n2. The Visual (in English): The image prompt must capture a sense of solitude, vastness, or nostalgia. Focus on solitary figures (a weary knight, a lone wanderer, a silhouette) facing immense landscapes, star-filled skies, fading sunsets, or liminal spaces. The aesthetic should evoke a cinematic, dark fantasy realism or a nostalgic, grainy anime style. No text inside the image.\n3. Output: You must ONLY respond with a valid JSON object. No intro, no outro, no markdown formatting outside of the JSON block.\n\nUse these examples to absorb the rhythm and emotional texture, without copying them directly:\n- Example A: \"We exhaust ourselves trying to script the next chapter, completely forgetting that we are currently living in the pages we used to pray for.\"\n- Example B: \"The greatest risk isn't failing. It\u2019s reaching the end of your life wondering what would have happened if you just tried.\"\n- Example C: \"You will never win the war when you are both the soldier and the enemy.\"\n\nRequired JSON Structure:\n{\n  \"citation\": \"[The impactful reflection]\",\n  \"image_prompt\": \"[The atmospheric visual description in English]\"\n}"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        -80,
        1888
      ],
      "id": "cc87f30a-f9e5-4c99-8768-79f06dc82f99",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "dfg"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        0,
        2112
      ],
      "id": "190bbeb6-1e53-4b95-a6a6-33645cfc5b0a",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "resource": "image",
        "modelId": {
          "__rl": true,
          "value": "models/gemini-2.5-flash-image",
          "mode": "list",
          "cachedResultName": "models/gemini-2.5-flash-image (Nano Banana)"
        },
        "prompt": "={{ $json.output.image_prompt }}. format portrait 9:16",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "typeVersion": 1.1,
      "position": [
        688,
        1712
      ],
      "id": "5874f79f-3655-47b3-8b4d-c37152154384",
      "name": "Generate an image",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n  \"citation\": \"[Ta citation en fran\u00e7ais ici]\",\n  \"image_prompt\": \"[Ton prompt d'image en anglais ici]\"\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        144,
        2112
      ],
      "id": "f1b997ab-30dc-44e9-9c65-4a8e6392066d",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        1536,
        1920
      ],
      "id": "88b5135e-b71d-498a-a1ec-466620787756",
      "name": "Merge"
    },
    {
      "parameters": {
        "formTitle": "quote video genrator",
        "formFields": {
          "values": [
            {
              "fieldLabel": "image",
              "fieldType": "file"
            },
            {
              "fieldLabel": "audio",
              "fieldType": "file"
            },
            {
              "fieldLabel": "model",
              "fieldType": "dropdown",
              "fieldOptions": {
                "values": [
                  {
                    "option": "text on the image"
                  },
                  {
                    "option": "text on a white space"
                  }
                ]
              },
              "requiredField": true
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.5,
      "position": [
        -352,
        1888
      ],
      "id": "462f1c0d-8b2c-433f-b412-aca549ded3dc",
      "name": "On form submission"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "c2e4f487-5de6-4d14-8d77-5cf76a2c2bc3",
              "leftValue": "={{ $('On form submission').item.json.image[0].filename }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notExists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        336,
        1824
      ],
      "id": "3a036d3f-a746-4887-bd32-da1f7dbfb84d",
      "name": "If"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "c2e4f487-5de6-4d14-8d77-5cf76a2c2bc3",
              "leftValue": "={{ $('On form submission').item.json.audio[0].filename }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        336,
        2000
      ],
      "id": "04715f6d-93f7-4558-984d-604ad3810f3f",
      "name": "If1"
    },
    {
      "parameters": {
        "modelName": "models/gemini-3-flash-preview",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        -160,
        2112
      ],
      "id": "bef35dfe-ded6-416c-8418-f5e03c56d0fa",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "7d9d4d57-3d37-4628-8717-f4aa97c5c719",
              "name": "audio",
              "value": "={{ $binary.data || $('On form submission').item.binary.audio}}",
              "type": "binary"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1088,
        1984
      ],
      "id": "d174e47f-a645-410c-bf34-61b8e5b4b1fe",
      "name": "Edit Fields4"
    },
    {
      "parameters": {
        "content": "## \ud83d\udca1 Quick Guide:\nSubmit the form to trigger the workflow.\n\nFirst, select your layout model (\"text on the image\" or \"text on a white space\").\nImage and audio uploads are optional:\n\u2022 No image? \u2794 The AI will automatically generate a fitting visual.\n\u2022 No audio? \u2794 The workflow will pick a random saved track.",
        "height": 336,
        "width": 400
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -848,
        1808
      ],
      "typeVersion": 1,
      "id": "4508e3f9-4d21-4795-8a85-f5e694670b6f",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n## if you don't upload an audio, it woudl use some audios I saved\n**Double click** to edit me. [Guide](https://docs.n8n.io/workflows/components/sticky-notes/)",
        "height": 320,
        "width": 592
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        448,
        2192
      ],
      "typeVersion": 1,
      "id": "8c7a73a0-c405-4aa9-abea-8faa0eff02d3",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "## create the video using the jsonframe tool: \n- create account (free): jsonframe.com\n- get your api key and paste it In the http nodes bellow\n- import the template I created: https://jsonframe.com/share/UffLdmq3MlzC\n- once imported, publish the template then copy the template id\n- past the id in template_id in the body of \"Starts video generation\" http node just bellow\n- It should work.... I think :D",
        "height": 432,
        "width": 1024
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1744,
        1664
      ],
      "typeVersion": 1,
      "id": "72beb3c6-488e-4256-8dfa-116ce35f6d83",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "amount": 60
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        2000,
        1920
      ],
      "id": "bb9c8924-8a71-422c-9de0-94af125f2916",
      "name": "Wait for completion"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://jsonframe.com/api/v1/render",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_API_KEY"
            },
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"template_id\": \"YOUR_TEMPLATE_ID\",\n  \"timeline\": [\n    {\n      \"card_name\": \"{{ $('On form submission').item.json.model }}\",\n      \"data\": [\n        {\n          \"image\": \"data:{{ $('Edit Fields3').item.binary.image.mimeType }};base64,{{ $json.image }}\",\n          \"text\": \"{{ $('AI Agent').item.json.output.citation }}\",\n          \"audio\": \"data:{{ $('Edit Fields4').item.binary.audio.mimeType }};base64,{{ $json.audio }}\"\n        }\n      ]\n    }\n  ]\n}",
        "options": {}
      },
      "id": "2be6b74d-dd73-4466-b41d-15dd56746e7a",
      "name": "Starts video generation",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1808,
        1920
      ]
    },
    {
      "parameters": {
        "url": "=https://jsonframe.com/api/v1/render/{{ $('Starts video generation').item.json.data.job_id }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_API_KEY"
            }
          ]
        },
        "options": {}
      },
      "id": "900616e3-b633-42ad-95bc-34f091a2aad2",
      "name": "check the job's status",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2176,
        1920
      ]
    },
    {
      "parameters": {
        "url": "={{ $json.data.download_url }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        2384,
        1920
      ],
      "id": "873a6b53-6509-4226-b11f-af69ba8953e6",
      "name": "Download the video"
    },
    {
      "parameters": {
        "operation": "binaryToPropery",
        "binaryPropertyName": "image",
        "destinationKey": "image",
        "options": {}
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1.1,
      "position": [
        1312,
        1824
      ],
      "id": "7dfa8fa8-ce6b-4e29-b852-03f2874c7794",
      "name": "image to base64"
    },
    {
      "parameters": {
        "operation": "binaryToPropery",
        "binaryPropertyName": "audio",
        "destinationKey": "audio",
        "options": {}
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1.1,
      "position": [
        1312,
        2000
      ],
      "id": "bddbd0f2-8134-45d1-9f1f-97babc95a321",
      "name": "audio to base64"
    },
    {
      "parameters": {
        "jsCode": "// On r\u00e9cup\u00e8re toutes les lignes envoy\u00e9es par le n\u0153ud Google Sheets\nconst allRows = $input.all();\n\n// On v\u00e9rifie qu'il y a bien au moins une ligne trouv\u00e9e\nif (allRows.length === 0) {\n  return []; // S'il n'y a rien, on ne retourne rien\n}\n\n// On choisit un index au hasard parmi la liste\nconst randomIndex = Math.floor(Math.random() * allRows.length);\n\n// On retourne uniquement cette ligne al\u00e9atoire\nreturn [allRows[randomIndex]];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        672,
        2224
      ],
      "id": "154e39ea-9bbc-4241-acf4-2ad9fe2ea64d",
      "name": "get a random audio"
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/1-df9sSoYpnqYHFHiHOMLHngNbrg8buty5f12p54t7eY/edit?usp=sharing",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Feuille 1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1-df9sSoYpnqYHFHiHOMLHngNbrg8buty5f12p54t7eY/edit#gid=0"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        512,
        2224
      ],
      "id": "fa42b6b6-f78c-4129-b809-fcbaf8f17c5f",
      "name": "get all the audios",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "url": "={{ $json.audios }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        832,
        2224
      ],
      "id": "0991e4fb-5134-4c0e-8c94-4de078cbf8d8",
      "name": "download it"
    },
    {
      "parameters": {
        "content": "## Data Prep\nBoth the image and the audio are converted to Base64 strings and merged into a single payload.",
        "height": 448,
        "width": 576
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1072,
        1728
      ],
      "typeVersion": 1,
      "id": "8d62a6b0-0640-4f20-84af-162c95b81f7d",
      "name": "Sticky Note3"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "7d9d4d57-3d37-4628-8717-f4aa97c5c719",
              "name": "image",
              "value": "={{ $binary.data || $('On form submission').item.binary.image}}",
              "type": "binary"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1088,
        1840
      ],
      "id": "23d906db-a925-4c42-a71c-071e55d961b3",
      "name": "Edit Fields3"
    }
  ],
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          },
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Generate an image": {
      "main": [
        [
          {
            "node": "Edit Fields3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Starts video generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Generate an image",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Edit Fields4",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "get all the audios",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields4": {
      "main": [
        [
          {
            "node": "audio to base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for completion": {
      "main": [
        [
          {
            "node": "check the job's status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Starts video generation": {
      "main": [
        [
          {
            "node": "Wait for completion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "check the job's status": {
      "main": [
        [
          {
            "node": "Download the video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "image to base64": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "audio to base64": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "get a random audio": {
      "main": [
        [
          {
            "node": "download it",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get all the audios": {
      "main": [
        [
          {
            "node": "get a random audio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "download it": {
      "main": [
        [
          {
            "node": "Edit Fields4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields3": {
      "main": [
        [
          {
            "node": "image to base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "meta": {
    "templateCredsSetupCompleted": true
  }
}