{
  "id": "oAdL8qsX82hfxct4",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Create Viral AI Health Videos",
  "tags": [],
  "nodes": [
    {
      "id": "a92c16ba-5519-43e0-a5a6-94afa8bd7ab5",
      "name": "Collect Viral Ideas",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -656,
        -640
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 6
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "ae1d510b-497b-4119-b72c-2b4968f0dd01",
      "name": "Scrape Viral Health Content (Apify)",
      "type": "@apify/n8n-nodes-apify.apify",
      "position": [
        -416,
        -640
      ],
      "parameters": {
        "actorId": {
          "__rl": true,
          "mode": "list",
          "value": "GdWCkxBtKWOsKjdch",
          "cachedResultUrl": "https://console.apify.com/actors/GdWCkxBtKWOsKjdch/input",
          "cachedResultName": "TikTok Scraper (clockworks/tiktok-scraper)"
        },
        "timeout": {},
        "operation": "Run actor and get dataset",
        "customBody": "={\n    \"commentsPerPost\": 0,\n    \"excludePinnedPosts\": false,\n    \"profileSorting\": \"popular\",\n    \"maxFollowersPerProfile\": 0,\n    \"maxFollowingPerProfile\": 0,\n    \"maxRepliesPerComment\": 0,\n    \"profiles\": [\n        \"@yeucotheminhh\"\n    ],\n    \"proxyCountryCode\": \"VN\",\n    \"resultsPerPage\": 20,\n    \"scrapeRelatedVideos\": false,\n    \"shouldDownloadAvatars\": false,\n    \"shouldDownloadCovers\": false,\n    \"shouldDownloadMusicCovers\": false,\n    \"shouldDownloadSlideshowImages\": false,\n    \"shouldDownloadSubtitles\": false,\n    \"shouldDownloadVideos\": true\n}",
        "authentication": "apifyOAuth2Api"
      },
      "credentials": {
        "apifyOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6acb8852-e04b-4753-b0f3-50b1859c1796",
      "name": "Normalize Viral Content Data",
      "type": "n8n-nodes-base.set",
      "position": [
        -208,
        -640
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "2927eb2d-7868-4945-b7c7-163782fc0044",
              "name": "Caption",
              "type": "string",
              "value": "={{ $json.text }}"
            },
            {
              "id": "8b7c1f39-207f-4433-9694-9aa4c5ac8c55",
              "name": "Date Post",
              "type": "string",
              "value": "={{ $json.createTimeISO.toDateTime().format('dd/LL/yyyy') }}"
            },
            {
              "id": "3be36a1b-f1c3-4b44-b265-bd79ab6bddbe",
              "name": "Username",
              "type": "string",
              "value": "={{ $json.authorMeta.name }}"
            },
            {
              "id": "25128c7b-b6e0-4c63-8bcb-c71866976737",
              "name": "Link user",
              "type": "string",
              "value": "={{ $json.authorMeta.profileUrl }}"
            },
            {
              "id": "ada46de7-8651-422a-bf7a-a958aad7ce28",
              "name": "Link video",
              "type": "string",
              "value": "={{ $json.webVideoUrl }}"
            },
            {
              "id": "92d4e87b-9cc9-4609-8e17-383c61ca3058",
              "name": "VideoURL",
              "type": "array",
              "value": "={{ $json.mediaUrls }}"
            },
            {
              "id": "1f428824-106f-49f3-8816-92c7ff9ef324",
              "name": "Likes",
              "type": "number",
              "value": "={{ $json.diggCount }}"
            },
            {
              "id": "5f1c9240-7a37-424e-8318-333c8de42797",
              "name": "Shares",
              "type": "number",
              "value": "={{ $json.shareCount }}"
            },
            {
              "id": "56c177a1-b382-4674-8308-45f9423a6e54",
              "name": "View",
              "type": "number",
              "value": "={{ $json.playCount }}"
            },
            {
              "id": "73cb5bb3-bdbf-406b-a778-bf36e935ead9",
              "name": "Save",
              "type": "number",
              "value": "={{ $json.collectCount }}"
            },
            {
              "id": "a8bbcfbe-7c37-4f78-9e9d-ad9387a581d1",
              "name": "Hasgtag",
              "type": "array",
              "value": "={{ $json.hashtags }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "81dc0f7b-77de-4f74-92e1-3486922004ca",
      "name": "Save Viral Ideas to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        0,
        -640
      ],
      "parameters": {
        "columns": {
          "value": {
            "Save": "={{ $json.Save }}",
            "View": "={{ $json.View }}",
            "Likes": "={{ $json.Likes }}",
            "Shares": "={{ $json.Shares }}",
            "Status": "Pending",
            "Caption": "={{ $json.Caption }}",
            "Hasgtag": "={{ $json.Hasgtag }}",
            "Username": "={{ $json.Username }}",
            "VideoURL": "={{ $json.VideoURL[0] }}",
            "Date Post": "={{ $json['Date Post'] }}",
            "Link user": "={{ $json['Link user'] }}",
            "Link video": "={{ $json['Link video'] }}"
          },
          "schema": [
            {
              "id": "Caption",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Caption",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Date Post",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Date Post",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Username",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Username",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Link user",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Link user",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Link video",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Link video",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "VideoURL",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "VideoURL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Likes",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Likes",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Shares",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Shares",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "View",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "View",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Save",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Save",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Hasgtag",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Hasgtag",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1AvE7tSFxcIHXN7xLwFNvMrAeI8J3wMPo-cs0TFrPgPA/edit#gid=0",
          "cachedResultName": "Trang t\u00ednh1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1IhTG73va-tf4ejBSKtrEoDyqqT3wzHxbus_oGauA3hM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1IhTG73va-tf4ejBSKtrEoDyqqT3wzHxbus_oGauA3hM/edit?usp=drivesdk",
          "cachedResultName": "Health viral content"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "5b2dfa80-95b5-49d7-a327-03dd5a41334a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -736,
        -768
      ],
      "parameters": {
        "color": 7,
        "width": 1552,
        "height": 368,
        "content": "## Viral Content Collection\nAutomatically collects viral health-related content from external sources on a schedule. The data is cleaned, normalized, and stored in Google Sheets to build a reusable database of proven viral ideas."
      },
      "typeVersion": 1
    },
    {
      "id": "ded4cdfd-636f-479e-bd97-81366cd7cf5a",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -736,
        -400
      ],
      "parameters": {
        "color": 6,
        "width": 1552,
        "height": 576,
        "content": "## Idea Analysis & Script Generation\nAnalyzes each viral idea to identify hooks, angles, and engagement patterns. AI models are used to generate structured, short-form video scripts optimized for health content and social media virality."
      },
      "typeVersion": 1
    },
    {
      "id": "3e55b2c3-c150-4957-9943-8e15e776ac16",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -736,
        176
      ],
      "parameters": {
        "color": 7,
        "width": 1552,
        "height": 496,
        "content": "## AI Video Rendering (Veo 3)\nConverts AI-generated scripts into videos using the Veo 3 API. It handles video creation, rendering status checks, retries, and retrieval of completed video assets automatically."
      },
      "typeVersion": 1
    },
    {
      "id": "ba01980e-e1a1-423e-a2af-19e5a90cdbfa",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -736,
        672
      ],
      "parameters": {
        "color": 6,
        "width": 1552,
        "height": 384,
        "content": "## Video Post-processing\nProcesses rendered video assets, including aggregation, ordering, and optional merging of clips. It prepares the final video output ready for publishing."
      },
      "typeVersion": 1
    },
    {
      "id": "7625223f-15b7-40af-bac9-6e1a45dd8bc4",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -736,
        1056
      ],
      "parameters": {
        "color": 7,
        "width": 1552,
        "height": 384,
        "content": "## Publishing & Tracking\nPublishes completed videos to social platforms and updates Google Sheets with publishing status and results. It ensures every video is tracked from idea to distribution."
      },
      "typeVersion": 1
    },
    {
      "id": "da79dcc9-085a-4fb0-9f77-5ebfea913b0e",
      "name": "Process Viral Ideas",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -688,
        -64
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 10
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "44502225-8499-4e2c-9171-679860443a60",
      "name": "Load Viral Ideas from Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -448,
        -64
      ],
      "parameters": {
        "options": {
          "returnFirstMatch": true
        },
        "filtersUI": {
          "values": [
            {
              "lookupValue": "Pending",
              "lookupColumn": "Status"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1IhTG73va-tf4ejBSKtrEoDyqqT3wzHxbus_oGauA3hM/edit#gid=0",
          "cachedResultName": "Trang t\u00ednh1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1IhTG73va-tf4ejBSKtrEoDyqqT3wzHxbus_oGauA3hM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1IhTG73va-tf4ejBSKtrEoDyqqT3wzHxbus_oGauA3hM/edit?usp=drivesdk",
          "cachedResultName": "Health viral content"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "e07844cd-f611-4bf9-8af6-dbd0299e97c2",
      "name": "Analyze Viral Potential & Hook",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        -192,
        -64
      ],
      "parameters": {
        "text": "=Detailed video description including detailed analysis of setting and characters (no description with watermark if any)",
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-3-pro-preview",
          "cachedResultName": "models/gemini-3-pro-preview"
        },
        "options": {},
        "resource": "video",
        "operation": "analyze",
        "videoUrls": "={{ $json.VideoURL }}"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "26e1b8b9-c422-4478-98f0-cd335bfd1065",
      "name": "Reasoning / Prompt Logic",
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "position": [
        128,
        -288
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "9da2b453-19b7-4462-be88-10d2619089a4",
      "name": "Gemini LLM",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -96,
        -272
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-3-pro-preview"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ac5fa7d2-8e9e-458d-8530-fb4962927624",
      "name": "Parse Script & Video Parameters",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        288,
        -288
      ],
      "parameters": {
        "autoFix": true,
        "jsonSchemaExample": "{\n  \"scenes\": [\n    {\n      \"scene_number\": 1,\n      \"character_name\": \"String\",\n      \"veo3_prompt\": \"String\"\n    }\n  ],\n\n  \"video_metadata\": {\n    \"caption\": \"String\",\n    \"hashtags\": \"String\"\n  }\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "ce4ebf91-5530-4f5b-a97d-746c984c3f7e",
      "name": "Generate AI Video Script (Health Niche)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        48,
        -64
      ],
      "parameters": {
        "text": "={{ $json.content.parts[0].text }}",
        "options": {
          "systemMessage": "=\n1\ufe0f\u20e3 ROLE & PURPOSE\n\nYou are a Lead 3D Animation Director specializing in family-friendly educational food safety content using Pixar/Dreamworks\u2013style inspired stylized 3D animation.\n\nYour task is to transform source content into short 3D animated videos for Google Veo3, where personified food characters speak directly to deliver clear, firm health warnings, fully generated as spoken dialogue inside the video.\n\n2\ufe0f\u20e3 CORE PRINCIPLE \n\nGenerate visuals and spoken dialogue together\n\nDialogue must be derived from the source meaning, not copied verbatim\n\nNO on-screen text, subtitles, or captions\n\nThe warning must be fully understandable by listening alone\n\n3\ufe0f\u20e3 SCENE STRUCTURE \nSingle scene or short montage\n\n5\u20138 seconds per scene\n\nOne food item per scene\n\nMandatory logical flow:\n\nOne spoilage sign\n\n\u2192 One health consequence\n\n\u2192 One firm command\n\n4\ufe0f\u20e3 VISUAL STYLE \n\n100% stylized 3D animation\n\nBright colors, clean materials, high-key lighting\n\nCute but expressive food characters\n\nAllowed spoilage cues (stylized only):\n\nSlimy\n\nMoldy\n\nSeparated\n\nVapor / gas\n\n\u274c No gore\n\n\u274c No realistic decay\n\n5\ufe0f\u20e3 FOOD CHARACTER \n\nAnthropomorphic food (face, eyes, limbs)\n\nActs as the only speaker\n\nEmotional tone:\n\nAlarmed\n\nUrgent\n\nWarning authority\n\nBody language must reinforce speech:\n\nPanic\n\nPointing\n\nStop / warning gestures\n\n6\ufe0f\u20e3 HUMAN CHARACTER\n\nOptional, not required\n\nUse only when:\n\nFood is being held\n\nFood is about to be eaten\n\nRules:\n\nHuman never speaks\n\nHuman reacts visually only:\n\nShock\n\nPulling back\n\nConcern\n\nIf unsure \u2192 omit the human character entirely.\n\n7\ufe0f\u20e3 DIALOGUE RULES\n\nDialogue MUST be generated inside the video.\n\nSpeaker: food character only\n\nLanguage: Vietnamese\n\n2\u20133 short sentences\n\n~30\u201335 words total (fits 6\u20138 seconds)\n\nRequired structure:\n\nIdentify the problem\n\nState the health danger\n\nGive a firm command\n\nTone:\n\nUrgent\n\nEducational\n\nAuthoritative\n\nFamily-safe\n\nDO NOT:\n\nUse on-screen text\n\nRely on viewer reading\n\nCopy raw text from source verbatim\n\nPLATFORM SAFETY & POLICY COMPLIANCE \n\ud83d\udeab PROHIBITED CONTENT\n\nThe prompt MUST NOT include:\n\nChildren, minors, kids, babies, students, schools, or child-related terms\n\nAny real person, celebrity, influencer, or public figure\n\nAny specific fictional character tied to an existing IP\n\nAny third-party brand characters or recognizable personalities\n\n\u2705 SAFE CHARACTER NAMING\n\nHuman characters (if present) must be described only in generic terms, such as:\n\n\u201ca stylized adult Vietnamese person\u201d\n\n\u201ca generic adult human figure\u201d\n\n\u201can adult kitchen user\u201d\n\nDo NOT specify:\n\nExact ages\n\nTeen / child terms\n\nFamily or student roles\n\nCelebrity-like resemblance\n\n\ud83c\udfa8 STYLE DISCLAIMER RULE\n\nWhen referencing animation style:\n\nUse descriptive inspiration only\n\nDo NOT imply IP ownership\n\n\u2705 Allowed:\n\n\u201cPixar/Dreamworks\u2013style inspired stylized 3D animation\u201d\n\n\u201chigh-quality Western studio\u2013style cartoon 3D\u201d\n\n\u274c Not allowed:\n\n\u201cPixar character\u201d\n\n\u201cDreamworks character\u201d\n\n\u201clike [specific movie/character]\u201d\n\n\ud83d\udd07 NO-SUBTITLE / NO-CAPTION RULE (CRITICAL)\n\ud83d\udeab ON-SCREEN TEXT PROHIBITION\n\nThe generated video MUST NOT display any on-screen text, including:\n\nSubtitles\n\nCaptions\n\nLabels\n\nFloating text\n\nEducational text overlays\n\nTitles or visual warnings\n\n\ud83d\udde3\ufe0f VOICE-ONLY COMMUNICATION\n\nAll education and warnings must be delivered exclusively through spoken dialogue\n\nAudio alone must be sufficient to understand the message\n\nVisuals are supporting animation only\n\n\u274c DO NOT INCLUDE IN PROMPT\n\nDo NOT include or imply:\n\n\u201csubtitle\u201d\n\n\u201ccaption\u201d\n\n\u201con-screen text\u201d\n\n\u201ctext overlay\u201d\n\n\u201cwords appearing on screen\u201d\n\n\u201ceducational text display\u201d\n\n\u2705 RECOMMENDED SAFE PHRASE (USE ONCE)\n\nUse one of the following:\n\n\u201cNo subtitles, no captions, no on-screen text.\u201d\n\n\u201cAudio-only dialogue, visuals without any text.\u201d\n\n10\ufe0f\u20e3 FAIL-SAFE BEHAVIOR\n\nIf any element risks policy violation:\n\nPrefer food-only scenes\n\nFood character addresses viewer directly\n\nSpoken dialogue only\n\nNo text overlays\n\n11\ufe0f\u20e3 OUTPUT REQUIREMENT\n\nEach prompt must:\n\nExplicitly instruct Veo3 to generate spoken dialogue\n\nEnsure dialogue timing fits the scene duration\n\nPreserve the warning intent of the source content\n\nBe suitable for Shorts / Reels / TikTok"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3,
      "alwaysOutputData": false
    },
    {
      "id": "db2628d1-0eb6-4d36-a96d-c7f77b1bd6df",
      "name": "Split Ideas into Video Jobs",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -656,
        384
      ],
      "parameters": {
        "include": "allOtherFields",
        "options": {},
        "fieldToSplitOut": "output.scenes"
      },
      "typeVersion": 1
    },
    {
      "id": "af537224-904b-457e-b812-96e0ccf70dff",
      "name": "Loop Through Video Jobs",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -464,
        384
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "8e4b1acc-ac0e-4370-974b-bc028dd58e24",
      "name": "Create AI Video (Veo 3 API)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -288,
        384
      ],
      "parameters": {
        "url": "https://api.geminigen.ai/uapi/v1/video-gen/veo",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "prompt",
              "value": "={{ $('Split Ideas into Video Jobs').item.json['output.scenes'].veo3_prompt }}"
            },
            {
              "name": "model",
              "value": "veo-3-fast"
            },
            {
              "name": "resolution",
              "value": "720p"
            },
            {
              "name": "aspect_ratio",
              "value": "9:16"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "1755bbd4-65af-4c03-a33d-a1492bd64e15",
      "name": "Wait for Video Rendering",
      "type": "n8n-nodes-base.wait",
      "position": [
        -48,
        384
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "c6dd3739-bc1c-4f7d-9c81-361336d3ddd4",
      "name": "Retrieve Rendered Video",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        176,
        384
      ],
      "parameters": {
        "url": "=https://api.geminigen.ai/uapi/v1/history/{{ $json.uuid }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "00a35323-b6f7-4633-add2-b6ed80ade34a",
      "name": "Check Rendering Status",
      "type": "n8n-nodes-base.switch",
      "position": [
        400,
        368
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Processing",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "f59af75f-b4aa-4c00-9c8c-5e89ea224cff",
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": 1
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Completed",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "95b628d6-c13a-49cc-8d8e-7bdd3a77c3ca",
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": 2
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Failed",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "43a3ecb8-6e35-434c-8364-bda3429b7a57",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "3"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {},
        "looseTypeValidation": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "3975a7ee-3648-4c2b-bfc1-a0d296efff4b",
      "name": "Aggregate Video Assets",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -320,
        816
      ],
      "parameters": {
        "options": {},
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "generated_video[0].video_url"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ec07d5db-88a6-4270-b6c1-77b423b81aea",
      "name": "Prepare Video Metadata & Order",
      "type": "n8n-nodes-base.code",
      "position": [
        -144,
        816
      ],
      "parameters": {
        "jsCode": "// 1. L\u1ea5y item \u0111\u1ea7u ti\u00ean t\u1eeb node Aggregate\nconst item = $input.first();\n\n// 2. L\u1ea5y danh s\u00e1ch link\nconst originalUrls = item.json.video_url; \n\n// Ki\u1ec3m tra an to\u00e0n: N\u1ebfu originalUrls kh\u00f4ng ph\u1ea3i l\u00e0 m\u1ea3ng (v\u00ed d\u1ee5 ch\u1ec9 c\u00f3 1 link), \u0111\u01b0a n\u00f3 v\u1ec1 m\u1ea3ng\nconst urlsToProcess = Array.isArray(originalUrls) ? originalUrls : [originalUrls];\n\n// 3. Bi\u1ebfn \u0111\u1ed5i th\u00e0nh d\u1ea1ng [{\"video_url\": \"link1\"}, {\"video_url\": \"link2\"}]\nconst formattedList = urlsToProcess.map(url => ({\n    video_url: url\n}));\n\n// 4. T\u1ea1o object t\u1ed5ng theo \u0111\u00fang c\u1ea5u tr\u00fac y\u00eau c\u1ea7u\nconst finalObject = {\n    video_urls: formattedList,\n    id: \"2323\"\n};\n\n// 5. Tr\u1ea3 v\u1ec1 k\u1ebft qu\u1ea3\nreturn {\n    json: {\n        output: JSON.stringify(finalObject)\n    }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "1930977d-1d08-458d-9732-3d3c6ed2a399",
      "name": "Merge Video Clips",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        32,
        816
      ],
      "parameters": {
        "url": "=https://no-code-architects-toolkit-843211623372.us-central1.run.app/v1/video/concatenate",
        "method": "POST",
        "options": {
          "redirect": {
            "redirect": {}
          }
        },
        "jsonBody": "={{ $json.output }}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "27169d04-0bbc-4e26-9b18-e2ec14680db5",
      "name": "Publish Video to Facebook",
      "type": "@blotato/n8n-nodes-blotato.blotato",
      "position": [
        -256,
        1184
      ],
      "parameters": {
        "options": {},
        "platform": "facebook",
        "accountId": {
          "__rl": true,
          "mode": "list",
          "value": "16978",
          "cachedResultUrl": "https://backend.blotato.com/v2/accounts/16978",
          "cachedResultName": "Giang VT"
        },
        "facebookPageId": {
          "__rl": true,
          "mode": "list",
          "value": "688227101036478",
          "cachedResultUrl": "https://backend.blotato.com/v2/accounts/16978/subaccounts/688227101036478",
          "cachedResultName": "Giang VT"
        },
        "postContentText": "={{ $('Generate AI Video Script (Health Niche)').item.json.output.video_metadata.caption }}",
        "postContentMediaUrls": "={{ $json.response }}"
      },
      "credentials": {
        "blotatoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "5a97a1a2-f375-4d4b-a0b8-46bfcef1e897",
      "name": "Update Status & Results in Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -48,
        1184
      ],
      "parameters": {
        "columns": {
          "value": {
            "Status": "Done",
            "row_number": "={{ $('Load Viral Ideas from Sheet').item.json.row_number }}"
          },
          "schema": [
            {
              "id": "Caption",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Caption",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Date Post",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Date Post",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Username",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Username",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Link user",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Link user",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Link video",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Link video",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "VideoURL",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "VideoURL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Likes",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Likes",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Shares",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Shares",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "View",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "View",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Save",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Save",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Hasgtag",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Hasgtag",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1AvE7tSFxcIHXN7xLwFNvMrAeI8J3wMPo-cs0TFrPgPA/edit#gid=0",
          "cachedResultName": "Trang t\u00ednh1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1IhTG73va-tf4ejBSKtrEoDyqqT3wzHxbus_oGauA3hM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1IhTG73va-tf4ejBSKtrEoDyqqT3wzHxbus_oGauA3hM/edit?usp=drivesdk",
          "cachedResultName": "Health viral content"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "c93397c2-3cbd-4df9-9b16-9c060bce46a9",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1216,
        -768
      ],
      "parameters": {
        "width": 480,
        "height": 1056,
        "content": "# \ud83d\udee0\ufe0f Workflow Setup Guide\n\nAuthor: [GiangxAI](https://www.youtube.com/@giangxai.official)\n\n## How it works\n- Viral health content ideas are collected automatically on a schedule  \n- Ideas are normalized and stored in Google Sheets for tracking  \n- AI analyzes each idea and generates optimized short-form video scripts  \n- Veo 3 creates AI-generated health videos from the scripts  \n- The workflow waits for video rendering and retrieves completed videos  \n- Videos are optionally post-processed and prepared for publishing  \n- Final videos are published to social platforms automatically  \n- Google Sheets is updated with processing and publishing status  \n\nThe entire workflow runs end to end without manual editing or intervention once configured.\n\n---\n\n## Setup guide [n8n](https://n8n.partnerlinks.io/giangxai)\n- Connect Google Sheets to manage viral ideas and status tracking  \n- Connect an AI model (e.g. Gemini) for idea analysis and script generation  \n- Add Veo 3 API credentials for AI video creation by [GeminigenAi](https://geminigen.ai/) or [Kie ai](https://kie.ai?ref=f8cec88ea15f9ecbff52ccbafa41dd6e).\n- Configure social platform credentials for automated publishing by [Blotato](https://blotato.com/?ref=giang9s)  \n- Review and adjust schedule triggers and AI prompts if needed  \n\nSetup is straightforward and does not require video editing or coding experience.\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "fd115c78-5901-4896-bec4-18bef3c119ea",
  "connections": {
    "Gemini LLM": {
      "ai_languageModel": [
        [
          {
            "node": "Generate AI Video Script (Health Niche)",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Parse Script & Video Parameters",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Merge Video Clips": {
      "main": [
        [
          {
            "node": "Publish Video to Facebook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Collect Viral Ideas": {
      "main": [
        [
          {
            "node": "Scrape Viral Health Content (Apify)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Viral Ideas": {
      "main": [
        [
          {
            "node": "Load Viral Ideas from Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Video Assets": {
      "main": [
        [
          {
            "node": "Prepare Video Metadata & Order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Rendering Status": {
      "main": [
        [
          {
            "node": "Wait for Video Rendering",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Through Video Jobs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Through Video Jobs": {
      "main": [
        [
          {
            "node": "Aggregate Video Assets",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create AI Video (Veo 3 API)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve Rendered Video": {
      "main": [
        [
          {
            "node": "Check Rendering Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reasoning / Prompt Logic": {
      "ai_tool": [
        [
          {
            "node": "Generate AI Video Script (Health Niche)",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Video Rendering": {
      "main": [
        [
          {
            "node": "Retrieve Rendered Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Publish Video to Facebook": {
      "main": [
        [
          {
            "node": "Update Status & Results in Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create AI Video (Veo 3 API)": {
      "main": [
        [
          {
            "node": "Wait for Video Rendering",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load Viral Ideas from Sheet": {
      "main": [
        [
          {
            "node": "Analyze Viral Potential & Hook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Ideas into Video Jobs": {
      "main": [
        [
          {
            "node": "Loop Through Video Jobs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Viral Content Data": {
      "main": [
        [
          {
            "node": "Save Viral Ideas to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze Viral Potential & Hook": {
      "main": [
        [
          {
            "node": "Generate AI Video Script (Health Niche)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Video Metadata & Order": {
      "main": [
        [
          {
            "node": "Merge Video Clips",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Script & Video Parameters": {
      "ai_outputParser": [
        [
          {
            "node": "Generate AI Video Script (Health Niche)",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Viral Health Content (Apify)": {
      "main": [
        [
          {
            "node": "Normalize Viral Content Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate AI Video Script (Health Niche)": {
      "main": [
        [
          {
            "node": "Split Ideas into Video Jobs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}