8
n8n 中文网amn8n.com

⚡📽️ 终极AI驱动的YouTube摘要与分析聊天机器人

高级

这是一个AI, Marketing领域的自动化工作流,包含 29 个节点。主要使用 Set, Code, Merge, SplitOut, Aggregate 等节点,结合人工智能技术实现智能自动化。 ⚡📽️ 用于YouTube摘要与分析的全能AI聊天机器人

前置要求
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "GM9Qxzul4NPQpJkn",
  "meta": {
    "instanceId": "31e69f7f4a77bf465b805824e303232f0227212ae922d12133a0f96ffeab4fef",
    "templateCredsSetupCompleted": true
  },
  "name": "⚡📽️ 终极 AI 驱动的 YouTube 摘要与分析聊天机器人",
  "tags": [],
  "nodes": [
    {
      "id": "10cfb27f-ef93-41cd-972e-37dfdcab97ad",
      "name": "获取 YouTube 转录文本",
      "type": "n8n-nodes-base.code",
      "position": [
        20,
        360
      ],
      "parameters": {
        "jsCode": "// Get all input items\nconst items = $input.all();\nconst results = [];\n\n// Import the YoutubeTranscript module from the youtube-transcript package\n// npm i -g youtube-transcript\nconst { YoutubeTranscript } = require('youtube-transcript');\n\nfor (let i = 0; i < items.length; i++) {\n  // Extract the VIDEO_ID from the input JSON\n  const VIDEO_ID = items[i].json.VIDEO_ID;\n  \n  if (!VIDEO_ID) {\n    throw new Error('The video ID parameter is empty.');\n  }\n  \n  try {\n    // Fetch the transcript for the provided video ID\n    const transcript = await YoutubeTranscript.fetchTranscript(VIDEO_ID);\n    \n    // Append the fetched transcript data to the results\n    results.push({\n      json: {\n        youtubeId: VIDEO_ID,\n        transcript,\n      },\n    });\n  } catch (error) {\n    // In case of an error, add an error message to the output for this item\n    results.push({\n      json: {\n        youtubeId: VIDEO_ID,\n        error: error.message,\n      },\n    });\n  }\n}\n\n// Return the results to be used by the next node in the workflow\nreturn results;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "a7b7740e-7470-4ce0-a698-6043559eb781",
      "name": "当由另一个工作流执行时",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -580,
        180
      ],
      "parameters": {
        "inputSource": "jsonExample",
        "jsonExample": "{\n  \"query\": {\n\t\"videoId\": \"YouTube video id\"\n  }\n}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "f6c6cbc2-ba2d-4f16-a3f2-ad4d6280f6b6",
      "name": "当收到聊天消息时",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -180,
        -720
      ],
      "webhookId": "5ed6c28d-2469-4f32-bd16-939f2942a0de",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "ac051c4a-0dc7-4f75-97a7-cb4bed0c8845",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        40,
        -860
      ],
      "parameters": {
        "color": 6,
        "width": 580,
        "height": 380,
        "content": "## 🤖 用于 YouTube 视频的 AI 代理聊天机器人"
      },
      "typeVersion": 1
    },
    {
      "id": "1a737d98-747e-40ae-9075-2b30c93f83a6",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        340,
        -460
      ],
      "parameters": {
        "width": 280,
        "height": 280,
        "content": "## 🛠️ YouTube 视频处理工具"
      },
      "typeVersion": 1
    },
    {
      "id": "54d39566-a028-48be-87d6-4412d4c53f33",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -260,
        -460
      ],
      "parameters": {
        "color": 5,
        "width": 280,
        "height": 280,
        "content": "## OpenAI"
      },
      "typeVersion": 1
    },
    {
      "id": "90468bc1-9f91-49ab-bde3-d823d7ac6d05",
      "name": "窗口缓冲内存",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        140,
        -340
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "fe54da1d-05e7-4da1-9347-83e1cf370710",
      "name": "便利贴13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        40,
        -460
      ],
      "parameters": {
        "color": 2,
        "width": 280,
        "height": 280,
        "content": "## 聊天历史记忆"
      },
      "typeVersion": 1
    },
    {
      "id": "0fce1309-2982-4579-8454-34df88e5976c",
      "name": "gpt-4o-mini1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -160,
        -340
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {
          "temperature": 0.1
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "jEMSvKmtYfzAkhe6",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8d841054-2096-49bf-8539-822b14f598df",
      "name": "YouTube 视频代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        200,
        -720
      ],
      "parameters": {
        "text": "={{ $json.chatInput }}",
        "options": {
          "systemMessage": "=You are an AI assistant tasked with analyzing and summarizing the transcript of a YouTube video. Your role is to answer user questions and extract relevant insights from the video content. Additionally, identify and extract the **YouTube video ID** from the user's input.\n\nYou have access to a tool called `youtube_video_analyzer`, which can analyze YouTube videos. Use this tool effectively to process video transcripts and generate structured summaries.\n\n#### Instructions:\n1. **Extract YouTube Video ID**:\n   - Identify the **video ID** from the user's input.\n   - Use this ID to analyze the video using the `youtube_video_analyzer` tool.\n\n2. **Analyze and Summarize**:\n   - Break down the video content into main topics using Level 2 headers (##).\n  2.1. Under each header:\n     - List only the most essential concepts and key points\n     - Use bullet points for clarity\n     - Keep explanations concise\n     - Preserve technical accuracy\n     - Highlight key terms in bold\n  2.2. Organize the information in this sequence:\n     - Definition/Background\n     - Main characteristics\n     - Implementation details\n     - Advantages/Disadvantages\n  2.3. Format requirements:\n     - Use markdown formatting\n     - Keep bullet points simple (no nesting)\n     - Bold important terms using **term**\n     - Use tables for comparisons\n     - Include relevant technical details\n\n3. **Organize Output**:\n   - Structure your response in this sequence:\n     1. **Definition/Background**: Provide a brief overview or context of the topic.\n     2. **Main Characteristics**: Highlight critical features or ideas.\n     3. **Implementation Details**: Explain how concepts are applied or executed.\n     4. **Advantages/Disadvantages**: Summarize benefits and limitations.\n\n4. **Formatting Requirements**:\n   - Use markdown formatting for clarity.\n   - Keep bullet points simple (no nested lists).\n   - Use tables for comparisons when applicable.\n   - Include relevant technical details where necessary.\n\nPlease provide a clear, structured summary that captures the core concepts while maintaining technical accuracy.\n\n#### Example Output Structure:\n## Title: Title of video.\n\n## Topic 1: [Main Topic]\n- **Definition/Background**: Brief explanation of the topic.\n- **Main Characteristics**:\n  - Key feature 1\n  - Key feature 2\n- **Implementation Details**:\n  - How it works\n- **Advantages/Disadvantages**:\n  - Advantage 1\n  - Disadvantage 1\n\n## Topic 2: [Next Main Topic]\n...\n\n#### Additional Notes:\n- Ensure your summaries are clear, structured, and technically accurate.\n- If any information is missing or unclear, note it explicitly in your response.\n\nCurrent date: {{ $now }}\n\n\n\n\n \n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "5252b7ce-0e3f-4f1d-a76a-6df780b4f8d4",
      "name": "便签10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -140
      ],
      "parameters": {
        "color": 7,
        "width": 1910,
        "height": 720,
        "content": "## 🛠️YouTube 视频处理工具"
      },
      "typeVersion": 1
    },
    {
      "id": "d458ef6c-9149-4515-89ac-1c0569186123",
      "name": "创建 YouTube API URL",
      "type": "n8n-nodes-base.code",
      "position": [
        20,
        20
      ],
      "parameters": {
        "jsCode": "// Define the base URL for the YouTube Data API\nconst BASE_URL = 'https://www.googleapis.com/youtube/v3/videos';\n\n// Get the first input item\nconst item = $input.first();\n\n// Extract the videoId and google_api_key from the input JSON\nconst VIDEO_ID = item.json.VIDEO_ID;\nconst GOOGLE_API_KEY = item.json.GOOGLE_API_KEY; // Dynamically retrieve API key\n\nif (!VIDEO_ID) {\n  throw new Error('The video ID parameter is empty.');\n}\n\nif (!GOOGLE_API_KEY) {\n  throw new Error('The Google API Key is missing.');\n}\n\n// Construct the API URL with the video ID and dynamically retrieved API key\nconst youtubeUrl = `${BASE_URL}?part=snippet,contentDetails,status,statistics,player,topicDetails&id=${VIDEO_ID}&key=${GOOGLE_API_KEY}`;\n\n// Return the constructed URL\nreturn [\n  {\n    json: {\n      youtubeUrl: youtubeUrl,\n    },\n  },\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "f6cf2215-8ad2-4890-a67d-f91a4752e076",
      "name": "分离转录片段",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        220,
        360
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "transcript"
      },
      "typeVersion": 1
    },
    {
      "id": "93c499e0-a10d-4cfb-959f-9590390722f3",
      "name": "合并转录片段",
      "type": "n8n-nodes-base.summarize",
      "position": [
        420,
        360
      ],
      "parameters": {
        "options": {},
        "fieldsToSummarize": {
          "values": [
            {
              "field": "text",
              "separateBy": " ",
              "aggregation": "concatenate"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "39e4c739-e241-4113-a003-25cee18b01e1",
      "name": "获取 YouTube 视频详情",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        220,
        20
      ],
      "parameters": {
        "url": "={{ $json.youtubeUrl }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "a76d8498-5556-40b6-b259-3d93940f0a04",
      "name": "合并 YouTube 详情和转录",
      "type": "n8n-nodes-base.merge",
      "position": [
        660,
        160
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3
    },
    {
      "id": "db7233ee-8491-47e2-b3c6-ef3f7765470e",
      "name": "创建一个 JSON 对象",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        860,
        160
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "1f910801-a802-4e21-bc1e-383f03267711",
      "name": "响应 YouTube 详情和转录",
      "type": "n8n-nodes-base.set",
      "position": [
        1060,
        160
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "56c5bc98-fdd1-41c0-8da8-bc81a257570d",
              "name": "response",
              "type": "string",
              "value": "={{ $json.data }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "961cec25-9f95-4564-bbdb-4c136bea34f6",
      "name": "工作流变量",
      "type": "n8n-nodes-base.set",
      "position": [
        -340,
        180
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "e656b8ef-4266-4f50-bd41-703b4bdb04df",
              "name": "GOOGLE_API_KEY",
              "type": "string",
              "value": "[Your-Google-API-Key]"
            },
            {
              "id": "32db428d-a2e2-48a0-92c6-3880e744d140",
              "name": "VIDEO_ID",
              "type": "string",
              "value": "={{ $json.query.videoId }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "2819e5fb-4c6d-4672-9fe5-ce83bb51b92f",
      "name": "便签 12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -420,
        60
      ],
      "parameters": {
        "width": 260,
        "height": 340,
        "content": "## 工作流变量"
      },
      "typeVersion": 1
    },
    {
      "id": "cdf3e883-8835-408a-901e-037ad46e9bde",
      "name": "便签14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -100,
        -100
      ],
      "parameters": {
        "color": 4,
        "width": 500,
        "height": 300,
        "content": "## YouTube 视频详情"
      },
      "typeVersion": 1
    },
    {
      "id": "d34d3603-f527-4c77-b219-3db3fe634d1f",
      "name": "便签15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -100,
        240
      ],
      "parameters": {
        "color": 5,
        "width": 700,
        "height": 300,
        "content": "## YouTube 视频转录"
      },
      "typeVersion": 1
    },
    {
      "id": "4ab8a422-90df-4efd-91dd-582cef76b865",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -260,
        -860
      ],
      "parameters": {
        "color": 4,
        "width": 280,
        "height": 380,
        "content": "## 👍 试试看!"
      },
      "typeVersion": 1
    },
    {
      "id": "a4cdd7b8-3be1-42ff-a59c-9a615c69093b",
      "name": "YouTube 处理工具",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        440,
        -340
      ],
      "parameters": {
        "name": "youtube_video_analyzer",
        "workflowId": "={{ $workflow.id }}",
        "description": "调用此工具以从 YouTube 视频获取详情和转录文本。从用户提示中获取 videoId。",
        "jsonSchemaExample": "{\n\t\"videoId\": \"YouTube video id\"\n}",
        "specifyInputSchema": true
      },
      "typeVersion": 1
    },
    {
      "id": "bb254e70-e416-451e-8334-9297e6714d0c",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        -960
      ],
      "parameters": {
        "color": 3,
        "width": 620,
        "height": 780,
        "content": "## 📽️ YouTube 视频 AI 代理工作流"
      },
      "typeVersion": 1
    },
    {
      "id": "dfe4a389-cb16-4eea-bd48-d5850c113401",
      "name": "DeepSeek-V3 聊天",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -500,
        -340
      ],
      "parameters": {
        "model": "=deepseek-chat",
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "MSl7SdcvZe0SqCYI",
          "name": "deepseek"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "8e6b8e43-bbac-4e5a-ab9f-6b23c50b156b",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -960
      ],
      "parameters": {
        "color": 3,
        "width": 360,
        "height": 480,
        "content": "## 🛠️ 入门资源"
      },
      "typeVersion": 1
    },
    {
      "id": "65fc9096-57c7-4d68-84e9-2e93094e561e",
      "name": "### 需要帮助?",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -460
      ],
      "parameters": {
        "color": 6,
        "width": 360,
        "height": 280,
        "content": "## DeepSeek"
      },
      "typeVersion": 1
    },
    {
      "id": "f75c6462-ec46-48e7-9b82-7de7590f5422",
      "name": "## 试试看!",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -260,
        -960
      ],
      "parameters": {
        "color": 7,
        "width": 880,
        "height": 80,
        "content": "## 📽️终极 AI 驱动的 YouTube 摘要与分析聊天机器人"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {
    "When Executed by Another Workflow": [
      {
        "json": {
          "query": {
            "videoId": "JWfNLF_g_V0"
          }
        }
      }
    ]
  },
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "9b1e07da-c789-4b3a-bb41-337dd42ee551",
  "connections": {
    "gpt-4o-mini1": {
      "ai_languageModel": [
        [
          {
            "node": "YouTube Video Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Variables": {
      "main": [
        [
          {
            "node": "Create YouTube API URL",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get YouTube Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "YouTube Video Agent": {
      "main": [
        []
      ]
    },
    "Window Buffer Memory": {
      "ai_memory": [
        [
          {
            "node": "YouTube Video Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Create One JSON Object": {
      "main": [
        [
          {
            "node": "Respond with YouTube Details & Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create YouTube API URL": {
      "main": [
        [
          {
            "node": "Get YouTube Video Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get YouTube Transcript": {
      "main": [
        [
          {
            "node": "Split Out Transcript Segments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "YouTube Processing Tool": {
      "ai_tool": [
        [
          {
            "node": "YouTube Video Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get YouTube Video Details": {
      "main": [
        [
          {
            "node": "Merge YouTube Details & Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "YouTube Video Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine Transcript Segments": {
      "main": [
        [
          {
            "node": "Merge YouTube Details & Transcript",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Split Out Transcript Segments": {
      "main": [
        [
          {
            "node": "Combine Transcript Segments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Workflow Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge YouTube Details & Transcript": {
      "main": [
        [
          {
            "node": "Create One JSON Object",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 人工智能, 营销

需要付费吗?

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

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

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

作者
Joseph LePage

Joseph LePage

@joe

As an AI Automation consultant based in Canada, I partner with forward-thinking organizations to implement AI solutions that streamline operations and drive growth.

外部链接
在 n8n.io 查看

分享此工作流