Ever wished you could just type a topic and, minutes later, have a professional research report ready in your inbox or chat? This n8n workflow does exactly that. In simple terms, you put in any question or topic, and the workflow:
- Refines your research query for clarity
- Searches the web, news, Wikipedia, and Google Scholar using AI and APIs
- Aggregates all findings into a structured summary
- Turns that summary into a beautifully formatted PDF
- Sends the PDF, along with a summary email, to Gmail AND/OR Telegram
Let’s walk through exactly how this works – no jargon, just plain English! You don’t need any coding skills. Just follow each step, and you’ll be able to create, customize, and troubleshoot this workflow yourself.
What Happens Inside the Workflow:
The process starts simple but uses several powerful tools along the way:
- Manual trigger (or subworkflow): You start the process or trigger it in another flow.
- Validate and clean your query: A Code node checks your input and prepares the search topic.
- Refine your search automatically: An AI Agent expands your question into 5 research queries, making web results much broader and smarter.
- Fetches data from multiple sources:
- News (with NewsAPI)
- Wikipedia for background
- Google Search (web and scholar)
- ChatGPT-like Large Model analyzes and aggregates: It summarizes everything into structured sections (intro, findings, news, sources, etc).
- Split/merge nodes organize the AI output for your PDF.
- Code node builds an HTML report: This HTML becomes the content for a PDF cover page and sections, with real styling.
- PDFShift node converts HTML → PDF: The result is a proper PDF file, not just a text blob!
- Send by Email and/or Telegram: The PDF is sent as an attachment to Gmail (with a friendly summary message) and/or directly to a Telegram chat.
- All data (topic, sources, date) is saved to Google Sheets for tracking.
Step-by-Step Setup Guide for Beginners
Step 1: Prepare Your Workspace
1. Open your n8n dashboard.
2. Click “Create Workflow”.
3. Give it a name like “Automated Research Report”.
What you should see: A blank workflow canvas.
Common mistake: Forgetting to name your workflow. Use specific names so you don’t mix flows up!
Step 2: Add Manual Trigger or Connect from Another Workflow
1. Add a Manual Trigger node (search for “manual trigger” and drag it in).
2. For automating this inside another process, you could use Execute Workflow Trigger instead.
Screenshots description: Blue node called “When clicking ‘Test workflow’” at the top left.
Step 3: Validate and Clean Up Your Search Query
1. Add a Code node after the trigger.
2. Paste this code in the JavaScript field:
// Validate input and prepare for processing
const query = $input.all()[0].json.query;
if (!query || query.trim().length < 3) {
throw new Error('Research query must be at least 3 characters long');
}
return {
json: {
originalQuery: query,
cleanedQuery: query.trim().toLowerCase(),
timestamp: new Date().toISOString()
}
};
Explanation: This step ensures the workflow doesn’t break if you forget to type something or just click “Test”.
Common mistake: Leaving the “query” input empty. Always check this node is green before moving on!
Step 4: Automatically Expand Your Query Using an AI Agent
1. Add an AI Agent (LangChain Agent node or similar) after input validation.
2. Use this prompt:
You are a query generation expert. Based on the refined query provided, generate exactly 5 related search queries ...
Refined Query: {{ $json.cleanedQuery }}
What’s happening? The bot will generate 5 search queries that cover different angles (for deeper research).
Step 5: Aggregate Web News, Wikipedia, and Academic Results
1. Add nodes for News API, Wikipedia, Google Search, and Google Scholar.
2. Plug the search queries into those nodes; each fetches different results.
3. Typical URLs to use (replace YOURAPIKEY with your real keys!):
- News:
https://newsapi.org/v2/everything?q={{query}}&apiKey=YOURAPIKEY - Wikipedia:
https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&exintro&explaintext&titles={{query}} - Google Search:
https://www.googleapis.com/customsearch/v1?key=YOURAPIKEY&q={{query}} - Google Scholar:
https://serpapi.com/search?engine=google_scholar&q={{query}}&api_key=YOURAPIKEY
Common pitfall: Wrong or expired API keys. Always check the “credentials” fields and test each node. 🔧
Step 6: Have the AI Summarize and Structure the Data
1. Add the Research AI Agent node (uses GPT-4o or similar for best results).
2. Use this prompt:
Perform research on the topic "{{ $json.output.topic }}" ...
Summarize and aggregate all findings into a structured JSON format ... (see workflow for full prompt structure)
What to expect: It produces a JSON object with intro, summary, up to 12 key findings, 4-6 news headlines, scholarly insights, and sources.
Step 7: Parse and Split the AI Output
1. Add a Code node to parse the AI’s JSON response.
2. Use:
const outputString = $input.first().json.output;
const parsedOutput = JSON.parse(outputString);
return [{ json: parsedOutput }];
3. Add a Split Out node to distribute sections, then a Merge Split Items node (with code) to re-group all data.
Step 8: Generate Styled HTML for the PDF
1. Add a Code node called “Generate PDF HTML”.
2. Put in the supplied HTML template, which uses escapeHtml() for safety, calculated date, structured sections, and smart topic capitalization.
Screenshot description: You should see an output with htmlContent, fileName, topic etc., ready to send to PDF conversion.
Common pitfall: Forgetting to escape user text can break PDF rendering; always test this step at least once!
Step 9: Convert the HTML to a PDF
1. Add the HTTP Request node.
2. Set URL to PDFShift API (https://api.pdfshift.io/v3/convert/pdf)
3. Send body parameters for your HTML, and the PDF filename.
4. Attach your PDFShift API key in the Authorization header.
What you should see: Output will include a public URL to the PDF file.
Common mistake: If you see errors about authentication or content, double check your API key and JSON fields.
Step 10: Download the PDF for Delivery
1. Add another HTTP Request node.
2. Use the PDF’s URL from the last step.
3. Output should be binary data: “application/pdf”.
Step 11: Send by Gmail and/or Telegram
1. For Gmail delivery:
- Add a Gmail node configured with your email and credentials.
- Attach the binary PDF and use the example message (HTML, personalized greeting, subject line with the research topic and date, etc.).
2. For Telegram delivery:
- Add a Telegram node; use “sendDocument”, enter your chat ID, and attach the PDF.
Testing tip: Use your own Gmail or Telegram for safe tests before deploying this for anyone else.
Step 12: Store Results for Record-Keeping
1. Add a Google Sheets node after merging results.
- Map topic, queries, sources, and timestamps to columns.
Pro tip: Now you have an instant report archive for every research task ever run.
How Data Flows Through the Workflow
– Your trigger launches the process with a question.
– Input is validated → query is expanded → web/news/scholar data is collected → AI summarizes → content is formatted → PDF is generated → PDF is delivered → Results logged in Sheets.
– Every section is fully automated.
3–5 Customizations You Can Try
- Send to multiple people: Add more Gmail nodes for extra recipients (change the “sendTo” value).
- Change PDF style: Tweak the HTML/CSS in the “Generate PDF HTML” code node—use your company colors, add a logo, etc.
- Output as DOCX: Instead of HTML→PDF, use a DOCX conversion API for reports in Word format.
- Add language detection and translate the report: Insert a language-detection or translation node before sending output.
- Save to Google Drive/Dropbox: Save every report PDF in a shared team folder before (or instead of) delivering by email/chat.
4–6 Common Problems and How to Fix Them
- API key invalid or expired: If a web/news/Google node fails, double-check your credentials. Always keep API keys updated!
- PDF not rendering or malformed: Make sure no section is empty and test with simple topics first. Blank HTML or special characters often break rendering; use the “escapeHtml” function as in the example.
- Emails not sending or going to spam: Use a tested Gmail account, limit attachment size, and avoid phrases in your subject like “free money” or “urgent”.
- No results or incomplete research: Check that the topic has at least 3 characters, and try broadening your queries. The AI prompt ensures a minimum number of news/scholar sources by design.
- Google Sheets or Drive node errors: Make sure the selected document and sheet name are exactly correct, and your Google account is connected and shared properly.
- Telegram fails to send: Double-check your chat ID and bot token, and make sure bot is added to the right channel or user chat.
Testing Before You Go Live
Checklist for a safe launch:
- Run the workflow with 2–3 test topics.
- Open each resulting PDF. Confirm the intro, summary, findings, news, scholars, and sources all have unique data.
- Check your Gmail, Telegram, and Google Sheets for correct delivery/storage.
- If something fails, check execution logs for which node went red and review that step above.
- Final step: Activate your workflow so it runs automatically, not just when you click “Test”.
Ready for Production? Here’s a Launch Recap ✅
If you’ve followed all the instructions, you now have a production-grade, fully customized research workflow that can:
- Take any question
- Build a beautiful PDF report automatically
- Send that report as a friendly email and PDF to anyone you want
- Save a record of every report for easy lookup in the future
You can now automate research for yourself, clients, your boss, or your whole company—no extra coding skills required!
Good Luck and Happy Automating!
If you ever hit a roadblock, review the error messages in n8n execution logs, check that all credentials are connected and up to date, or try running each node individually. The n8n community forums have lots of guides and friendly help too. You’ve got this! ⚙️

