ChatGPT软件基础设施AI 评分 · 待评分AI 辅助编辑·未发现明显提示词注入风险n8n.io

用 n8n + Apify + OpenAI o3 自建 AI 深度研究助手

通过表单提交研究主题 → 递归搜索与网页抓取 → 推理模型汇总生成报告 → 写入 Notion

经验丰富步骤流程提示词贴士
给谁
需要在团队内部部署类 OpenAI DeepResearch 能力的研究人员、自动化工程师
你会得到
用户填写表单后,工作流自动执行多轮网络搜索、内容抓取与推理汇总,最终生成结构化研究报告并保存至 Notion
你需要
n8n · apify · notion · gemini

硬约束

前置条件:可访问的 n8n 实例;OpenAI API 密钥(o3-mini 或 o1 系列);Apify API 密钥;Notion 集成密钥与已复制的数据库模板;可选 Google Gemini API 密钥。将模板导入 n8n 后,配置各节点凭证,发布工作流并确保表单 URL 可公开访问。

他们做了什么

作者 jimleuk 基于 David Zhang 的开源 deep-research 实现,在 n8n 中构建了一个复刻 OpenAI DeepResearch 功能的模板。该模板使用 n8n 表单作为前端,通过递归子工作流模式执行多轮网络搜索与网页抓取,利用 OpenAI o3-mini 的推理能力汇总学习要点并生成 Markdown 报告,最终转换为 Notion 块格式写入数据库。

效果如何

作者报告(author_report):depth=1 & breadth=2 约需 5-10 分钟;depth=1 & breadth=3 约需 15-20 分钟;depth=3 & breadth=5 可能超过 2 小时。成本随深度与广度指数增长。模板在 n8n.io 上发布, viewed 79,870 次。

值得知道

1. 作者明确说明未使用 Firecrawl.ai 而选择 Apify 是出于成本与性能考虑,但用户可替换为其他搜索/抓取服务;2. 递归循环依赖精确的「execute once」与「execute for each item」节点设置,修改节点时需保留原执行模式;3. 自托管 n8n 用户可考虑用社区节点或 martian/notionmd 替代 LLM 转换 Notion 块,以提升效率;4. 模板中的 LLM 提示词(prompts)有改进空间,建议按实际用例调整;5. 除 o3-mini 外,可实验 o1、Deepseek、Gemini 2.0 等推理模型;6. 本站未实测该工作流,reproduction=not_tested。

n8n 工作流模板

结构已检查 · 未实际运行

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

配置与测试清单

需要绑定的凭证

  • OpenAI Chat Model 节点:绑定OpenAI API 凭证。
  • OpenAI Chat Model1 节点:绑定OpenAI API 凭证。
  • OpenAI Chat Model2 节点:绑定OpenAI API 凭证。
  • OpenAI Chat Model3 节点:绑定OpenAI API 凭证。
  • OpenAI Chat Model4 节点:绑定OpenAI API 凭证。
  • Create Row 节点:绑定Notion API 凭证。
  • Get Existing Row 节点:绑定Notion API 凭证。
  • Set In-Progress 节点:绑定Notion API 凭证。
  • Set Done 节点:绑定Notion API 凭证。
  • Google Gemini Chat Model 节点:绑定Google Gemini/PaLM API 凭证。
  • Upload to Notion Page 节点:绑定Notion API 凭证。
  • Get Existing Row1 节点:绑定Notion API 凭证。
  • RAG Web Browser 节点:绑定httpQueryAuth 凭证。
  • RAG Web Browser 节点:绑定HTTP Header Auth 凭证。

需要替换的配置

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

测试输入与预期结果

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

模板处理说明

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

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

步骤

  1. 提交研究主题

    用户通过公开表单填写研究问题,并选择深度(depth,默认 1,范围 1-5)与广度(breadth,默认 2,范围 1-5)。提交后,LLM 生成最多 3 个澄清问题,通过循环表单收集用户回答,最终合并为完整查询。

    运行提示词 · 来源原文。Clarifying Questions 节点 (Basic LLM Chain) 的 text 参数

    =Given the following query from the user, ask some follow up questions to clarify the research direction. Return a maximum of 3 questions, but feel free to return less if the original query is clear: <query>{{ $json.prompt }}</query>`

    运行提示词 · 来源原文。Clarifying Questions 与 Generate SERP Queries 等节点共享的 system message (messages.messageValues[0])

    =You are an expert researcher. Today is {{ $now.toLocaleString() }}. Follow these instructions when responding:
      - You may be asked to research subjects that is after your knowledge cutoff, assume the user is right when presented with news.
      - The user is a highly experienced analyst, no need to simplify it, be as detailed as possible and make sure your response is correct.
      - Be highly organized.
      - Suggest solutions that I didn't think about.
      - Be proactive and anticipate my needs.
      - Treat me as an expert in all subject matter.
      - Mistakes erode my trust, so be accurate and thorough.
      - Provide detailed explanations, I'm comfortable with lots of detail.
      - Value good arguments over authorities, the source is irrelevant.
      - Consider new technologies and contrarian ideas, not just the conventional wisdom.
      - You may use high levels of speculation or prediction, just flag it for me.
  2. 在 Notion 创建报告占位页

    根据合并后的查询,LLM 生成报告标题与描述,在指定的 Notion 数据库中创建新页面,状态设为「未开始」,并记录请求 ID 用于后续关联更新。

    运行提示词 · 来源原文。Report Page Generator 节点 (Basic LLM Chain) 的 text 参数

    =Create a suitable title for the research report which will be created from the user's query.
    <query>{{ $json.query }}</query>
  3. 异步启动深度研究

    通过 Execute Workflow 节点以非阻塞方式触发子工作流执行深度研究,同时将 Notion 页面状态更新为「进行中」。用户无需保持浏览器开启。

  4. 递归搜索与知识积累

    子工作流通过 JobType Router 分发任务。对每条查询:使用 Basic LLM Chain 生成 SERP 查询词 → 调用 Apify RAG Web Browser 执行搜索与网页抓取 → 过滤有效结果 → 由 o3-mini 提取最多 3 条学习要点(learnings)与后续问题。学习要点跨轮次累积,直到达到设定的 depth 上限。

    运行提示词 · 来源原文。Generate SERP Queries 节点 (Basic LLM Chain) 的 text 参数

    =Given the following prompt from the user, generate a list of SERP queries to research the topic.
    Reduce the number of words in each query to its keywords only.
    Return a maximum of {{ $('JobType Router').first().json.data.breadth }} queries, but feel free to return less if the original prompt is clear. Make sure each query is unique and not similar to each other: <prompt>{{ $('JobType Router').first().json.data.query.trim() }}</prompt>
    
    {{
    $('JobType Router').first().json.data.learnings.length
      ? `Here are some learnings from previous research, use them to generate more specific queries:\n${$('JobType Router').first().json.data.learnings.map(text => `* ${text}`).join('\n')}`
      : ''
    }}

    运行提示词 · 来源原文。DeepResearch Learnings 节点 (Basic LLM Chain) 的 text 参数

    =Given the following contents from a SERP search for the query <query>{{ $('Item Ref').first().json.query }}</query>, generate a list of learnings from the contents. Return a maximum of 3 learnings, but feel free to return less if the contents are clear. Make sure each learning is unique and not similar to each other. The learnings should be concise and to the point, as detailed and infromation dense as possible. Make sure to include any entities like people, places, companies, products, things, etc in the learnings, as well as any exact metrics, numbers, or dates. The learnings will be used to research the topic further.
    
    <contents>
    {{
    $input
      .all()
      .map(item =>`<content>\n${item.json.markdown.substr(0, 25_000)}\n</content>`)
      .join('\n')
    }}
    </contents>
  5. 生成最终研究报告

    所有轮次的学习要点汇总后,交由 o3-mini 生成完整的 Markdown 格式研究报告,要求 3 页以上,包含全部学习要点,使用标题、列表和表格。

    运行提示词 · 来源原文。DeepResearch Report 节点 (Basic LLM Chain) 的 text 参数

    =You are are an expert and insightful researcher.
    * Given the following prompt from the user, write a final report on the topic using the learnings from research.
    * Make it as as detailed as possible, aim for 3 or more pages, include ALL the learnings from research.
    * Format the report in markdown. Use headings, lists and tables only and where appropriate.
    
    <prompt>{{ $('JobType Router').first().json.data.query }}</prompt>
    
    Here are all the learnings from previous research:
    
    <learnings>
    {{
    $('JobType Router').first().json.data
      .all_learnings
      .map(item => `<learning>${item}</learning>`)  
      .join('\n')
    }}
    </learnings>
  6. 转换为 Notion 块格式

    报告先由 Markdown 节点转为 HTML,再分割为语义片段。每个片段交由 Google Gemini 2.0 Flash 转换为符合 Notion API 规范的 JSON 块(含标题、段落、列表、表格)。同时用 Code 节点将来源 URL 列表批量转换为 bulleted_list_item 块。

    运行提示词 · 来源原文。Notion Block Generator 节点 (Basic LLM Chain) 的 messages.messageValues[0].message 参数

    =Convert the following html into its equivalent Notion Block as per Notion's API schema.
    * Ensure the content is always included and remains the same.
    * Return only a json response.
    * Generate child-level blocks. Should not define "parent" or "children" property.
    * Strongly prefer headings, paragraphs, tables and lists type blocks.
    * available headings are heading_1, heading_2 and heading_3 - h4,h5,h6 should use heading_3 type instead. ensure headings use the rich text definition.
    * ensure lists blocks include all list items.
    
    ## Examples
    
    1. headings
    ```
    <h3 id="references">References</h3>
    ```
    would convert to 
    ```
    {"object":  "block", "type": "heading_3", "heading_3": { "rich_text": [{"type": "text","text": {"content": "References"}}]}}
    ```
    
    2. lists
    ```
    <ul><li>hello</li><li>world</li></ul>
    ```
    would convert to
    ```
    [
    {
      "object": "block",
      "type": "bulleted_list_item",
      "bulleted_list_item": {"rich_text": [{"type": "text","text": {"content": "hello"}}]}
    },
    {
      "object": "block",
      "type": "bulleted_list_item",
      "bulleted_list_item": {"rich_text": [{"type": "text","text": {"content": "world"}}]}
    }
    ]
    ```
    
    3. tables
    ```
    <table>
      <thead>
        <tr><th>Technology</th><th>Potential Impact</th></tr>
      </thead>
      <tbody>
        <tr>
          <td>5G Connectivity</td><td>Enables faster data speeds and advanced apps</td>
        </tr>
      </tbody>
    </table>
    ```
    would convert to
    ```
    {
      "object": "block",
      "type": "table",
      "table": {
        "table_width": 2,
        "has_column_header": true,
        "has_row_header": false,
        "children": [
          {
            "object": "block",
            "type": "table_row",
            "table_row": {
              "cells": [
                [
                  {
                    "type": "text",
                    "text": {
                      "content": "Technology",
                      "link": null
                    }
                  },
                  {
                    "type": "text",
                    "text": {
                      "content": "Potential Impact",
                      "link": null
                    }
                  }
                ],
                [
                  {
                    "type": "text",
                    "text": {
                      "content": "5G Connectivity",
                      "link": null
                    }
                  },
                  {
                    "type": "text",
                    "text": {
                      "content": "Enables faster data speeds and advanced apps",
                      "link": null
                    }
                  }
                ]
              ]
            }
          }
        ]
      }
    }
    ```
    4. anchor links
    Since Notion doesn't support anchor links, just convert them to rich text blocks instead.
    ```
    <a href="#module-0-pre-course-setup-and-learning-principles">Module 0: Pre-Course Setup and Learning Principles</a>
    ```
    converts to
    ```
    {
      "object": "block",
      "type": "paragraph",
      "paragraph": {
        "rich_text": [
          {
            "type": "text",
            "text": {
              "content": "Module 0: Pre-Course Setup and Learning Principles"
            }
          }
        ]
      }
    }
    ```
    5. Invalid html parts
    When the html is not syntax valid eg. orphaned closing tags, then just skip the conversion and use an empty rich text block.
    ```
    </li>\n</ol>
    ```
    can be substituted with
    ```
    {
      "object": "block",
      "type": "paragraph",
      "paragraph": {
        "rich_text": [
          {
            "type": "text",
            "text": {
              "content": " "
            }
          }
        ]
      }
    }
    ```
  7. 写入 Notion 并标记完成

    通过 HTTP Request 节点调用 Notion API 逐块追加内容(含重试机制),最后更新页面状态为「完成」并记录最后更新时间。

可复制提示词

搭建指导 · 本站建议版本。交给搭建助手,协助用户完成环境准备与模板导入配置

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

你是一个 n8n 工作流搭建助手。用户希望复现「自建 AI 深度研究助手」模板。请按以下顺序协助:1) 确认用户已准备 n8n 实例、OpenAI API 密钥、Apify API 密钥、Notion 集成密钥及复制的数据库模板;2) 指导导入 workflow.json 并配置五个凭证节点(openAiApi、notionApi、googlePalmApi、httpQueryAuth、httpHeaderAuth);3) 说明 depth/breadth 参数对时间与成本的影响;4) 提醒发布工作流并公开表单 URL。不要替用户执行任何 API 调用或凭证填写。

搭建前请确认所有外部服务凭证已就绪,特别是 Apify 的 Header Auth 需填写 "Bearer <api_key>" 格式

来源

Host your own AI deep research agent with n8n, Apify and OpenAI o3 · jimleuk · n8n.io · 2025-02-11

留言与反馈

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

正在加载…

    相关用例