{
  "nodes": [
    {
      "id": "f7ea3195-b3d6-4cfc-af35-9127b141bb9c",
      "name": "Fal Submit",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1792,
        0
      ],
      "parameters": {
        "url": "https://queue.fal.run/fal-ai/veo3",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "prompt",
              "value": "={{$json[\"output\"]}}"
            },
            {
              "name": "aspect_ratio",
              "value": "9:16"
            },
            {
              "name": "duration",
              "value": "8s"
            },
            {
              "name": "generate_audio",
              "value": "true"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth"
      },
      "typeVersion": 4.3
    },
    {
      "id": "ff5841b5-57ab-4e7d-8b8d-4748b52f76ea",
      "name": "Upload file",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        2416,
        0
      ],
      "parameters": {
        "name": "\u751f\u6210\u6e08\u307f",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_DRIVE_FOLDER_ID",
          "cachedResultUrl": "https://drive.google.com/drive/folders/",
          "cachedResultName": "n8n"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "edd10d01-6c3b-4edc-9b20-0e643e3fb654",
      "name": "HTTP Request3",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2208,
        0
      ],
      "parameters": {
        "url": "={{ $node[\"Fal Submit\"].json[\"response_url\"] }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "typeVersion": 4.3
    },
    {
      "id": "4fcb6775-88ce-4791-8da0-57440aa6d2a6",
      "name": "Wait1",
      "type": "n8n-nodes-base.wait",
      "position": [
        2000,
        0
      ],
      "parameters": {
        "unit": "minutes"
      },
      "typeVersion": 1.1
    },
    {
      "id": "e4e07935-6be1-4f7e-b6f5-ff560cf2feb3",
      "name": "Limit",
      "type": "n8n-nodes-base.limit",
      "position": [
        1040,
        0
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "2132fb30-fb02-4abf-a386-0c79740d1361",
      "name": "Append or update row in sheet1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1584,
        0
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "output",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "output",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_SHEET_ID_OR_NAME",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/",
          "cachedResultName": "\u751f\u6210\u6e08\u307f"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_SPREADSHEET_ID",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/",
          "cachedResultName": "SNS(\u8ee2\u8077)"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "d56e500d-813e-4177-9bf2-af682d96e81f",
      "name": "Append or update row in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        832,
        0
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "text",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "text",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "textLanguage",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "textLanguage",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "createTime",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "createTime",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "createTimeISO",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "createTimeISO",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "isAd",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "isAd",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "authorMeta",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "authorMeta",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "musicMeta",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "musicMeta",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "webVideoUrl",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "webVideoUrl",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "mediaUrls",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "mediaUrls",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "videoMeta",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "videoMeta",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "diggCount",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "diggCount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "shareCount",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "shareCount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "playCount",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "playCount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "collectCount",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "collectCount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "commentCount",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "commentCount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "mentions",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "mentions",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "detailedMentions",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "detailedMentions",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "hashtags",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "hashtags",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "effectStickers",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "effectStickers",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "isSlideshow",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "isSlideshow",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "isPinned",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "isPinned",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "searchQuery",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "searchQuery",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "locationMeta",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "locationMeta",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_SHEET_ID_OR_NAME",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/",
          "cachedResultName": "\u30b7\u30fc\u30c81"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_SPREADSHEET_ID",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/",
          "cachedResultName": "SNS(\u8ee2\u8077)"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "d60d4cbe-ef88-434a-9a4f-8f75f22f9878",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        1232,
        208
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "ae3786f5-2407-4619-a83c-3408da37664c",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1232,
        0
      ],
      "parameters": {
        "text": "=\u4e0b\u8a18\u306e\u5185\u5bb9\u3092\u53c2\u7167\u3057\u3066\u3001\u52d5\u753b\u751f\u6210\u7528\u306e\u30d7\u30ed\u30f3\u30d7\u30c8\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\n\u6328\u62f6\u3084\u8aac\u660e\u6587\u306f\u7701\u3044\u3066\u304f\u3060\u3055\u3044\n\u30d7\u30ed\u30f3\u30d7\u30c8\u306e\u307f\u3092\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\n\n#\u53c2\u8003\u52d5\u753b \n\u30bf\u30a4\u30c8\u30eb\uff1a {{ $json.text }}\n\u52d5\u753b\u53c2\u8003URL\uff1a{{ $json.authorMeta.id }}\n\n#\u51fa\u529b\u5f62\u5f0f\u306e\u4f8b\n\u300c\u30bf\u30fc\u30b2\u30c3\u30c8\uff1a20\u4ee3\u306e\u8ee2\u8077\u3092\u8003\u3048\u3066\u3044\u308b\u4f1a\u793e\u54e1\u300d\u5411\u3051\u306e\u30b7\u30e7\u30fc\u30c8\u52d5\u753b\u3002\n\u7e26\u578b9:16\u3001\u52d5\u753b\u306e\u79d2\u657015\uff09\u3002\n\u5192\u982d3\u79d2\u3067\u300c\u4e00\u756a\u4f1d\u3048\u305f\u3044\u30d5\u30ec\u30fc\u30ba\uff08\u4f8b\uff1a\u4eca\u306e\u8077\u5834\u30013\u5e74\u5f8c\u306e\u81ea\u5206\u304c\u60f3\u50cf\u3067\u304d\u307e\u3059\u304b\uff1f\uff09\u300d\u3068\u3044\u3046\u5927\u304d\u306a\u30c6\u30ed\u30c3\u30d7\u3068\u3001\n\u9a5a\u3044\u305f\u8868\u60c5\u306e\u4eba\u7269\u306e\u30bf\u30a4\u30d7\uff08\u4f8b\uff1a\u30b9\u30fc\u30c4\u59ff\u306e\u7537\u6027\u4f1a\u793e\u54e1\uff09\u306e\u30af\u30ed\u30fc\u30ba\u30a2\u30c3\u30d7\u3002\n\u4e2d\u76e4\u3067\u306f\u3001\u8ab2\u984c\u30fb\u60a9\u307f\uff08\u4f8b\uff1a\u6b8b\u696d\u3060\u3089\u3051\u3001\u30b9\u30ad\u30eb\u304c\u8eab\u306b\u3064\u304b\u306a\u3044\u3001\u4e0d\u5b89\u306a\u5c06\u6765\uff09\u3092\u30c6\u30ad\u30b9\u30c8\u3068\u30a2\u30a4\u30b3\u30f3\u3067\u30c6\u30f3\u30dd\u3088\u304f\u8868\u793a\u3002\n\u6700\u5f8c\u306f\u300c\u89e3\u6c7a\u7b56\u30fb\u30b5\u30fc\u30d3\u30b9\u540d\uff08\u4f8b\uff1aiRup\u3067\u3001\u30a8\u30f3\u30b8\u30cb\u30a2\u3068\u3057\u3066\u30ad\u30e3\u30ea\u30a2\u30c1\u30a7\u30f3\u30b8\uff09\u300d\u3068\u3044\u3046\u30c6\u30ed\u30c3\u30d7\u3068\u3001\n\u660e\u308b\u3044\u8868\u60c5\u3067PC\u306b\u5411\u304b\u3046\u4eba\u7269\u306e\u30ab\u30c3\u30c8\u3002\n\u753b\u9762\u306f\u30dd\u30c3\u30d7\u3060\u304c\u843d\u3061\u7740\u3044\u305f\u8272\u5473\u3001\u767d\u80cc\u666f\u30d9\u30fc\u30b9\u3001\u30c6\u30ed\u30c3\u30d7\u306f\u65e5\u672c\u8a9e\u3067\u592a\u5b57\u3001\u8efd\u3044BGM\u4ed8\u304d\u3002",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 3
    },
    {
      "id": "e1129a37-ed62-4ddc-a4c9-fb2a8c0bc42a",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        416,
        0
      ],
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "de994ac2-ab0a-4517-86a3-9c0d051edfa9",
      "name": "HTTP Request1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        624,
        0
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/clockworks~tiktok-scraper/runs/last/dataset/items?token=YOUR_TOKEN_HERE",
        "options": {}
      },
      "typeVersion": 4.3
    },
    {
      "id": "4c9527a6-eb8e-4f33-802c-2d27e37b087d",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        208,
        0
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/clockworks~tiktok-scraper/runs?token=YOUR_TOKEN_HERE",
        "method": "POST",
        "options": {},
        "jsonBody": "{\n    \"excludePinnedPosts\": false,\n    \"maxProfilesPerQuery\": 10,\n    \"proxyCountryCode\": \"None\",\n    \"resultsPerPage\": 10,\n    \"scrapeRelatedVideos\": false,\n    \"searchQueries\": [\n        \"\u8ee2\u8077\",\n        \"\u5c31\u8077\"\n    ],\n    \"shouldDownloadAvatars\": false,\n    \"shouldDownloadCovers\": false,\n    \"shouldDownloadMusicCovers\": false,\n    \"shouldDownloadSlideshowImages\": false,\n    \"shouldDownloadSubtitles\": false,\n    \"shouldDownloadVideos\": false\n}",
        "sendBody": true,
        "specifyBody": "json"
      },
      "typeVersion": 4.3
    },
    {
      "id": "99f75e4a-cd04-43ee-9d29-ccb02de0ce06",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "43c7bfad-f532-485d-ab31-93fa7553b8b5",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        864,
        -544
      ],
      "parameters": {
        "color": 7,
        "width": 848,
        "height": 448,
        "content": "## How to set up\n1.  **Credentials:** Configure the following credentials in n8n:\n    *   **Apify API:** (Currently passed via URL query params in the workflow, recommended to switch to Header Auth).\n    *   **Google Sheets OAuth2:** Connect your Google account.\n    *   **OpenRouter API:** For the AI Agent.\n    *   **Fal AI (Header Auth):** For the video generation API.\n    *   **Google Drive OAuth2:** For uploading the final video.\n2.  **Google Sheets:**\n    *   Create a spreadsheet.\n    *   Note the `documentId` and update the Google Sheets nodes.\n    *   Ensure you have the necessary Sheet names (e.g., \"\u30b7\u30fc\u30c81\" for raw data, \"\u751f\u6210\u6e08\u307f\" for prompts) and columns mapped.\n3.  **Google Drive:**\n    *   Create a destination folder.\n    *   Update the **Upload file** node with the correct `folderId`.\n4.  **Apify:**\n    *   Update the `token` in the **HTTP Request** and **HTTP Request1** URLs with your own Apify API token.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "5ab251b0-f54c-4fc5-b31f-17c366c25c2c",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        -544
      ],
      "parameters": {
        "width": 752,
        "height": 448,
        "content": "## How it works / What it does\nThis workflow automates the pipeline from content research to video creation:\n1.  **Scrape Data:** It triggers an Apify actor (`clockworks/tiktok-scraper`) to search and scrape TikTok videos related to \"Job Change\" (\u8ee2\u8077) and \"Employment\" (\u5c31\u8077).\n2.  **Store Raw Data:** It saves the scraped TikTok metadata (text, stats, author info) into a Google Sheet.\n3.  **AI Analysis & Prompting:** An AI Agent (via OpenRouter) analyzes the scraped video content and creates a detailed prompt for a new video (concept, visual cues, aspect ratio).\n4.  **Log Prompts:** The generated prompt is saved to a separate tab in the Google Sheet.\n5.  **Video Generation:** The prompt is sent to **Fal AI (Veo3 model)** to generate a new 8-second, vertical (9:16) video with audio.\n6.  **Wait & Retrieve:** The workflow waits for the generation to complete, then retrieves the video file.\n7.  **Cloud Storage:** Finally, it uploads the generated video file to a specific Google Drive folder.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "45dab3cd-8c5d-4e53-8981-152dc88a82e9",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1872,
        -288
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 192,
        "content": "## Requirements\n*   **n8n Version:** 1.x or higher (Workflow uses version 4.3 nodes).\n*   **Apify Account:** With access to `clockworks/tiktok-scraper` and sufficient credits.\n*   **Fal.ai Account:** With credits for the `fal-ai/veo3` model.\n*   **OpenRouter Account:** With credits for the selected LLM.\n*   **Google Workspace:** Access to Drive and Sheets."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "HTTP Request3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Append or update row in sheet1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fal Submit": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request1": {
      "main": [
        [
          {
            "node": "Append or update row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request3": {
      "main": [
        [
          {
            "node": "Upload file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Append or update row in sheet": {
      "main": [
        [
          {
            "node": "Limit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append or update row in sheet1": {
      "main": [
        [
          {
            "node": "Fal Submit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}