{
  "meta": {
    "instanceId": "a6cdf7a32b1c6530b19aaace6bb5b9be540bb598a580bc9b7d02c42c82a682d6"
  },
  "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": "生成済み",
        "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
      ],
      "webhookId": "fb884014-1f93-4808-980f-21bdccda0b84",
      "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": "生成済み"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_SPREADSHEET_ID",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/",
          "cachedResultName": "SNS(転職)"
        }
      },
      "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": "シート1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_SPREADSHEET_ID",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/",
          "cachedResultName": "SNS(転職)"
        }
      },
      "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": "=下記の内容を参照して、動画生成用のプロンプトを作成してください\n挨拶や説明文は省いてください\nプロンプトのみを出力してください\n\n#参考動画 \nタイトル： {{ $json.text }}\n動画参考URL：{{ $json.authorMeta.id }}\n\n#出力形式の例\n「ターゲット：20代の転職を考えている会社員」向けのショート動画。\n縦型9:16、動画の秒数15）。\n冒頭3秒で「一番伝えたいフレーズ（例：今の職場、3年後の自分が想像できますか？）」という大きなテロップと、\n驚いた表情の人物のタイプ（例：スーツ姿の男性会社員）のクローズアップ。\n中盤では、課題・悩み（例：残業だらけ、スキルが身につかない、不安な将来）をテキストとアイコンでテンポよく表示。\n最後は「解決策・サービス名（例：iRupで、エンジニアとしてキャリアチェンジ）」というテロップと、\n明るい表情でPCに向かう人物のカット。\n画面はポップだが落ち着いた色味、白背景ベース、テロップは日本語で太字、軽いBGM付き。",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 3
    },
    {
      "id": "e1129a37-ed62-4ddc-a4c9-fb2a8c0bc42a",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        416,
        0
      ],
      "webhookId": "471b28c1-12d5-408f-b47b-1b30202e0707",
      "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        \"転職\",\n        \"就職\"\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 ‘Execute workflow’",
      "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., \"シート1\" for raw data, \"生成済み\" 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\" (転職) and \"Employment\" (就職).\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
    }
  ],
  "pinData": {},
  "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 ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}