AI Deep Research Agent Using Apify and Notion - n8n Workflow

Deploy a self-hosted AI Deep Research Agent using n8n and OpenAI. This powerful n8n workflow performs recursive web searches, extracts data using Apify, and generates comprehensive reports in Notion.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Data Analysts and Researchers needing automated, in-depth data collection.
Developers looking to build advanced AI agents using the n8n automation platform.
Users seeking to replicate OpenAI's 'Deep Research' feature using self-hosted or open source automation.
Technical users who require complex, asynchronous workflows leveraging n8n templates.

Overview

This comprehensive automation solution transforms a simple research prompt into a multi-stage, recursive investigation process, achieving in minutes what might take a human hours. The core value of this n8n workflow lies in its ability to dynamically generate follow-up research queries based on initial findings (breadth) and repeat the process across multiple iterations (depth). By integrating with cutting-edge LLMs (OpenAI) and specialized web scraping services (Apify), this n8n template ensures high-quality data collection. The final output is a structured, markdown-formatted report automatically uploaded to a user-defined Notion database, providing a seamless experience from prompt submission to final report delivery.

How it Works

The process begins when a user submits a prompt via the n8n form trigger, defining the research query and two critical parameters: depth (number of research iterations) and breadth (number of sources/sub-queries per iteration).


  1. Input and Clarification: Initial variables are set. An initial LLM call may generate clarification questions if the prompt is ambiguous. These questions are presented back to the user via a dynamically generated n8n form.

  2. Notion Initialization: Once the query is finalized, the workflow uses an LLM to generate a title and description, creating a placeholder row in a Notion database. The core research job is then initiated asynchronously using an Execute Workflow n8n node, allowing the initial user interaction to terminate quickly.

  3. Recursive Deep Search Loop: The workflow enters a recursive loop controlled by the JobType Router and Accumulate Results nodes. In each iteration, an LLM generates specific SERP queries based on the current prompt and all 'learnings' accumulated so far.

  4. Data Extraction (Apify): Each generated query is sent to Apify's RAG Web Browser via an HTTP Request n8n node, which performs a web search and extracts relevant content in Markdown format.

  5. Learning Compilation: The extracted content is summarized by another OpenAI LLM, generating structured 'learnings' and potential follow-up questions for the next iteration. These learnings accumulate throughout the recursive process.

  6. Final Report Generation: When the defined depth is reached, the recursive loop terminates. All collected learnings are passed to the final report-generating LLM (DeepResearch Report), which produces a detailed report in Markdown format.

  7. Notion Upload and Cleanup: The Markdown report is chunked, converted to Notion-compatible JSON blocks using a dedicated LLM (Notion Block Generator), and uploaded sequentially to the Notion page created in step 2. Finally, the Notion entry's status is updated to 'Done', completing the n8n workflow.

Installation Guide

To deploy this powerful n8n workflow, follow these steps:


  1. Import the n8n workflow: Copy the provided JSON data and paste it into your n8n instance using the 'New' -> 'Import from JSON' function.

  2. Set Up Credentials: You will need valid credentials for the following services:

OpenAI: For the reasoning and generation models (o3-mini recommended).
Notion: Connect your Notion account and ensure you select or create a database that matches the required properties (Title, Description, Status, Request ID). Update the Create Row and Get Existing Row n8n nodes with your specific database ID.
* Apify: You need an API key for the RAG Web Browser actor. Update the RAG Web Browser n8n node with your Apify credentials (Header Auth is recommended, often using a 'Bearer' token format).

  1. Publish and Test: Publish the n8n workflow to activate the form trigger. Access the form URL provided by the On form submission n8n trigger to initiate the research process. Ensure the 'Execute Workflow' n8n nodes reference the correct ID of the published workflow for proper asynchronous and recursive execution.

Node Details

On form submission (n8n trigger): The starting point of this n8n workflow. It collects the user's research query, desired depth, and breadth using a custom-styled form interface.
OpenAI Chat Model / Clarifying Questions (LLM Chain): Uses an OpenAI n8n node (o3-mini) with a structured output parser to determine if the initial prompt requires clarification, generating up to three follow-up questions.
Create Row (Notion n8n node): Creates the initial empty Notion database page to serve as the destination for the final report.
Initiate DeepResearch (Execute Workflow n8n node): Triggers an asynchronous, separate execution of this same n8n workflow, passing necessary initial data. This enables the recursive loop needed for deep research.
RAG Web Browser (HTTP Request n8n node): Calls the Apify RAG Web Browser actor. This n8n node performs the web search and content extraction, crucial for the data gathering phase of the n8n workflow.
DeepResearch Learnings (LLM Chain + Structured Output): This crucial component uses an OpenAI n8n node to process the raw markdown content scraped by Apify, synthesizing it into concise, structured 'learnings' and further follow-up questions.
Accumulate Results (Set n8n node): Manages the state of the recursive loop by collecting all learnings and URLs gathered across all iterations, and checks if the defined research depth has been reached.
DeepResearch Report (LLM Chain): The final LLM integration. This n8n node takes all accumulated 'learnings' and the original prompt to generate the comprehensive, multi-page report in Markdown format.
Notion Block Generator (Google Gemini Chat Model): A dedicated LLM model used to convert the generated Markdown/HTML report structure into the specific JSON block schema required by the Notion API for proper formatting.
Upload to Notion Page (HTTP Request n8n node): Directly interacts with the Notion API endpoint to sequentially patch the blocks (content) onto the previously created report page.

Related n8n Workflows

Free

Nodes: 23 Nodes
Updated: December 26 2025
View all
Created by
Jimleuk
Jimleuk

Freelance consultant based in the UK specialising in AI-powered automations. I work with select clients tackling their most challenging projects. For business enquiries, send me an email at [email protected] LinkedIn: https://www.linkedin.com/in/jimleuk/ X/Twitter: https://x.com/jimle_uk

Featured*