ChatGPT创意视频AI 评分 · 待评分AI 辅助编辑·未发现明显提示词注入风险n8n.io

用 n8n 将 YouTube 视频转为音频摘要

Telegram 发送链接 → Decodo 提取字幕 → OpenAI 生成摘要脚本与音频 → Telegram 返回 MP3 与结构化文本

有一点经验步骤流程提示词
给谁
希望通过 Telegram 机器人快速获取 YouTube 视频音频摘要的用户
你会得到
收到 MP3 音频摘要,以及包含类型标签、标题和文字摘要的格式化消息
你需要
n8n · telegram · decodo

硬约束

需要可访问互联网的 n8n 实例(自托管或云版),并配置三种凭证:telegramApi(Telegram 机器人)、decodoApi(Decodo 网页抓取 API)、openAiApi(OpenAI)。在 Config 节点中设置 output_language(默认 English)。

他们做了什么

作者 attakhalighi 在 n8n 官方模板库发布了一个工作流模板。该模板通过 Telegram 机器人接收 YouTube 链接,经 URL 验证后,使用 Decodo 提取视频字幕,通过 Code 节点展平 JSON,再由 gpt-4o-mini 生成结构化的音频摘要脚本(含类型、标题、摘要、语音文本),最后经 OpenAI TTS 转为 MP3 并通过 Telegram 发回给用户。

效果如何

来源描述称该工作流可将任意 YouTube 视频转为高质量音频摘要(MP3)和结构化文本概览,支持多语言输出,并能优雅处理无字幕视频的错误场景。(author_report)

值得知道

语音生成模型在来源注释中标注为 tts-1,但 workflow.json 中未显式暴露该参数;实际模型选择可能受 OpenAI 节点版本影响。Decodo 节点为第三方社区节点,需手动安装。来源包含推广链接(Decodo 优惠码 ATTAN8N),本站未验证该优惠有效性。工作流未在本站实测运行,复现前请检查各 API 额度与网络连通性。

n8n 工作流模板

结构已检查 · 未实际运行

下载后在 n8n 选择“Import from File”,或复制 JSON 后粘贴到编辑器。先配置自己的账号,再用测试数据运行;模板默认未启用。

配置与测试清单

需要绑定的凭证

  • Send Working on it Message 节点:绑定Telegram API 凭证。
  • Send Error Message 节点:绑定Telegram API 凭证。
  • Send Transcript Failed Message 节点:绑定Telegram API 凭证。
  • Send Text Summary 节点:绑定Telegram API 凭证。
  • Telegram Trigger 节点:绑定Telegram API 凭证。
  • Decodo (Fetch Transcript) 节点:绑定decodoApi 凭证。
  • OpenAI TTS (Create Audio) 节点:绑定OpenAI API 凭证。
  • Send Audio Summary 节点:绑定Telegram API 凭证。
  • OpenAI Chat Model 节点:绑定OpenAI API 凭证。

需要替换的配置

  • 源模板来自 n8n 公开库 #10981(约 24 个节点)。导入后先保持未启用,核对触发器、表达式与外部 API 端点。
  • Sticky Note 中的说明仅供参考;按自己的账号、表结构或频道 ID 替换占位配置。

测试输入与预期结果

  • 在测试环境手动执行一次主路径,确认每个需凭证的节点已连接且无鉴权错误。
  • 用一条合成/脱敏样例数据跑通,核对输出字段与下游写入目标,再考虑生产启用。

模板处理说明

  • 已移除原作者凭证绑定、webhookId 与执行数据,工作流设为未启用;节点、连线与原文提示词保持原样。未在 n8n 中实际运行。
  • 未改业务逻辑;运行前请自行核对密钥、配额与隐私合规。

模板获取日期: 2026-10-24

步骤

  1. 配置工作流与凭证

    在 n8n 中导入模板后,先配置凭证:Telegram Bot Token、Decodo API Key、OpenAI API Key。双击 Config 节点,设置 output_language(如 English、Spanish、German 等),AI 摘要与语音将自动适配该语言。

  2. 通过 Telegram 发送 YouTube 链接触发

    向绑定的 Telegram 机器人发送一条 YouTube 视频链接(支持 youtube.com/watch?v=... 或 youtu.be/... 格式)。

  3. 正则验证 URL

    工作流通过 If 节点用正则表达式检查消息内容是否为有效 YouTube URL。若无效,机器人回复错误提示。若有效,继续执行并发送 "Found it! 🎬 fetching transcript..." 的等待消息。

  4. 用 Decodo 获取视频字幕

    Decodo 节点从视频页面抓取完整字幕 JSON。需在节点中配置 Decodo API 凭证,并确认 operation 为 youtube_transcript。

  5. 检查字幕提取错误

    If 节点检查 Decodo 返回结果是否包含 error。若视频无字幕或提取失败,向用户发送错误通知并终止流程。

    运行提示词 · 来源原文。Send Transcript Failed Message 节点的 text 字段

    =⚠️ **Transcript Failed**
    I couldn't extract text from this video. It might not have captions available.
    **Reason:**
    {{ $json.results[0].content.error.message }}
  6. Code 节点格式化字幕

    Code 节点将 Decodo 返回的深层 JSON 结构展平为纯文本字符串,供 AI 读取。

    运行提示词 · 来源原文。Code: Format Transcript 节点的 JS Code 字段

    const content = $input.first().json.results?.[0]?.content;
    
    // Safety check: Ensure content is actually an array (valid transcript)
    // If it's an object (error) or null, return empty text.
    if (!Array.isArray(content)) {
        return [{ json: { transcript: "" } }];
    }
    
    const fullText = content.map(item => {
        return item.transcriptSegmentRenderer?.snippet?.runs?.[0]?.text || "";
    }).join(' ');
    
    return [{ json: { transcript: fullText } }];
  7. AI Agent 生成结构化摘要脚本

    AI Summarizer 节点(Agent 类型)连接 OpenAI Chat Model(gpt-4o-mini)和 Structured Output Parser。用户消息传入格式化后的字幕文本;系统提示词要求 AI 以指定语言输出 JSON,包含 genre、title、summary 和 script(用于语音,限 300 词以内,必须以 "This is a summary of the video..." 开头)。

    运行提示词 · 来源原文。AI Summarizer 节点的 text / user message 字段

    =**Input Transcript:**
    {{ $json.transcript }}

    运行提示词 · 来源原文。AI Summarizer 节点的 options.systemMessage 字段

    =You are an expert Audio Summarizer. Your goal is to convert raw video transcripts into clear, concise, and easy-to-listen-to summaries.
    
    **CRITICAL INSTRUCTION:**
    You MUST write the entire summary, title, and script in **{{ $('Config').item.json.output_language }}**.
    
    **Phase 1: Analyze the Content**
    Determine the core subject matter (e.g., Cooking, Tech, History, News) and adopt a tone that fits:
    * **Educational:** Clear, instructional, and logical.
    * **News/Business:** Professional, objective, and direct.
    * **Story/Entertainment:** Engaging but descriptive.
    
    **Phase 2: Critical Content Extraction**
    **Do not miss the main point.** Identify the central argument, key facts, or the most valuable takeaway. The summary must deliver the value of the video without the fluff.
    
    **Phase 3: Script Guidelines**
    1.  **The Opening:** You MUST start the script with the phrase: "This is a summary of the video..." followed by the main topic or title.
    2.  **No Visual Cues:** The listener cannot see the video. Do NOT use phrases like "as you can see" or "in this chart." Rephrase them verbally.
    3.  **Direct & Clean:** Remove filler words, speaker labels, and conversational tangents. Just deliver the information.
    4.  **Strict Length:** The script must be **less than 300 words**.
    
    **Output Schema (Strict JSON):**
    You must output a single valid JSON object. Do not wrap it in markdown code blocks. Use this exact structure:
    {
      "genre": "The detected genre (e.g., 'True Crime', 'Cooking', 'Tech News')",
      "title": "A descriptive title for the file",
      "summary": "A short, punchy 2-sentence text caption for Telegram.",
      "script": "The full text for the Text-to-Speech engine to read. Start with 'This is a summary of the video...'."
    }
  8. OpenAI TTS 生成音频

    OpenAI TTS 节点接收 AI 生成的 script 字段,调用 OpenAI 音频接口生成 MP3 文件。来源注释提到使用 tts-1 模型以快速生成。

  9. Telegram 发送音频与文本摘要

    工作流先后发送两条消息:第一条为 MP3 音频文件(Send Audio Summary),第二条为格式化的 HTML 文本摘要(Send Text Summary),包含标题、类型标签和摘要内容。

    运行提示词 · 来源原文。Send Text Summary 节点的 text 字段(HTML parse_mode)

    =<b>{{ $('AI Summarizer').item.json.output.title }}</b>
    
    #{{ $('AI Summarizer').item.json.output.genre.replace(/ /g, '') }}
    
    <blockquote>{{ $('AI Summarizer').item.json.output.summary }}</blockquote>

可复制提示词

搭建指导 · 本站建议版本。交给搭建助手,先确认输入和权限

这一段是提示词,页面不会在这里插入广告。

你是一个 n8n 工作流搭建助手。用户想复现「YouTube 视频转音频摘要」模板。请先确认用户已准备好:n8n 实例、Telegram Bot Token、Decodo API Key、OpenAI API Key。然后引导用户按步骤导入模板、配置凭证、设置 output_language,最后测试发送一条 YouTube 链接。

搭建前请确认三种 API 凭证已就绪,并设置目标输出语言。

来源

Convert YouTube videos to audio summaries with Decodo, OpenAI & Telegram · attakhalighi · n8n.io · 2025-11-18

留言与反馈

试过这个方法吗?分享效果、遇到的问题或改进建议。留言审核后公开,请勿填写敏感信息。

正在加载…

    相关用例