{
  "name": "Multi-Agent Research Assistant",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "research",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "e5f6a7b8-5555-4000-8000-000000000001",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "resource": "chat",
        "operation": "message",
        "model": "gpt-4o",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are a research planning agent. Given a research topic, generate a structured research plan. Respond with a JSON object:\n{\n  \"topic\": \"refined topic statement\",\n  \"search_queries\": [\"query1\", \"query2\", \"query3\"],\n  \"key_aspects\": [\"aspect1\", \"aspect2\", \"aspect3\"],\n  \"expected_sources\": [\"academic\", \"industry\", \"news\"]\n}\nGenerate 3-5 diverse search queries that cover different angles of the topic."
            },
            {
              "role": "user",
              "content": "={{ $json.body.topic }}"
            }
          ]
        },
        "options": {
          "temperature": 0.5,
          "maxTokens": 512
        }
      },
      "id": "e5f6a7b8-5555-4000-8000-000000000002",
      "name": "Plan Research",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.6,
      "position": [
        500,
        300
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "GET",
        "url": "https://api.search.brave.com/res/v1/web/search",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "q",
              "value": "={{ JSON.parse($json.text).search_queries[0] }}"
            },
            {
              "name": "count",
              "value": "5"
            }
          ]
        },
        "options": {
          "timeout": 10000
        }
      },
      "id": "e5f6a7b8-5555-4000-8000-000000000003",
      "name": "Web Search",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        750,
        300
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "chat",
        "operation": "message",
        "model": "gpt-4o",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are a research synthesis agent. Analyze the search results and create a comprehensive research report. Structure your report with:\n1. Executive Summary (2-3 sentences)\n2. Key Findings (bullet points)\n3. Detailed Analysis (organized by the key aspects from the research plan)\n4. Sources and References\n5. Gaps and Recommendations for further research\n\nBe thorough, cite sources, and highlight contradictions or debates in the literature."
            },
            {
              "role": "user",
              "content": "=Research Plan: {{ $('Plan Research').item.json.text }}\n\nSearch Results:\n{{ JSON.stringify($json) }}"
            }
          ]
        },
        "options": {
          "temperature": 0.4,
          "maxTokens": 2048
        }
      },
      "id": "e5f6a7b8-5555-4000-8000-000000000004",
      "name": "Summarize Findings",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.6,
      "position": [
        1000,
        300
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "page",
        "operation": "create",
        "databaseId": {
          "__rl": true,
          "value": "your-notion-database-id",
          "mode": "id"
        },
        "title": "=Research: {{ $('Webhook').item.json.body.topic }}",
        "bodyContent": "={{ $json.text }}",
        "options": {
          "properties": {
            "Status": "Complete",
            "Type": "Research Report",
            "Date": "={{ $now.toISO() }}"
          }
        }
      },
      "id": "e5f6a7b8-5555-4000-8000-000000000005",
      "name": "Save to Notion",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [
        1250,
        300
      ],
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {
          "responseCode": 200
        },
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ report: $('Summarize Findings').item.json.text, topic: $('Webhook').item.json.body.topic, notionPageId: $json.id }) }}"
      },
      "id": "e5f6a7b8-5555-4000-8000-000000000006",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1500,
        300
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Plan Research",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Plan Research": {
      "main": [
        [
          {
            "node": "Web Search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Web Search": {
      "main": [
        [
          {
            "node": "Summarize Findings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Summarize Findings": {
      "main": [
        [
          {
            "node": "Save to Notion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save to Notion": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null
}