8
n8n 中文网amn8n.com

Reels趋势观察器

高级

这是一个Market Research, AI Summarization领域的自动化工作流,包含 36 个节点。主要使用 If, Set, Code, Wait, Notion 等节点。 使用Gemini和Apify查找高表现Instagram Reels并将洞察保存至Notion

前置要求
  • Notion API Key
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "name": "Reels 趋势观察器",
  "nodes": [
    {
      "id": "e9aad9c8-d2ad-4e17-93cd-a7faa215a06f",
      "name": "当点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -640,
        660
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "81d68000-b6bd-42bf-8335-78e753c1f68e",
      "name": "获取来源",
      "type": "n8n-nodes-base.notion",
      "position": [
        -200,
        660
      ],
      "parameters": {
        "options": {},
        "resource": "databasePage",
        "operation": "getAll",
        "returnAll": true,
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "cachedResultName": "Sources"
        }
      },
      "credentials": {
        "notionApi": {
          "id": "kvRPd5KbcIYATwNj",
          "name": "Notion - Content Factory"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "d59e57be-ae56-4853-aa56-c0839b5fd6c1",
      "name": "变量",
      "type": "n8n-nodes-base.code",
      "position": [
        -420,
        660
      ],
      "parameters": {
        "jsCode": "const variables = {\n  // https://apify.com/apify/instagram-scraper \n  // Instagram Scraper = apify/instagram-scraper, \n  \"scrapingActorId\" : \"shu8hvrXbJbY3Eb9W\", // ID of Apify scraper\n  \"daysLimit\" : 7, // Date limit \n  \"resultsLimit\" : 3, // Results per account\n  \"maxDays\" : 2, // Sleeping || Active\n  \"translationLang\" : \"German\",\n}\n\n\nreturn [{json : variables}]"
      },
      "typeVersion": 2
    },
    {
      "id": "9dc6b692-015d-4749-bd77-a91cace88f73",
      "name": "Apify 负载",
      "type": "n8n-nodes-base.code",
      "position": [
        20,
        660
      ],
      "parameters": {
        "jsCode": "// required Simplify = true\n\nconst query = {\n    \"addParentData\": false,\n    \"directUrls\": [],\n    \"enhanceUserSearchWithFacebookPage\": false,\n    \"isUserReelFeedURL\": false,\n    \"isUserTaggedFeedURL\": false,\n    \"onlyPostsNewerThan\": ($('Variables').first().json.daysLimit ?? 10) + ' days',\n    \"resultsLimit\": $('Variables').first().json.resultsLimit ?? 5,\n    \"resultsType\": \"stories\"\n};\n\nconst urls = [];\nconst map = {};\n\nitems.forEach(item => {\n  const username = item.json.property_username || '';\n  if (username) {\n    urls.push('https://www.instagram.com/' + username + '/');\n    map[username.toLowerCase()] = item.json.id;   // Notion pageId\n  }\n});\n\nquery.directUrls = urls;\n\nreturn [\n  {\n    json: {\n      query,\n      urls,\n      map     \n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "70cb78f1-bbc9-4dca-91a6-3d54444689ec",
      "name": "开关",
      "type": "n8n-nodes-base.switch",
      "position": [
        680,
        600
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Done",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "96d0046b-c9ab-429e-b35c-3d7518564c1b",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "SUCCEEDED"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Running",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "5b1c311d-10cf-4e6f-a55c-f311c75ef444",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Get Status').item.json.status }}",
                    "rightValue": "RUNNING"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Ready",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "8376a12a-87c9-4878-b654-1c91fdfb31a2",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Get Status').item.json.status }}",
                    "rightValue": "READY"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "43b693cd-9c70-4b2c-a30b-9ec3d01fe809",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        900,
        760
      ],
      "webhookId": "6a6311dc-42d5-4329-93a2-ccd76057b31d",
      "parameters": {
        "unit": "minutes",
        "amount": 1
      },
      "typeVersion": 1.1
    },
    {
      "id": "8114cefb-bf4e-4ccd-9d27-b5858bfa4ca9",
      "name": "获取数据集项目",
      "type": "@apify/n8n-nodes-apify.apify",
      "position": [
        900,
        540
      ],
      "parameters": {
        "limit": null,
        "resource": "Datasets",
        "datasetId": "={{ $json.defaultDatasetId }}",
        "operation": "Get items"
      },
      "credentials": {
        "apifyApi": {
          "id": "ULiVF6A0w3CkwFvr",
          "name": "Apify account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2045d552-7cc9-4670-8729-faec32a2bb49",
      "name": "获取状态",
      "type": "@apify/n8n-nodes-apify.apify",
      "position": [
        460,
        660
      ],
      "parameters": {
        "runId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "resource": "Actor runs",
        "operation": "Get run"
      },
      "credentials": {
        "apifyApi": {
          "id": "ULiVF6A0w3CkwFvr",
          "name": "Apify account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e3288a62-aae7-4b7d-9081-63daac01219a",
      "name": "运行执行器",
      "type": "@apify/n8n-nodes-apify.apify",
      "position": [
        240,
        660
      ],
      "parameters": {
        "actorId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Variables').first().json.scrapingActorId }}"
        },
        "operation": "Run actor",
        "customBody": "={{ $json.query.toJsonString() }}",
        "actorSource": "store"
      },
      "credentials": {
        "apifyApi": {
          "id": "ULiVF6A0w3CkwFvr",
          "name": "Apify account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "cb8d08e4-d245-4f6f-a5e3-98860dc4e04d",
      "name": "更新账户",
      "type": "n8n-nodes-base.notion",
      "position": [
        1560,
        540
      ],
      "parameters": {
        "pageId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.notionPageId }}"
        },
        "options": {},
        "resource": "databasePage",
        "operation": "update",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Status|select",
              "selectValue": "={{ $json.publishingStatus }}"
            },
            {
              "key": "Title|title",
              "title": "={{ $json.ownerFullName }}"
            },
            {
              "key": "URL|url",
              "urlValue": "={{ $json.inputUrl }}"
            }
          ]
        }
      },
      "credentials": {
        "notionApi": {
          "id": "kvRPd5KbcIYATwNj",
          "name": "Notion - Content Factory"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "950f0ac1-11d9-4673-b751-feea0b623dc9",
      "name": "获取 Reels",
      "type": "n8n-nodes-base.notion",
      "position": [
        2000,
        540
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "key": "Date|date",
              "date": "={{ new Date(Date.now() - $('Variables').first().json.daysLimit * 24 * 60 * 60 * 1000).toISOString().split('T')[0] }}",
              "condition": "after"
            }
          ]
        },
        "options": {},
        "resource": "databasePage",
        "operation": "getAll",
        "returnAll": true,
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "cachedResultName": "Reels"
        },
        "filterType": "manual"
      },
      "credentials": {
        "notionApi": {
          "id": "kvRPd5KbcIYATwNj",
          "name": "Notion - Content Factory"
        }
      },
      "executeOnce": false,
      "typeVersion": 2.2,
      "alwaysOutputData": true
    },
    {
      "id": "52d274fb-3b99-48c7-8338-83ed7537568e",
      "name": "多对一",
      "type": "n8n-nodes-base.code",
      "position": [
        1780,
        540
      ],
      "parameters": {
        "jsCode": "const accountsMap = {};\n\nitems.forEach(item => {\n  const username = item.json.property_username || '';\n  if (username) {\n    accountsMap[username.toLowerCase()] = item.json.id;   // Notion pageId\n  }\n});\n\nreturn [\n  {\n    json: {\n      accountsMap,\n      items\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "6e9b25fe-e3ce-4cd4-91f6-4accd65f532b",
      "name": "代码",
      "type": "n8n-nodes-base.code",
      "position": [
        2220,
        540
      ],
      "parameters": {
        "jsCode": "const existingPages = {};\nfor (const page of $items('Get Reels')) {\n  const source = page.json.property_url ?? '';\n  if (source) existingPages[source] = page.json;\n}\n\nconst output = [];\nconst accountsMap = $('Many to One').first().json.accountsMap;\n\nfor (const reel of $items('Map Reels')) {\n\n  const source   = reel.json.url;          \n\n  const views = reel.json.videoViewCount;\n  var update = {\n    \"Code\": reel.json.shortCode,\n    \"SignedCode\": reel.json.shortCode + '-' + Math.random(),\n    \"IsCreated\" : false,\n    \"notionAccountPageId\" : accountsMap[ reel.json.ownerUsername.toLowerCase() ],\n          \"Views\"       : views ? views : reel.json.videoPlayCount,\n          \"Likes\"       : reel.json.likesCount,\n          \"Comments\"    : reel.json.commentsCount,\n          \"Saves\"       : reel.json.savesCount ?? 0,\n          \"Shares\"      : reel.json.sharesCount ?? 0,\n          \"Updated\"   : new Date().toISOString()\n  };\n\n  /* ------------------------------------------------- */\n  if (existingPages[source]) {\n    \n    update.notionPageId = existingPages[source].id;\n\n  } else {\n    update['IsCreated'] = true;\n    update['Caption'] = reel.json.caption;\n    update['URL'] = reel.json.url;\n    update['Hashtags'] = reel.json.hashtags.join(', ');\n    update['Duration'] = reel.json.videoDuration;\n    update['Date'] = reel.json.timestamp;\n    update['videoUrl'] = reel.json.videoUrl;\n    \n  }\n\n  output.push({json: update});\n}\n\nreturn output;   // n8n continues with one array containing both kinds of items\n"
      },
      "typeVersion": 2
    },
    {
      "id": "242b65f6-a180-4795-b18f-c0b3278dbc3d",
      "name": "映射 Reels",
      "type": "n8n-nodes-base.code",
      "position": [
        1120,
        540
      ],
      "parameters": {
        "jsCode": "const maxDays = $('Variables').first()?.json?.maxDays ?? 3;  \nconst now     = new Date();\n\n\nvar results = items;                             \nconst map   = $('Apify Payload').first().json.map;\n\n\nconst acctStatus = {};   // { username: 'Active' | 'Sleeping' }\n\nfor (const itm of results) {\n  const owner = itm.json.ownerUsername.toLowerCase();\n  const ts    = new Date(itm.json.timestamp);\n  const diff  = (now - ts) / 86_400_000;    \n\n  \n  if (!acctStatus[owner] || acctStatus[owner] === 'Sleeping') {\n    acctStatus[owner] = diff <= maxDays ? 'Active' : 'Sleeping';\n  }\n}\n\nfor (const k in results) {\n  const item   = results[k];\n  const owner  = item.json.ownerUsername.toLowerCase();\n\n  // coauthorProducers - !notionPageId\n  item.json.notionPageId     = map[owner];\n  item.json.publishingStatus = acctStatus[owner];\n\n  results[k] = item;\n}\n\nreturn results;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "f6ce6734-6bbf-451b-bc8b-e73fcad9eaac",
      "name": "创建",
      "type": "n8n-nodes-base.notion",
      "onError": "continueRegularOutput",
      "position": [
        1800,
        1360
      ],
      "parameters": {
        "title": "={{ ($json.response.hook ?? $json.Caption).substring(0, 50) }}",
        "options": {},
        "resource": "databasePage",
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "cachedResultName": "Reels"
        },
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Date|date",
              "date": "={{ $json.Date }}"
            },
            {
              "key": "Caption|rich_text",
              "textContent": "={{ $json.Caption.substring(0, 1995) }}"
            },
            {
              "key": "Duration|number",
              "numberValue": "={{ $json.Duration }}"
            },
            {
              "key": "Likes|number",
              "numberValue": "={{ $json.Likes }}"
            },
            {
              "key": "Parsed Date|date",
              "date": "={{ $now }}"
            },
            {
              "key": "URL|url",
              "urlValue": "={{ $json.URL }}"
            },
            {
              "key": "Views|number",
              "numberValue": "={{ $json.Views }}"
            },
            {
              "key": "Comments|number",
              "numberValue": "={{ $json.Comments }}"
            },
            {
              "key": "Author|relation",
              "relationValue": [
                "={{ $json.notionAccountPageId }}"
              ]
            },
            {
              "key": "Content|rich_text",
              "textContent": "=### HOOK ###\n{{ $json.response.hook }}\n\n### CONTENT ###\n{{ $json.response.transcription.substring(0, 1800) }}"
            },
            {
              "key": "Translation|rich_text",
              "textContent": "=### HOOK ###\n{{ $json.response.translation_hook }}\n\n### CONTENT ###\n{{ $json.response.translation.substring(0, 1800) }}"
            },
            {
              "key": "Type|select",
              "selectValue": "={{ $json.response.format }}"
            },
            {
              "key": "Category|select",
              "selectValue": "={{ $json.response.category }}"
            }
          ]
        }
      },
      "credentials": {
        "notionApi": {
          "id": "kvRPd5KbcIYATwNj",
          "name": "Notion - Content Factory"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "4f840157-aa84-4e1d-bc01-743b2846e733",
      "name": "更新",
      "type": "n8n-nodes-base.notion",
      "position": [
        60,
        1620
      ],
      "parameters": {
        "pageId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.notionPageId }}"
        },
        "options": {},
        "resource": "databasePage",
        "operation": "update",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Comments|number",
              "numberValue": "={{ $json.Comments }}"
            },
            {
              "key": "Likes|number",
              "numberValue": "={{ $json.Likes }}"
            },
            {
              "key": "Views|number",
              "numberValue": "={{ $json.Views }}"
            }
          ]
        }
      },
      "credentials": {
        "notionApi": {
          "id": "kvRPd5KbcIYATwNj",
          "name": "Notion - Content Factory"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "3cf91952-47b1-4bd9-9b3d-95a0b847a4cc",
      "name": "下载视频",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        40,
        1220
      ],
      "parameters": {
        "url": "={{ $json.videoUrl }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "4afd4b50-bb64-4135-9d7a-b4e2da533370",
      "name": "上传到 Gemini",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        260,
        1220
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/upload/v1beta/files",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "binaryData",
        "authentication": "predefinedCredentialType",
        "inputDataFieldName": "data",
        "nodeCredentialType": "googlePalmApi"
      },
      "credentials": {
        "openAiApi": {
          "id": "kS6Z0Hk1s9z9jto6",
          "name": "OpenAi account"
        },
        "googlePalmApi": {
          "id": "OM6UrKcjIxk9844H",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "be95f2a7-fd68-472d-b1e9-e7f47e16f61d",
      "name": "Gemini 分析",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1360,
        1220
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n\t\"contents\": [{\n\t\t\"parts\": [{\n\t\t\t\"file_data\": {\n\t\t\t\t\"file_uri\": \"{{ $('Is Uploaded And Active?').item.json.uri }}\",\n\t\t\t\t\"mime_type\": \"{{ $('Is Uploaded And Active?').item.json.mimeType }}\"\n\t\t\t}\n\t\t}, {\n\t\t\t\"text\": \"{{ $('Set Prompt').first().json.AnalyzePrompt.replaceAll(\"\\n\", '\\\\n').replaceAll('\"', '\\\"\"') }}\"\n\t\t}]\n\t}]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googlePalmApi"
      },
      "credentials": {
        "openAiApi": {
          "id": "kS6Z0Hk1s9z9jto6",
          "name": "OpenAi account"
        },
        "googlePalmApi": {
          "id": "OM6UrKcjIxk9844H",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "d8a3b6c8-dfab-4d12-ac66-dacf23c379f5",
      "name": "是否已上传并激活?",
      "type": "n8n-nodes-base.if",
      "position": [
        920,
        1220
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "8cf67b24-2993-4aed-be9d-00b88a1c5701",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.state }}",
              "rightValue": "ACTIVE"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "849c07c0-c0c9-42bf-94a7-0bb794a8bbdc",
      "name": "获取文件状态",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        700,
        1160
      ],
      "parameters": {
        "url": "={{ $json.file.uri }}",
        "options": {},
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googlePalmApi"
      },
      "credentials": {
        "openAiApi": {
          "id": "kS6Z0Hk1s9z9jto6",
          "name": "OpenAi account"
        },
        "googlePalmApi": {
          "id": "OM6UrKcjIxk9844H",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "bd77d983-4f7a-4330-b461-dd0ebc6223e8",
      "name": "处理延迟",
      "type": "n8n-nodes-base.wait",
      "position": [
        480,
        1220
      ],
      "webhookId": "3df7acce-81fc-4341-a091-fa1427977cb4",
      "parameters": {
        "unit": "minutes",
        "amount": 1
      },
      "typeVersion": 1.1
    },
    {
      "id": "36dce35b-d983-4a45-9617-ac1254f5c77c",
      "name": "格式化响应",
      "type": "n8n-nodes-base.code",
      "position": [
        1580,
        1220
      ],
      "parameters": {
        "jsCode": "\nconst rawText = $input.first().json.candidates[0].content.parts[0].text;\n\nconst cleaned = rawText\n  .replace(/^```json\\s*/, '')      \n  .replace(/\\s*```$/, '')          \n  .trim();\n\nlet parsed;\ntry {\n  parsed = JSON.parse(cleaned);\n} catch (e) {\n  return [{ json: { error: 'Invalid JSON', message: e.message } }];\n}\n\nlet item = $('Is Created?').first().json;\n\nparsed.transcription = parsed.transcription ?? '';\nparsed.hook = parsed.hook ?? '';\nparsed.category = parsed.category ?? '';\nparsed.format = parsed.format ?? '';\nparsed.translation = parsed.translation ?? '';\nparsed.translation_hook = parsed.translation_hook ?? '';\n\nitem.response = parsed;\n\n\nreturn [{ json: item }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "913daa8b-e3c5-48d9-8f1c-16746a847564",
      "name": "设置提示",
      "type": "n8n-nodes-base.set",
      "position": [
        1160,
        1240
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "01c3ca92-795f-4528-8df5-204c324c352b",
              "name": "AnalyzePrompt",
              "type": "string",
              "value": "=Perform the following tasks based on the video/audio content:\n\n1. Create a full transcription of the audio — convert speech to text exactly as spoken, without interpretation or summarization, so it can be easily read or re-voiced later.\n\n2. Identify a strong hook from the first few seconds of the content that can grab attention.\n\n3. Determine the category of the content using the following rules:\n- Business: if the video shares business advice\n- Marketing: if the video shares marketing advice\n- Cooking: if the video shares cooking advice\n- Interview: if the video is an interview with a guest\n- Unknown: if the category cannot be determined\n\n4. Identify the video format using the following options:\n- Head: if it's a talking-head video\n- Animation: if it's animated or presented with drawings\n- Unknown: if the format is unclear\n\n5. Translate the full transcription and the hook into {{ $('Variables').first().json.translationLang }}.\n\nReturn the result in **pure JSON format** with the following fields:  \n`transcription`, `hook`, `category`, `format`, `translation`, `translation_hook`.\n\n**Do not include any commentary or explanations. Only return the JSON.**"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "f623358c-c051-4cf6-9922-1cbf1f944d7b",
      "name": "所有者?",
      "type": "n8n-nodes-base.if",
      "position": [
        1340,
        540
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "7b88be8b-60c6-47b1-8a6a-4f5b97d71234",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.notionPageId }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "6ef695e9-6e2d-4bea-bfb8-ba559e6a803e",
      "name": "是否已创建?",
      "type": "n8n-nodes-base.switch",
      "position": [
        -180,
        1300
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Create",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "bed205cb-cc58-4f99-af5e-7565257ea7c4",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.IsCreated && $json.notionAccountPageId != null }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Update",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "042c2e67-6f4d-4909-a73d-eb43864203dd",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ !$json.IsCreated && $json.notionAccountPageId != null }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "5b97e7c8-9637-4763-ad8c-53a086ddc8fd",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -400,
        1400
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "635e329a-dda0-40d6-96d1-e7b384ec841b",
      "name": "统计",
      "type": "n8n-nodes-base.code",
      "position": [
        -180,
        1100
      ],
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n  item.json.myNewField = 1;\n}\n\nreturn $input.all();"
      },
      "typeVersion": 2
    },
    {
      "id": "261dc20e-b593-440b-b002-f6d1cbfbfcc0",
      "name": "计划触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -640,
        440
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 4
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5d8a6022-16bc-4211-b596-089655921209",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1320,
        -220
      ],
      "parameters": {
        "color": 7,
        "width": 520,
        "height": 360,
        "content": "### 📺 工作原理 - 观看视频"
      },
      "typeVersion": 1
    },
    {
      "id": "b7c81e9f-5d71-4ce1-b6b0-585245e0eb90",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -740,
        -220
      ],
      "parameters": {
        "color": 7,
        "width": 520,
        "height": 580,
        "content": "## ⚙️ 如何安装模板"
      },
      "typeVersion": 1
    },
    {
      "id": "af4c205f-6a9c-493f-861d-bda18d346cf5",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1320,
        200
      ],
      "parameters": {
        "color": 7,
        "width": 520,
        "height": 140,
        "content": "### 📺 视频指南"
      },
      "typeVersion": 1
    },
    {
      "id": "5acb33a7-5bc2-439f-a648-450fe97073eb",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        560
      ],
      "parameters": {
        "width": 180,
        "height": 80,
        "content": "数据库 = 来源"
      },
      "typeVersion": 1
    },
    {
      "id": "aa226eb7-84f5-41cc-87dd-a18d163ddf8b",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1960,
        420
      ],
      "parameters": {
        "width": 180,
        "height": 80,
        "content": "数据库 = Reels"
      },
      "typeVersion": 1
    },
    {
      "id": "4efaf2ee-ef7a-4f72-88cc-12eae7210b1b",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1780,
        1260
      ],
      "parameters": {
        "width": 180,
        "height": 80,
        "content": "数据库 = Reels"
      },
      "typeVersion": 1
    },
    {
      "id": "c641b324-a620-4cf8-a8ec-1b821b942425",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1080,
        1080
      ],
      "parameters": {
        "width": 300,
        "height": 100,
        "content": "这是用于处理视频内容并分类其类别和类型的提示。根据您的逻辑进行自定义。"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Get Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Owner?": {
      "main": [
        [
          {
            "node": "Update Accounts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Get dataset items",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Reels": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map Reels": {
      "main": [
        [
          {
            "node": "Owner?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Variables": {
      "main": [
        [
          {
            "node": "Get Sources",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Status": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Prompt": {
      "main": [
        [
          {
            "node": "Gemini Analyze",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Sources": {
      "main": [
        [
          {
            "node": "Apify Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Created?": {
      "main": [
        [
          {
            "node": "Download Video",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Many to One": {
      "main": [
        [
          {
            "node": "Get Reels",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run an Actor": {
      "main": [
        [
          {
            "node": "Get Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Apify Payload": {
      "main": [
        [
          {
            "node": "Run an Actor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Video": {
      "main": [
        [
          {
            "node": "Upload to Gemini",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Analyze": {
      "main": [
        [
          {
            "node": "Format Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get File State": {
      "main": [
        [
          {
            "node": "Is Uploaded And Active?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Response": {
      "main": [
        [
          {
            "node": "Create",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Stats",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Is Created?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Accounts": {
      "main": [
        [
          {
            "node": "Many to One",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Processing Delay": {
      "main": [
        [
          {
            "node": "Get File State",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        []
      ]
    },
    "Upload to Gemini": {
      "main": [
        [
          {
            "node": "Processing Delay",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get dataset items": {
      "main": [
        [
          {
            "node": "Map Reels",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Uploaded And Active?": {
      "main": [
        [
          {
            "node": "Set Prompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Processing Delay",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 市场调研, AI 摘要总结

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量36
分类2
节点类型12
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

外部链接
在 n8n.io 查看

分享此工作流