Build Your Own DeepResearch with N8N + Apify + Notion!

In the end I used the Apify standby mode to point the node to (as I couldn’t get normal authentication to work).

https://rag-web-browser.apify.actor?token=apify_api_[your Apify APi goes here]

1 Like

I got it all working except for the sources list, for some reason it’s not appending the URL’s, it just stops at the “Sources” header.

1 Like

OMG, @Jim_Le !! Wtffff

That’s freaking awesome work.
Thank you for sharing all that!

1 Like

Really cool, Jim! I used Ollama with DeepseekR1 32b. It outputs its thinking enclosed in tags so I had to tweak the expression in the ‘Parse JSON Blocks’ Set node but looks like I might have lost some content in that process.

And there might be some tweaks I can do using Ollama to omit the tags but will save that for another day!

{{
(function(){
  const block = $json.text.split("```json")[1].replace('```', '') ;
  /*if (Array.isArray(block)) */ return block;
  if (block.type.startsWith('heading_')) {
    const prev = Number(block.type.split('_')[1]);
    const next = Math.max(1, prev - 1);
    if (next !== prev) {
      block.type = `heading_${next}`;
      block[`heading_${next}`] = Object.assign({}, block[`heading_${prev}`]);
      block[`heading_${prev}`] = undefined;
    }
  }
  return [block];
})()
}}
1 Like

Could you explain that a little bit more? I fairly new to n8n and APIs in general and it still gives me an authentication error :confused:

Hey @JaySmith502 You’re actually the 2nd person to report this bug so I’m happy to look into it. I recommend looking at the report subworkflow execution log as a starting point.

  1. Check the incoming data contains a list of sources. If it hasn’t, you may need to backtrack to the other subworkflow executions to figure out what happened to this data.
  2. Sources are not added to the markdown and are instead added at the end. It’s done this way because it’s quicker to convert them to notion blocks via code. In your execution logs, did something go wrong here?

Happy for you to post in this thread or DM privately.
Cheers!

1 Like

@viraj Thanks for trying out this template.

For the parsing/conversion of markdown to Notion blocks, I’d recommend perhaps switching to a Deepseek v3. A non-reasoning model may be better suited for this task and saves you from parsing out the <thinking>.

In your provided snippet, you have this bit which comments out the IF condition. This means all the code below this return doesn’t run and likely the cause as to why you’re losing content. Uncommenting should fix it!

 /*if (Array.isArray(block)) */ return block;

I actually finally figured it out and embarassingly this issue has hit me before, I forgot to add "Bearer " before the Apify token when setting credentials in the workflow. So it all ran, just gave 401 errors in the web searches. Basically my “Deep Research” was just hallucinated and internal knowledge junk. I got it fixed now and the results are fantastic.

1 Like

Thank you, @JaySmith502, for pointing me into the right direction. I’ve added "Bearer " before the token and changed the “Name” to “Authorization”. That has solved my authorization problems with Apify.

1 Like

Great job on n8n DeepSearch! I really appreciate the effort you’ve put into it—it’s a fantastic tool, and the DeepSearch feature is a solid move.

I’ve run it over three dozen times and noticed some intermittent issues (30% of the time it works flawlessly):

  • The production form sometimes freezes after clicking the first “Next” button. The loading animation appears, but the page hangs indefinitely. The execution starts but gets stuck at the second step.

  • Occasionally, the second or third question appears blank, even though the pipeline shows the next question is ready.

  • Updating Notion works about 30% of the time. Sometimes, the report is only partially filled, often just with the list of sources.

  • Everything feels slow. Is that n8n in general, or the workflow, or my setup, I don’t know.

As for use cases, I’ve customized a copy with webhook triggers and adjusted the search process and report settings to fit my needs—I love it when it works!

Looking forward to any improvements. Let me know if I can help debug.

2 Likes

Hey @Sebastien_Fichot
Thanks for the great feedback! Sorry to hear you’ve only had a low success rate with this template - I’ve not heard from anyone else with this complaint so appreciate you bringing it up.

1. The n8n forms issue seems to be quite common and from what I understand, this is affecting many self-hosted and locally-hosted users. I’m not sure of the root cause but some have suggested it’s likely related to how webhooks are configured for the instance.

The good news is the forms are optional and technically not required to run this template - they’re just a nicer user interface! Try swapping the forms out for webhooks or go with a simple manual trigger and “Edit Fields” node.

2. Updating Notion is a pain! The LLM-conversion of “markdown to Notion blocks” approach I’ve used wasn’t the best idea but allowed usage with installing external libraries/dependencies.

If you are self-hosting/locally-hosted, I would suggest swapping this part out with code-based solutions such as the following (note I haven’t tested any of these so YMMV)

3. n8n performance feeling slugglish depends on many things eg. If you have a lot for data fetched and held in memory, this is known to degrade the canvas responsiveness! For this particular template, here are my thoughts

  • Reasoning models are slow in general but get slower the more learnings/context it gets. I think the first few cycles take 1-2mins but by the 20th cycle, the model might be taking 10+ mins to respond.
  • Webscraping might be slow because I’m trying to keep things cheap - every request spins-up a new Apify instance and shuts it down after so they’re not long lived. You might want to swap this for other services like Jina.ai which might return faster results (trade off is less control).
  • Markdown-to-notion-blocks conversion is using an LLM which for 100+ headings, paragraphs etc actually takes ages! Swap out for custom node or code-based solution as mentioned.

Finally, this type of template is resource intensive. Boosting your server specs (easy) or switching to queue mode (harder) is generally the way to get better performance.

Hope this helps!

Thank you very much for your message. I will look into all of this, and share my discoveries with you.
Have a great day!

1 Like

Jim,
Any luck with that? I still do not get anything in the last section.

Thank you for putting this together. It’s a great example of some advanced functions within n8n. This might be a new aspect of the latest version of the Form but I noticed it says “Does not accept <script>, <style> or <input> tags”. I don’t know if it did before but your custom HTML has an input tag so that’s not working. Have you been working on it? Are you aware of that? Is that a new change?

I just kinda started with n8n about a month ago.

First, thank you for the time you spent to create such a work. I have a mini problem going on when i am testing the subworkflow, below. I tried adding Wait node but did not work out.

Referenced node is unexecuted

An expression references the node ‘Item Ref’, but it hasn’t been executed yet. Either change the expression, or re-wire your workflow to make sure that node executes first.

Hello Jim,
First of all, this is really cool and great work! thanks for your efforts and sharing it to us.
I am using make workflow and new to n8n workflow, so first I have to make myself familiar with n8n and get all the APIs done to test your nice workflow.
As I work in biotech, my idea is to modify a bit your workflow so it can read journal articles uploaded as pdf format, and give me a detail report and maybe experiment design via deep research after reading it. I will share it once I am done! Thanks again!

I have another question with this workflow, so far I am fine with first workflow, step 1-4, so I guess my Notion setting has no problem.
However, when it comes to the sub-workflow, the Notion in step 5 has issue: The resource you are requesting could not be found.
Do you have any idea to solve this issue? Thank you very much.

Hi Jim! Thanks for this awesome workflow. Just a question, I noticed that in the Set Next Queries, follow up questions is showing as undefined and I can’t seem to where this is being called.

Hey @Wojtek_T From some of the similar reports I’m getting, it’s likely that your Apify credential is misconfigured and therefore no sources are showing.

Try this and let me know if this helps.

  1. Create a generic credential
  2. Set it to “Header Auth”
  3. Click on “create new credential” option in the dropdown under “Header Auth”
  4. In the new credential modal under “Name” field, enter “Authorization”
  5. Under Value, you first need to enter "Bearer " before your API key. eg. “Bearer API_123456…”