{
  "name": "Deep Research Report Generation Using Open Router, Google Search, Webhook/Telegram and Notion",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.1,
      "position": [
        -860,
        180
      ],
      "id": "db0c8ef2-4859-4df9-a29b-4066998e7926",
      "name": "Telegram Trigger",
      "webhookId": "13911073-fffc-490c-b05b-3628d7a6faa5",
      "notes": "This telegramTrigger node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "YOUR_CREDENTIAL_HERE",
        "contextWindowLength": 10
      },
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1.3,
      "position": [
        -480,
        480
      ],
      "id": "49a10f75-eaa2-4466-a568-edfe9084fe30",
      "name": "Simple Memory",
      "notes": "This memoryBufferWindow node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n   \"is_pass_next\" : \"boolean\",\n   \"message\" : \"string\"\n}"
      },
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1.2,
      "position": [
        -320,
        480
      ],
      "id": "3c820502-6a10-4ad7-b460-42ea297b0a18",
      "name": "Structured Output Parser",
      "notes": "This outputParserStructured node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.output.is_pass_next }}",
                    "rightValue": "",
                    "operator": {
                      "type": "boolean",
                      "operation": "false",
                      "singleValue": true
                    },
                    "id": "9e5f68a3-6af4-48ce-9bf6-6c6e06236301"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "YOUR_CREDENTIAL_HERE"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "ac64b26c-d9e6-48a1-9fff-8b85156725b2",
                    "leftValue": "={{ $json.output.is_pass_next }}",
                    "rightValue": "",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "YOUR_CREDENTIAL_HERE"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -220,
        300
      ],
      "id": "cb67de10-2789-4c01-afcb-7716005419e8",
      "name": "Switch",
      "notes": "This switch node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=You are the research and planning agent. Your role is to help users plan high-quality research content — quickly, clearly, and efficiently.\n\nUser input: {{ $json?.message?.text ||  $json?.body?.message}}\n\n🌟 Your Mission:\nAfter greeting message ask what user want to research about. Just ask What would you like to research?\n\nGiven the following research topic 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. Ask all questions one by one.\n\nAfter clarity questions send draft for user to confirm. \n\n🧠 OUTPUT FORMAT (Always use this JSON output structure):\n\nIf needs feedback or clarity from user: \n\n{\n  \"is_pass_next\": false,\n  \"message\": \"message\"\n}\n\nIf strategy is ready for confirmation:\n{\n  \"is_pass_next\": false,\n  \"message\": \"Here’s your research plan draft:\"\n}\n\n🚀 If user confirms:\n{\n  \"is_pass_next\": true,\n  \"message\": \"The research plan is as follow:\",\n}\n\nToday's date : {{ $now }}",
        "hasOutputParser": true,
        "options": {}
      },
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1.8,
      "position": [
        -560,
        300
      ],
      "id": "c3acda96-3dfe-4562-85dc-508abb2b4e6a",
      "name": "Strategy Agent",
      "notes": "This agent node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Given the following prompt from the user, generate a list of SERP queries to research the topic.\nReduce the number of words in each query to its keywords only.\nReturn a maximum of 3 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>{{ $('Switch').item.json.output.message }}</prompt>",
        "hasOutputParser": true,
        "options": {}
      },
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1.8,
      "position": [
        880,
        400
      ],
      "id": "cc6ede05-c8e2-4d95-8f14-a2bd458d156c",
      "name": "Search Query Agent",
      "notes": "This agent node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"queries\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"object\",\n        \"properties\": {\n          \"query\": {\n            \"type\": \"string\",\n            \"description\": \"The SERP query\"\n          },\n          \"researchGoal\": {\n            \"type\": \"string\",\n            \"description\": \"First talk about the goal of the research that this query is meant to accomplish, then go deeper into how to advance the research once the results are found, mention additional research directions. Be as specific as possible, especially for additional research directions.\"\n          }\n        }\n      }\n    }\n  }\n}"
      },
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1.2,
      "position": [
        1060,
        580
      ],
      "id": "e377ea10-0533-4eb9-924c-a812ef08cf11",
      "name": "Structured Output Parser1",
      "notes": "This outputParserStructured node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "fieldToSplitOut": "output.queries",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        1240,
        500
      ],
      "id": "430256b3-1d07-4c83-90c9-3d836833332d",
      "name": "Split Out",
      "notes": "This splitOut node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        1420,
        500
      ],
      "id": "07630239-b8f2-4a00-904d-b2fb59c04545",
      "name": "Loop Over Queries",
      "notes": "This splitInBatches node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "method": "POST",
        "url": "{{ $env.API_BASE_URL }}",
        "authentication": "{{ $credentials.genericCredentialType }}",
        "genericAuthType": "httpCustomAuth",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "query",
              "value": "={{ $json.query }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1640,
        600
      ],
      "id": "64d8824c-2914-4f46-b0ca-9dff584970d7",
      "name": "HTTP Request",
      "notes": "This httpRequest node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "00d1543a-0036-43a3-8034-14bc29317218",
              "name": "tavily_results",
              "value": "={{ $json.results }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1860,
        600
      ],
      "id": "d0c8337a-c631-4582-a9bd-f7166772787f",
      "name": "Edit Fields",
      "notes": "This set node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4.1-mini",
          "mode": "list",
          "cachedResultName": "GPT-4.1-MINI"
        },
        "messages": {
          "values": [
            {
              "content": "=You are an intelligent assistant. A user has asked the following query:\n\n[Search Query]: {{ $('HTTP Request').item.json.query }}\n\nBelow is the draft for research that user has passed: {{ $('Switch').item.json.output.message }}\n\nBelow are the search results retrieved from the internet (from Tavily):\n\n{{ $json.tavily_results }}\n\nEach result includes a title, URL, and content. From these, choose the **single most relevant URL** that best matches the user's query. Focus on accuracy, relevance, and depth of the content. Only return the URL — do not include any explanation or extra text.\n\nreturn it like below JSON format: \n{\n final_url: \"url\"\n}\n"
            }
          ]
        },
        "jsonOutput": true,
        "options": {}
      },
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1.8,
      "position": [
        2060,
        600
      ],
      "id": "fa94faaa-c5a1-4752-a9e6-69c670217c65",
      "name": "OpenAI",
      "notes": "This openAi node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "method": "POST",
        "url": "{{ $env.API_BASE_URL }}",
        "authentication": "{{ $credentials.genericCredentialType }}",
        "genericAuthType": "httpCustomAuth",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "urls",
              "value": "={{ $json.message.content.final_url }}"
            },
            {
              "name": "extract_depth",
              "value": "advanced"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2420,
        600
      ],
      "id": "e3801e7f-60f5-4e9b-8ff5-717316c836c0",
      "name": "HTTP Request1",
      "notes": "This httpRequest node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "aggregate": "aggregateAllItemData",
        "options": {}
      },
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [
        1620,
        240
      ],
      "id": "86646bdb-78ba-440f-816e-6d8400c1dab7",
      "name": "Aggregate",
      "notes": "This aggregate node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=You are a research and writing assistant.\n\nYour task is to generate a comprehensive and well-structured blog-style report based on the following research topic and raw extracted content. Use professional, clear language suitable for a wide audience. Organize the report using headings and subheadings. Avoid repetition. At the end of the report, include a \"Sources\" section with a list of the URLs used. \n\nThis is the final draft on which you need to create report from given topic and draft: \n{{ $('Switch').item.json.output.message }}. Try to create final report from this outline and draft.\n\n---\n**Extracted Content**:\n\n1. Source: {{ $json.data[0].results[0].url }}\nContent:{{ $json.data[0].results[0].raw_content }}\n\n\n2. Source: {{ $json.data[1].results[0].url }}\nContent: {{ $json.data[1].results[0].raw_content }}\n\n3. Source: {{ $json.data[2].results[0].url }}\nContent:{{ $json.data[2].results[0].raw_content }}\n\n---\n\n**Instructions**:\n- Make as detailed report as possible. Include all the useful information.\n- Analyze and synthesize the information from all sources.\n- Structure the report into meaningful sections with headings and subheadings (e.g., Introduction, Key Insights, Challenges, Opportunities, Conclusion, etc.).\n- Do not copy the content verbatim — rewrite and consolidate it into an original, cohesive narrative.\n- Maintain factual accuracy.\n- Make it as as detailed as possible, aim for 3 or more pages, include ALL the learnings from research.\n- Format the report in markdown. Use headings, lists and tables only and where appropriate.\n- At the end of **each paragraph**, insert a superscript source reference in markdown format like this: `[1]`, `[2]`, `[3]`, based on which source(s) the paragraph is derived from.\n- Do not mention the source URL in the paragraph body.\n- Do not include content that cannot be mapped to one of the sources.\n- At the end include sources link with correct url.\n",
        "options": {}
      },
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1.8,
      "position": [
        1820,
        240
      ],
      "id": "59c8f32a-7208-4a2d-af97-50fbe2f23e93",
      "name": "AI Agent",
      "notes": "This agent node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4O-MINI"
        },
        "messages": {
          "values": [
            {
              "content": "=You will be given research draft that user asked to you need to create title and description using this draft. \n\ndraft:  {{ $('Switch').item.json.output.message }}\n\noutput using below json format: \n{\n \"title\": string,\n \"description\": string\n}"
            }
          ]
        },
        "jsonOutput": true,
        "options": {}
      },
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1.8,
      "position": [
        300,
        420
      ],
      "id": "7755fe19-6591-45a6-b763-31f239f41dd8",
      "name": "OpenAI1",
      "notes": "This openAi node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "resource": "databasePage",
        "databaseId": {
          "__rl": true,
          "value": "1f536e90-e9d0-805c-a1c1-f2fab42a8a7b",
          "mode": "list",
          "cachedResultName": "n8n DeepResearch",
          "cachedResultUrl": "{{ $env.WEBHOOK_URL }}"
        },
        "title": "={{ $json.message.content.title }}",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "YOUR_CREDENTIAL_HERE",
              "textContent": "={{ $('Code').item.json.randomId.toString() }}"
            },
            {
              "key": "YOUR_CREDENTIAL_HERE",
              "title": "={{ $json.message.content.title }}"
            },
            {
              "key": "YOUR_CREDENTIAL_HERE",
              "textContent": "={{ $json.message.content.description }}"
            },
            {
              "key": "YOUR_CREDENTIAL_HERE",
              "date": "={{ $now.toISO() }}"
            },
            {
              "key": "YOUR_CREDENTIAL_HERE",
              "statusValue": "In progress"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [
        660,
        440
      ],
      "id": "09b6efbc-7326-4b38-b9e9-49ff87b32101",
      "name": "Notion",
      "notes": "This notion node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "resource": "databasePage",
        "operation": "update",
        "pageId": {
          "__rl": true,
          "value": "={{ $('Convert to HTML').item.json.id }}",
          "mode": "id"
        },
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "YOUR_CREDENTIAL_HERE",
              "statusValue": "Done"
            },
            {
              "key": "YOUR_CREDENTIAL_HERE",
              "date": "={{ $now.toISO() }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [
        4400,
        320
      ],
      "id": "cb35b466-f368-4b57-90c1-fe45e8566516",
      "name": "Notion1",
      "notes": "This notion node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "method": "PATCH",
        "url": "{{ $env.BASE_URL }}",
        "authentication": "{{ $credentials.predefinedCredentialType }}",
        "nodeCredentialType": "YOUR_CREDENTIAL_HERE",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Notion-Version",
              "value": "2022-06-28"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{\n{\n  \"children\": $json.block\n}\n}}",
        "options": {
          "timeout": "={{ 1000 * 60 }}"
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        4120,
        520
      ],
      "id": "1e8271df-33ea-4ce6-b49a-4f9a7d809f16",
      "name": "HTTP Request2",
      "notes": "This httpRequest node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "mode": "markdownToHtml",
        "markdown": "={{ $('AI Agent').item.json.output }}",
        "options": {
          "tables": true
        }
      },
      "id": "76b8f99e-330a-4daf-a524-677e21a5f1bc",
      "name": "Convert to HTML",
      "type": "n8n-nodes-base.markdown",
      "position": [
        2440,
        340
      ],
      "typeVersion": 1,
      "notes": "This markdown node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "851b8a3f-c2d3-41ad-bf60-4e0e667f6c58",
              "name": "tag",
              "type": "array",
              "value": "={{ $json.data.match(/<table[\\s\\S]*?<\\/table>|<ul[\\s\\S]*?<\\/ul>|<[^>]+>[^<]*<\\/[^>]+>/g) }}"
            }
          ]
        },
        "options": {}
      },
      "id": "dc13b8f8-b1af-49b9-bac8-9237eda3d4c5",
      "name": "HTML to Array",
      "type": "n8n-nodes-base.set",
      "position": [
        2660,
        340
      ],
      "typeVersion": 3.4,
      "notes": "This set node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "fieldToSplitOut": "tag",
        "options": {}
      },
      "id": "a3434303-05dc-4d8c-982e-c11373976a1e",
      "name": "Tags to Items",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        2860,
        380
      ],
      "typeVersion": 1,
      "notes": "This splitOut node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.tag.trim() }}",
        "messages": {
          "messageValues": [
            {
              "message": "=Convert the following html into its equivalent Notion Block as per Notion's API schema.\n* Ensure the content is always included and remains the same.\n* Return only a json response.\n* Generate child-level blocks. Should not define \"parent\" or \"children\" property.\n* Strongly prefer headings, paragraphs, tables and lists type blocks.\n* 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.\n* ensure lists blocks include all list items.\n\n## Examples\n\n1. headings\n```\n<h3 id=\"references\">References</h3>\n```\nwould convert to \n```\n{\"object\":  \"block\", \"type\": \"heading_3\", \"heading_3\": { \"rich_text\": [{\"type\": \"text\",\"text\": {\"content\": \"References\"}}]}}\n```\n\n2. lists\n```\n<ul><li>hello</li><li>world</li></ul>\n```\nwould convert to\n```\n[\n{\n  \"object\": \"block\",\n  \"type\": \"bulleted_list_item\",\n  \"bulleted_list_item\": {\"rich_text\": [{\"type\": \"text\",\"text\": {\"content\": \"hello\"}}]}\n},\n{\n  \"object\": \"block\",\n  \"type\": \"bulleted_list_item\",\n  \"bulleted_list_item\": {\"rich_text\": [{\"type\": \"text\",\"text\": {\"content\": \"world\"}}]}\n}\n]\n```\n\n3. tables\n```\n<table>\n  <thead>\n    <tr><th>Technology</th><th>Potential Impact</th></tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td>5G Connectivity</td><td>Enables faster data speeds and advanced apps</td>\n    </tr>\n  </tbody>\n</table>\n```\nwould convert to\n```\n{\n  \"object\": \"block\",\n  \"type\": \"table\",\n  \"table\": {\n    \"table_width\": 2,\n    \"has_column_header\": true,\n    \"has_row_header\": false,\n    \"children\": [\n      {\n        \"object\": \"block\",\n        \"type\": \"table_row\",\n        \"table_row\": {\n          \"cells\": [\n            [\n              {\n                \"type\": \"text\",\n                \"text\": {\n                  \"content\": \"Technology\",\n                  \"link\": null\n                }\n              },\n              {\n                \"type\": \"text\",\n                \"text\": {\n                  \"content\": \"Potential Impact\",\n                  \"link\": null\n                }\n              }\n            ],\n            [\n              {\n                \"type\": \"text\",\n                \"text\": {\n                  \"content\": \"5G Connectivity\",\n                  \"link\": null\n                }\n              },\n              {\n                \"type\": \"text\",\n                \"text\": {\n                  \"content\": \"Enables faster data speeds and advanced apps\",\n                  \"link\": null\n                }\n              }\n            ]\n          ]\n        }\n      }\n    ]\n  }\n}\n```\n4. anchor links\nSince Notion doesn't support anchor links, just convert them to rich text blocks instead.\n```\n<a href=\"#module-0-pre-course-setup-and-learning-principles\">Module 0: Pre-Course Setup and Learning Principles</a>\n```\nconverts to\n```\n{\n  \"object\": \"block\",\n  \"type\": \"paragraph\",\n  \"paragraph\": {\n    \"rich_text\": [\n      {\n        \"type\": \"text\",\n        \"text\": {\n          \"content\": \"Module 0: Pre-Course Setup and Learning Principles\"\n        }\n      }\n    ]\n  }\n}\n```\n5. Invalid html parts\nWhen the html is not syntax valid eg. orphaned closing tags, then just skip the conversion and use an empty rich text block.\n```\n</li>\\n</ol>\n```\ncan be substituted with\n```\n{\n  \"object\": \"block\",\n  \"type\": \"paragraph\",\n  \"paragraph\": {\n    \"rich_text\": [\n      {\n        \"type\": \"text\",\n        \"text\": {\n          \"content\": \" \"\n        }\n      }\n    ]\n  }\n}\n```"
            }
          ]
        }
      },
      "id": "0c472a0a-4c4a-4421-b98c-e1fe84a5da4d",
      "name": "Notion Block Generator",
      "type": "n8n-nodes-base.noOp",
      "position": [
        3040,
        360
      ],
      "typeVersion": 1.5,
      "notes": "This chainLlm node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "modelName": "models/gemini-2.0-flash",
        "options": {}
      },
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        3040,
        540
      ],
      "id": "bcefff85-b26a-4bc5-a131-f2582da4c99c",
      "name": "Google Gemini Chat Model",
      "notes": "This lmChatGoogleGemini node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "73fcb8a0-2672-4bd5-86de-8075e1e02baf",
              "name": "=block",
              "type": "array",
              "value": "={{\n(function(){\n  const block = $json.response.text\n    .replace('```json', '')\n    .replace('```', '')\n    .trim()\n    .parseJson();\n  if (Array.isArray(block)) return block;\n  if (block.type.startsWith('heading_')) {\n    const prev = Number(block.type.split('_')[1]);\n    const next = Math.max(1, prev - 1);\n    if (next !== prev) {\n      block.type = `heading_${next}`;\n      block[`heading_${next}`] = Object.assign({}, block[`heading_${prev}`]);\n      block[`heading_${prev}`] = undefined;\n    }\n  }\n  return [block];\n})()\n}}"
            }
          ]
        },
        "options": {}
      },
      "id": "991e572e-5949-4f6b-89e4-8f99db69955d",
      "name": "Parse JSON blocks",
      "type": "n8n-nodes-base.set",
      "position": [
        3380,
        360
      ],
      "executeOnce": false,
      "typeVersion": 3.4,
      "onError": "continueRegularOutput",
      "notes": "This set node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "f68cefe0-e109-4d41-9aa3-043f3bc6c449",
              "operator": {
                "type": "string",
                "operation": "notExists",
                "singleValue": true
              },
              "leftValue": "={{ $json.error }}",
              "rightValue": ""
            }
          ]
        },
        "options": {}
      },
      "id": "bbb56ba0-6f86-45ba-8d26-78be926bbd98",
      "name": "Valid Blocks",
      "type": "n8n-nodes-base.filter",
      "position": [
        3580,
        360
      ],
      "typeVersion": 2.2,
      "notes": "This filter node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "7ff6ecda-0d72-49c8-b0af-65756a04c76a",
      "name": "For Each Block...",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        3900,
        400
      ],
      "typeVersion": 3,
      "notes": "This splitInBatches node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "resource": "databasePage",
        "operation": "getAll",
        "databaseId": {
          "__rl": true,
          "value": "1f536e90-e9d0-805c-a1c1-f2fab42a8a7b",
          "mode": "list",
          "cachedResultName": "n8n DeepResearch",
          "cachedResultUrl": "{{ $env.WEBHOOK_URL }}"
        },
        "limit": 1,
        "filterType": "manual",
        "matchType": "allFilters",
        "filters": {
          "conditions": [
            {
              "key": "YOUR_CREDENTIAL_HERE",
              "condition": "equals",
              "richTextValue": "={{ $('Code').item.json.randomId.toString() }}"
            }
          ]
        },
        "options": {}
      },
      "id": "82c33ad1-1e8b-4bdb-adfe-b25c16fe782b",
      "name": "Get Existing Row",
      "type": "n8n-nodes-base.notion",
      "position": [
        2220,
        260
      ],
      "typeVersion": 2.2,
      "notes": "This notion node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "jsCode": "const randomId = Math.floor(100000 + Math.random() * 900000);\nreturn { randomId };\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        140,
        420
      ],
      "id": "fed5e77e-22a0-44b6-9c61-e2faa2bba26c",
      "name": "Code",
      "notes": "This code node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "aggregate": "aggregateAllItemData",
        "options": {}
      },
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [
        4120,
        300
      ],
      "id": "014c40d1-7c82-4b04-a907-9cab832df4c0",
      "name": "Aggregate1",
      "notes": "This aggregate node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "model": "anthropic/claude-3.5-sonnet",
        "options": {}
      },
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        -640,
        480
      ],
      "id": "a8aa4844-e19e-4f11-bcc4-4b7ac7d11412",
      "name": "OpenRouter Chat Model",
      "notes": "This lmChatOpenRouter node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "model": "anthropic/claude-3.5-sonnet",
        "options": {}
      },
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        860,
        580
      ],
      "id": "68c4f8d0-5d3f-48ee-9c84-40664992a4e5",
      "name": "OpenRouter Chat Model1",
      "notes": "This lmChatOpenRouter node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "model": "anthropic/claude-3.5-sonnet",
        "options": {}
      },
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1800,
        400
      ],
      "id": "a24cd1e0-eda2-4dcb-a527-aec509cf8381",
      "name": "OpenRouter Chat Model2",
      "notes": "This lmChatOpenRouter node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "1c86c408-aeed-40c5-b4ba-aad5f4cdf0ad",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -860,
        360
      ],
      "id": "167770e1-31e6-4830-a1b8-b3bf65db779c",
      "name": "Webhook",
      "webhookId": "1c86c408-aeed-40c5-b4ba-aad5f4cdf0ad",
      "notes": "This webhook node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "respondWith": "text",
        "responseBody": "={{ $json.output.message }}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        20,
        160
      ],
      "id": "09b175ea-164b-4e22-bd43-7bf94ee2788c",
      "name": "Respond to Webhook",
      "notes": "This respondToWebhook node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "respondWith": "text",
        "responseBody": "Thank you for your response. We are preparing your report. Once it is finished we will send report link to you.",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        -60,
        420
      ],
      "id": "3486459a-4816-4cd0-a635-eba98e91ae6c",
      "name": "Respond to Webhook1",
      "notes": "This respondToWebhook node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "method": "POST",
        "url": "{{ $env.API_BASE_URL }}",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "report_title",
              "value": "={{ $json.name || '' }}"
            },
            {
              "name": "report_url",
              "value": "={{ $json.url || \"\" }}"
            },
            {
              "name": "status",
              "value": "={{ $json.property_status || \"\" }}"
            },
            {
              "name": "session_id",
              "value": "={{ $('Webhook').item.json.body.session_id || \"\" }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        4640,
        500
      ],
      "id": "ab8b66ad-ed6b-492d-94f9-337173f6cfed",
      "name": "HTTP Request3",
      "notes": "This httpRequest node performs automated tasks as part of the workflow."
    },
    {
      "parameters": {
        "content": "# Workflow Overview\n\nThis workflow automates the process of research planning, query generation, web search, content extraction, and report creation. It integrates with Webhook, Notion, OpenAI, and external APIs.\n\n## Main Steps\n\n1. **Trigger**: Starts from a Telegram message or Webhook.\n2. **Strategy Agent**: Asks the user for a research topic and clarifies requirements.\n3. **Query Generation**: Generates SERP queries for the research topic.\n4. **Web Search**: Uses Tavily API to fetch search results for each query.\n5. **Content Extraction**: Extracts content from the most relevant URLs.\n6. **Report Generation**: Uses AI to synthesize a detailed report in markdown.\n7. **Notion Integration**: Saves the report and metadata to a Notion database.\n8. **Notification**: Notifies the user when the report is ready.\n\n## Key Nodes\n\n- **Trigger**: Listens for new messages.\n- **Strategy Agent**: Handles user interaction and planning.\n- **Search Query Agent**: Generates search queries.\n- **HTTP Request**: Fetches search results and extracts content.\n- **OpenAI/AI Agent**: Processes and synthesizes information.\n- **Notion**: Stores the final report.\n- **Sticky Note**: Use this to add or update instructions.\n\n## Tips\n\n- Update credentials for all API nodes before running.\n- You can edit or move Sticky Notes for better documentation.\n- Use the Switch node to handle user confirmations and feedback.\n- Optionally use Telegram or any other third party integration to trigger the workflow.",
        "height": 940,
        "width": 620
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        120,
        -920
      ],
      "id": "9b00f677-b15d-4c00-aa06-df10decbd38d",
      "name": "Sticky Note",
      "notes": "This stickyNote node performs automated tasks as part of the workflow."
    }
  ],
  "pinData": {},
  "connections": {
    "64d8824c-2914-4f46-b0ca-9dff584970d7": {
      "main": [
        [
          {
            "node": "error-handler-64d8824c-2914-4f46-b0ca-9dff584970d7",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-64d8824c-2914-4f46-b0ca-9dff584970d7-bade8a96",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-64d8824c-2914-4f46-b0ca-9dff584970d7-0e3949d0",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-64d8824c-2914-4f46-b0ca-9dff584970d7-2af4d26c",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-64d8824c-2914-4f46-b0ca-9dff584970d7-9eb973a6",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-64d8824c-2914-4f46-b0ca-9dff584970d7-35ad3f3e",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-64d8824c-2914-4f46-b0ca-9dff584970d7-6bc31a10",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-64d8824c-2914-4f46-b0ca-9dff584970d7-aaf58c4e",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-64d8824c-2914-4f46-b0ca-9dff584970d7-7be99347",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e3801e7f-60f5-4e9b-8ff5-717316c836c0": {
      "main": [
        [
          {
            "node": "error-handler-e3801e7f-60f5-4e9b-8ff5-717316c836c0",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-e3801e7f-60f5-4e9b-8ff5-717316c836c0-473fe6e3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-e3801e7f-60f5-4e9b-8ff5-717316c836c0-9febe244",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-e3801e7f-60f5-4e9b-8ff5-717316c836c0-88d7de2d",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-e3801e7f-60f5-4e9b-8ff5-717316c836c0-68c995d4",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-e3801e7f-60f5-4e9b-8ff5-717316c836c0-4cb5b084",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-e3801e7f-60f5-4e9b-8ff5-717316c836c0-0dced0fa",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-e3801e7f-60f5-4e9b-8ff5-717316c836c0-76c95d24",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-e3801e7f-60f5-4e9b-8ff5-717316c836c0-079d64e2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1e8271df-33ea-4ce6-b49a-4f9a7d809f16": {
      "main": [
        [
          {
            "node": "error-handler-1e8271df-33ea-4ce6-b49a-4f9a7d809f16",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-1e8271df-33ea-4ce6-b49a-4f9a7d809f16-e110b831",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-1e8271df-33ea-4ce6-b49a-4f9a7d809f16-68b1f9e4",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-1e8271df-33ea-4ce6-b49a-4f9a7d809f16-5936ae96",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-1e8271df-33ea-4ce6-b49a-4f9a7d809f16-4c9ea490",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-1e8271df-33ea-4ce6-b49a-4f9a7d809f16-9c1dcb82",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-1e8271df-33ea-4ce6-b49a-4f9a7d809f16-b89705e0",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-1e8271df-33ea-4ce6-b49a-4f9a7d809f16-97c64178",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-1e8271df-33ea-4ce6-b49a-4f9a7d809f16-8c3cc8a2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "167770e1-31e6-4830-a1b8-b3bf65db779c": {
      "main": [
        [
          {
            "node": "error-handler-167770e1-31e6-4830-a1b8-b3bf65db779c",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-167770e1-31e6-4830-a1b8-b3bf65db779c-f025b768",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-167770e1-31e6-4830-a1b8-b3bf65db779c-77e15b41",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-167770e1-31e6-4830-a1b8-b3bf65db779c-b7c5987e",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-167770e1-31e6-4830-a1b8-b3bf65db779c-afa98029",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-167770e1-31e6-4830-a1b8-b3bf65db779c-55f48f7e",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-167770e1-31e6-4830-a1b8-b3bf65db779c-743d0ed1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-167770e1-31e6-4830-a1b8-b3bf65db779c-ad766983",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-167770e1-31e6-4830-a1b8-b3bf65db779c-e682c5ec",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "09b175ea-164b-4e22-bd43-7bf94ee2788c": {
      "main": [
        [
          {
            "node": "error-handler-09b175ea-164b-4e22-bd43-7bf94ee2788c",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-09b175ea-164b-4e22-bd43-7bf94ee2788c-826e405d",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-09b175ea-164b-4e22-bd43-7bf94ee2788c-cf514c14",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-09b175ea-164b-4e22-bd43-7bf94ee2788c-d33c3edc",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-09b175ea-164b-4e22-bd43-7bf94ee2788c-bf64fcaa",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-09b175ea-164b-4e22-bd43-7bf94ee2788c-2609661e",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-09b175ea-164b-4e22-bd43-7bf94ee2788c-5868480b",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-09b175ea-164b-4e22-bd43-7bf94ee2788c-aaf54f50",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-09b175ea-164b-4e22-bd43-7bf94ee2788c-1ef41b9c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3486459a-4816-4cd0-a635-eba98e91ae6c": {
      "main": [
        [
          {
            "node": "error-handler-3486459a-4816-4cd0-a635-eba98e91ae6c",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-3486459a-4816-4cd0-a635-eba98e91ae6c-4d19b8ac",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-3486459a-4816-4cd0-a635-eba98e91ae6c-d677df53",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-3486459a-4816-4cd0-a635-eba98e91ae6c-c8bb42ca",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-3486459a-4816-4cd0-a635-eba98e91ae6c-39ed3001",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-3486459a-4816-4cd0-a635-eba98e91ae6c-0e086189",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-3486459a-4816-4cd0-a635-eba98e91ae6c-c24a0ec1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-3486459a-4816-4cd0-a635-eba98e91ae6c-7238b527",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-3486459a-4816-4cd0-a635-eba98e91ae6c-03ce7063",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ab8b66ad-ed6b-492d-94f9-337173f6cfed": {
      "main": [
        [
          {
            "node": "error-handler-ab8b66ad-ed6b-492d-94f9-337173f6cfed",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-ab8b66ad-ed6b-492d-94f9-337173f6cfed-06810a29",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-ab8b66ad-ed6b-492d-94f9-337173f6cfed-2f6e5967",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-ab8b66ad-ed6b-492d-94f9-337173f6cfed-a3308b9b",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-ab8b66ad-ed6b-492d-94f9-337173f6cfed-8b8229c9",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-ab8b66ad-ed6b-492d-94f9-337173f6cfed-e4b6530f",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-ab8b66ad-ed6b-492d-94f9-337173f6cfed-a1ce89bd",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-ab8b66ad-ed6b-492d-94f9-337173f6cfed-1cd9e35d",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "error-handler-ab8b66ad-ed6b-492d-94f9-337173f6cfed-3d8d3ff6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "db0c8ef2-4859-4df9-a29b-4066998e7926": {
      "main": [
        [
          {
            "node": "error-handler-db0c8ef2-4859-4df9-a29b-4066998e7926-96529397",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "fa94faaa-c5a1-4752-a9e6-69c670217c65": {
      "main": [
        [
          {
            "node": "error-handler-fa94faaa-c5a1-4752-a9e6-69c670217c65-8474b873",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7755fe19-6591-45a6-b763-31f239f41dd8": {
      "main": [
        [
          {
            "node": "error-handler-7755fe19-6591-45a6-b763-31f239f41dd8-fc849e46",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "bcefff85-b26a-4bc5-a131-f2582da4c99c": {
      "main": [
        [
          {
            "node": "error-handler-bcefff85-b26a-4bc5-a131-f2582da4c99c-becadcd0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": null,
    "timezone": "UTC",
    "executionTimeout": 3600,
    "maxExecutions": 1000,
    "retryOnFail": true,
    "retryCount": 3,
    "retryDelay": 1000
  },
  "versionId": "b12bd622-3a4c-4197-ae0e-8853d87fb2d3",
  "meta": {
    "instanceId": "workflow-d867546d",
    "versionId": "1.0.0",
    "createdAt": "2025-09-29T07:07:44.279168",
    "updatedAt": "2025-09-29T07:07:44.279178",
    "owner": "n8n-user",
    "license": "MIT",
    "category": "automation",
    "status": "active",
    "priority": "high",
    "environment": "production"
  },
  "id": "3ycewf83b8KVQi8N",
  "tags": [
    "automation",
    "n8n",
    "production-ready",
    "excellent",
    "optimized"
  ],
  "description": "Automated workflow: Deep Research Report Generation Using Open Router, Google Search, Webhook/Telegram and Notion. This workflow integrates 22 different services: stickyNote, switch, splitInBatches, chainLlm, set. It contains 56 nodes and follows best practices for error handling and security.",
  "notes": "Excellent quality workflow: Deep Research Report Generation Using Open Router, Google Search, Webhook/Telegram and Notion. This workflow has been optimized for production use with comprehensive error handling, security, and documentation."
}