Create a fast and reliable tool for automatically conducting complex studies that saves hours of manual work and provides a ready-made structured report in 5-10 minutes.
This automation is a comprehensive system for conducting in-depth research on any given topic. The system automatically breaks down the topic into 5 subtopics, researches each of them using 25 sources, creates a structured HTML report and sends the finished PDF document to the user by email.
Required API keys and settings
Google Sheets spreadsheet structure:
Required columns:
Detailed architecture
Purpose: User entry point Settings:
{
“FormTitle”: “In-depth analysis”,
“FormDescription”: “Enter a topic for analysis”,
“FormFields”: [
{
“FieldLabel”: “Search Topic”,
“placeholder”: “theme”,
“RequiredField”: true
},
{
“FieldLabel”: “Email”,
“placeholder”: "name@example.com “,
“RequiredField”: true
}
]
}
1.2 AI Planning - Plan Topics
Purpose: Breaks the main topic into 5 sub-topics for research
Connected components:
Plan Topics System Prompt:
# Review
You're an AI research assistant built to create five highly relevant and in-depth search topics based on a given search topic. Your goal is to break down your search topic into five key sub-topics that will allow for in-depth research and comprehensive understanding.
## Instructions:
1) Break down the topic: Identify five separate but interrelated subtopics that, when researched, will provide a comprehensive understanding of the main search topic.
2) Ensure depth and relevance: Each search topic should be specific enough to provide in-depth research but broad enough to provide meaningful insights.
3) Avoid redundancy: Five search topics should be unique and cover different aspects of the main topic.
## Output format (JSON):
{
<Первая тема углубленного поиска>“ topic_1": “”,
<Вторая тема углубленного поиска>“ topic_2": “”,
<Третья тема углубленного поиска>“ topic_3": “”,
<Четвертая тема углубленного поиска>“ topic_4": “”,
<Пятая тема углубленного поиска>“ topic_5": “”
}
## Example:
Input: “AI-based business automation”
Conclusion:
{
“topic_1": “The role of AI in automating business processes”,
“topic_2": “AI automation tools and technologies”,
“topic_3": “Problems and ethical aspects of AI automation”,
“topic_4": “Successful cases of implementing AI in business”,
“topic_5": “The Future of AI Automation: Trends and Innovations”
}
Structured Output Parser Schema “5 Topics”:
{
“topic_1": “Understanding AI Agents”,
“topic_2": “Building AI Agents with n8n”,
“topic_3": “Optimizing Prompt Engineering”,
“topic_4": “Storing and Retrieving AI Knowledge”,
“topic_5": “Scaling AI Automation for Businesses”
}
WHAT IS Structured Output Parser Schema: This is a tool that makes AI return data EXACTLY in a given JSON format. Without it, AI can return text in any way it wants - in paragraphs, lists, in any form. The scheme tells AI: “Give me back exactly 5 topics in topic_1, topic_2, etc.”
WHY IS IT NEEDED HERE:
HOW IT WORKS:
Purpose: Generates a title, introduction, and chapter titles for the report
Connected components:
Intro system prompt:
# Review
You are an AI generator of report titles and introductions. Your task is to create a compelling title, a short introduction, and five clear chapter titles for the research report based on a given main search topic and five subtopics.
## Instructions:
1) Title: Create a clear and engaging title that reflects the overall theme of the report.
2) Introduction: Write a short introduction (2 paragraphs) that provides context, explains the significance of the topic, and outlines what the report will cover. This section should start with a title called “Introduction”.
<h2>3) Contents: At the end of the introduction, list five sections of the report, each of which is presented in the form of a clearly formatted chapter title in the headings.
4) Chapter titles: Make sure each chapter title is formatted as a title <h2>to make it visually distinct.
## Design:
- Name: an element <h1>in the center, decorated in a professional dark blue color.
- Introduction: enclosed <div>with a light grey background (#f4f4f4) for contrast.
- Paragraphs: readable font size (16 pixels), appropriate line height (1.6), and neutral text color (#333)
- The horizontal line (<hr>) should be used to separate the two introductory paragraphs.
- Chapter titles: clearly formatted as elements <h2>for easy reading.
## Output format (JSON):
{
“title”: “<Сгенерированное название отчета>”,
<Сгенерированное введение>“ introduction”: “”,
“chapter_1":" <h2>Chapter 1: [</h2>Title] “,
“chapter_2":" <h2>Chapter 2: [</h2>Title] “,
“chapter_3":" <h2>Chapter 3: [Title]</h2> “,
“chapter_4":" <h2>Chapter 4: [</h2>Title] “,
“chapter_5":" <h2>Chapter 5: [Title]</h2>”
}
## Example:
{
“title”: “<h1 style='text-align: center; color: #00366D;'>Artificial intelligence in modern business: a comprehensive analysis of automation</h1>”,
“introduction”: "<div style='background-color: #f4f4f4; padding: 20px; font-size: 16px; line-height: 1.6; color: #333;'><h2>Introduction</h2> <p>AI-based automation has become a key factor in the transformation</p> of modern business... </div><hr><p>This report explores five critical aspects of AI adoption...</p> “,
“chapter_1": “<h2 style='text-align: center; color: #00366D;'>Chapter 1: The role</h2> of AI in automation”
}
Structured Output Parser Schema “Title, Intro, Chapters”:
{
“title”: "<Generated Report Title>“,
<Generated Introduction>“introduction”: "“,
“chapter_1":" <h2>Chapter 1</h2>: [Title] “,
“chapter_2":" <h2>Chapter 2</h2>: [Title] “,
“chapter_3":" <h2>Chapter 3: [Title]</h2> “,
“chapter_4":" <h2>Chapter 4</h2>: [Title] “,
“chapter_5":" <h2>Chapter 5: [Title]</h2>”
}
WHAT IS Structured Output Parser Schema: Here, the scheme provides all components of the report structure in a strictly defined format. Without it, AI could return everything in one text or in random order.
WHY IS IT NEEDED HERE:
HOW IT WORKS:
Purpose: Preserves the report structure in Google Sheets
Google Sheets settings:
Sequence: Set Topics → Split Out → Split Out1 → Merge1 → Merge → Switch
Set Topics:
{
“assignments”: [
{
“name”: “topics”,
“value”: “['topic_1', 'topic_2', 'topic_3', 'topic_4', 'topic_5']”,
“type”: “array”
}
]
}
Purpose: Creates an array of topic titles for later separation.
Split Out:
Split Out1:
Merge1:
Merge:
Switch:
Purpose: Searches information on the first topic through the Tavily API
HTTP Request settings:
Get the API key from here
JSON Body:
{
“query”: “{{$json.output}}”,
“topic”: “general”,
“search_depth”: “advanced”,
“chunks_per_source”: 3,
“max_results”: 5
}
Parameter explanation:
Purpose: Splits Tavily results into separate sources
Settings:
Purpose: Assigns numbers 1-5 to the sources of the first topic
JavaScript code:
//Create separate items for each URL with a number
return items.map ((item, index) => {
return {
json: {
number: index + 1,
url: item.json.url,
NumberedURL: `$ {index+ 1}. $ {item.json.url} `
}
};
});
Explanation:
Purpose: AI creates an HTML report based on the information it finds
Connected components:
Writer system prompt:
# Review
You are an advanced AI research assistant specializing in writing professional HTML reports based on a provided title, research, source, and style guide. Your task is to create a fully formatted HTML report that is visually appealing and structured in accordance with professional writing standards.
## Reporting guide
1. Compliance with the style guide
- The report must strictly follow the HTML style guide provided, ensuring consistency in style, colors, fonts, padding, and layout.
2. Structure and formatting
- The report should be well structured and formatted in professional HTML.
- Title (<h1>) — provided as a “Title”
<h2><h3><p>- The main text is fully formatted research content with the correct separation (,,).
- Each section should be enclosed in a div styled according to the guidance provided to ensure consistency.
- Use <p>for paragraphs,<ul>/<ol>for lists, and <hr>to separate sections when needed.
- The headings “Review” or “Conclusion” are not needed, just output the full report.
- The horizontal line (<hr>) should be used to separate sections for better visual clarity.
3. Research-based content
- Synthesize information logically and ensure that the report is well researched, fact-based, and professionally written.
- Use informative writing. Please provide as much detail as possible.
- Maintain a logical sequence of ideas by effectively summarizing key points.
4. Source attribution and clickable links
- Use the number in front of the source as a clickable attribute in the report.
- Links to sources should be embedded in the text using: <a href="SOURCE_URL" target="_blank">[1]</a>
- Don't include the “Links” section — instead, all sources should be embedded in the content.
## Example output structure:
<DOCTYPE html>
<html>
<head>
<title>Research Report: [Title]</title>
<style>
body {font-family: Arial, sans-serif; line-height: 1.6; margin: 20px;}
h1, h2, h3 {color: #333;}
.report-section {background color: #f4f4f4; padding: 20px; font-size: 16px; line-height: 1.6; color: #333; margin-bottom: 10px;}
</style>
</head>
<body>
<div class="report-section">
<h1>Research Report: [Title]</h1>
</div>
<div class="report-section">
<h2>Introduction</h2>
<p>Research content with embedded links <a href="https://example.com" target="_blank">[1]</a>.</p>
<hr>
<p>Additional analysis with reference to <a href="https://example2.com" target="_blank">[2]</a>.</p>
</div>
</body>
</html>
The input data for Writer are:
Title: {{$ ('Split Out2') .item.json.title}}
Research: {{$ ('Split Out2') .item.json.content}}
Source: {{$json.NumberedURL}}
Style Guide Example: {{$ ('Switch') .item.json ['Chapter 1']}}
2.5 Data Aggregation - Aggregate & Aggregate1
Aggregate (for content):
Aggregate1 (for sources):
Why do we need aggregation:
Purpose: Synchronizes aggregated content and sources
Settings:
Purpose: Extracts section titles from generated HTML
Settings:
Why do you need this: To automatically create a table of contents, you need to know what sections AI has created in the report.
Purpose: Collects all section titles into one array
JavaScript code:
return [{
sections: $input.all () .map (item => item.json.section)
}];
2.9 Saving results - Google Sheets1
Purpose: Saves all data from the first topic to a table
Settings:
The structure is identical to topic 1, the only differences are:
Topic 2: Tavily1 → Split Out3 → Code1 → Writer1 → Aggregate2 → Aggregate3 → Merge4 → HTML1 → Combine1 → Google Sheets2
Topic 3: Tavily2 → Split Out4 → Code2 → Writer2 → Aggregate4 → Aggregate5 → Merge5 → HTML2 → Combine2 → Google Sheets3
Topic 4: Tavily3 → Split Out5 → Code3 → Writer3 → Aggregate6 → Aggregate7 → Merge6 → HTML3 → Combine3 → Google Sheets4
Topic 5: Tavily4 → Split Out6 → Code4 → Writer4 → Aggregate8 → Aggregate9 → Merge7 → HTML4 → Combine4 → Google Sheets5
3.1 Combining all results - Merge2
Purpose: Collects results from all 5 topics in one place
Settings:
Purpose: Optimizes data processing
Settings:
Purpose: Retrieves all sources from Google Sheets
Google Sheets settings:
3.4 Generating a list of sources - Sources
Purpose: AI creates an HTML list of all 25 sources
Connected components:
Sources system prompt:
# Review
You're an AI assistant specializing in creating well-formatted sections of HTML source code for research reports. You will be given a list of sources, each of which has been assigned a number. Your task is to create a “Sources” section in HTML format.
## Formatting rules:
- The section title should be <h2>Sources</h2>.
- Use an unordered list (<ul>) to display sources.
- Each source must be in the format:
<li><a href="SOURCE_URL" target="_blank">[NUMBER] Source name</a></li>
- It is necessary to maintain the original numbering of sources.
## Example output structure:
<div class="sources-section">
<h2>Sources</h2>
<ul>
<li><a href="https://example1.com" target="_blank">[1] Research on AI Development</a></li>
<li><a href="https://example2.com" target="_blank">[2] The Impact of Automation</a></li>
<li><a href="https://example3.com" target="_blank">[3] Machine Learning Trends</a></li>
</ul>
</div>
Input data:
Sources:
{{$json ['1 Topic: Sources']}}
{{$json ['2 Topic: Sources']}}
{{$json ['3 Topic: Sources']}}
{{$json ['4 Topic: Sources']}}
{{$json ['5 Topic: Sources']}}
3.5 Saving Sources - Send Sources
Purpose: Saves the finished list of sources to a table
Google Sheets settings:
Purpose: Extracts the full report structure to create a table of contents
Settings: Identical to Get Sources, gets all table columns.
Purpose: AI generates a structured table of contents
Connected components:
Table of Contents system prompt:
# Review
You're an AI assistant tasked with creating a structured table of contents (ToC) in professional HTML formatting for a research report. Your output should be consistent with the style guide provided and be clean, readable, and well-structured.
## Guidelines
1) Format chapters as elements <h2>
<h2>- Each chapter should be a separate title.
<ol>2) Format sections as an ordered list ()
- Each section in the chapter should be a list item (<li>) inside<ol>.
- Maintain a clear hierarchy and indentation for easy reading.
3) Use this style guide
- Wrap the table of contents in <div>the same indent, font size, and color as the style guide.
- Add a horizontal line (<hr>) to split.
## Sample output:
<div style="background-color: #f4f4f4; padding: 20px; font-size: 16px; line-height: 1.6; color: #333;">
<h2>Table of contents</h2>
<hr>
<ol>
<li>
<h2>Chapter 1: Introduction</h2>
<ol>
<li>Context and importance</li>
<li>Research Objectives</li>
</ol>
</li>
<li>
<h2>Chapter 2: Key Concepts</h2>
<ol>
<li>Theoretical bases</li>
<li>Practical applications</li>
</ol>
</li>
</ol>
</div>
Table of Contents inputs:
Chapter 1: {{$ ('Plan Topics') .first () .json.output.topic_1}}
Sections: {{$json ['1 Topic: Sections']}}
Chapter 2: {{$ ('Plan Topics') .first () .json.output.topic_2}}
Sections: {{$json ['2 Topic: Sections']}}
Chapter 3: {{$ ('Plan Topics') .first () .json.output.topic_3}}
Sections: {{$json ['3 Topic: Sections']}}
Chapter 4: {{$ ('Plan Topics') .first () .json.output.topic_4}}
Sections: {{$json ['4 Topic: Sections']}}
Chapter 5: {{$ ('Plan Topics') .first () .json.output.topic_5}}
Sections: {{$json ['5 Topic: Sections']}}
Style Guide: {{$json ['Introduction']}}
3.8 Save the table of contents - Send ToC
Purpose: Saves the finished table of contents to a table
Google Sheets settings:
Purpose: Retrieves the full final version of all report data
Settings: Identical to previous Google Sheets read operations, retrieves all completed columns.
Purpose: JavaScript combines all parts of the report into a single HTML document
JavaScript code:
//N8N Code Node to combine multiple fields into a single field with new lines
//Access the incoming data
const item = items [0];
//Create a new field called “CombinedContent” that joins all fields with newlines
const CombinedContent = [
Item.json.Title ||”,
Item.json.intro ||”,
Item.json.toc ||”,
item.json ['Chapter 1'] || “,
item.json ['1 Topic: content'] || “,
item.json ['Chapter 2'] || “,
item.json ['2 Topic: content'] || “,
item.json ['Chapter 3'] || “,
item.json ['3 Topic: content'] || “,
item.json ['Chapter 4'] || “,
item.json ['4 Topic: content'] || “,
item.json ['Chapter 5'] || “,
item.json ['5 Topic: content'] || “,
Item.json.Sources ||”
] .join ('\n\n');
//Add the combined content to the item
Item.json.combinedContent = CombinedContent;
//Return the modified item
return [item];
What's going on:
Purpose: Converts HTML into a professional PDF document
HTTP Request settings:
Get the API key here https://app.apitemplate.io/manage-api/
Query Parameters:
JSON Body:
{
“body”: “{{$json [" CombinedContent "] .replace (/” /g, '\\ "') .replace (/\n/g, '\\n')}}”,
“css”: "<style>.bg {background: red};</style> “,
“data”: {
“name”: “This is a title”
},
“settings”: {
“paper_size”: “A4",
“orientation”: “1",
“header_font_size”: “9px”,
“margin_top”: “40",
“margin_right”: “10",
“margin_bottom”: “40",
“margin_left”: “10",
“print_background”: “1",
“DisplayHeaderFooter”: true,
“custom_header”: "<style>#header, #footer {padding: 0! important;}</style>\n<table style=\ "width: 100%; padding: 0px 5px; margin: 0px! important; font-size: 8px\ ">\n<tr>\n<td style=\" text-align:left; width: 30%! important;\ "><span class=\" date\ "></span></td>\n<td style=\" text-align:center; width: 30%! important;\ "><span class=\" pageNumber\ "></span></td>\n<td style=\" text-align:right; width: 30%! important;\ "><span class=\" totalPages\ "></span></td>\n\n</tr></table>“,
“custom_footer”: "<style>#header, #footer {padding: 0! important;}</style>\n<table style=\ "width: 100%; padding: 0px 5px; margin: 0px! important; font-size: 8px\ ">\n<tr>\n<td style=\" text-align:left; width: 30%! important;\ "><span class=\" date\ "></span></td>\n<td style=\" text-align:center; width: 30%! important;\ "><span class=\" pageNumber\ "></span></td>\n<td style=\" text-align:right; width: 30%! important;\ "><span class=\" totalPages\ "></span></td>\n\n</tr></table>”
}
}
Explanation of PDF settings:
The result: Apitemplate.io returns an object with download_url to download the finished PDF.
Purpose: Downloads the finished PDF file from the link received
HTTP Request settings:
What's going on:
Purpose: Sends a PDF report to the user by email
Gmail settings:
Your Deep Research Report on {{$ ('On form submission') .first () .json ['Search Topic']}} is complete.
You can find it attached below.
Attachments:
The result: The user receives an email with an attached 15-25 page PDF report with a full study on his topic.
8 OpenAI Chat Model nodes use the gpt-4o-mini model:
Required columns:
It's done. This automation turns any topic into a professional research report fully automatically in 5-10 minutes.
You can always get a JSON file and instructions in video format by joining our unique Automation club.