FindPrompts
n8nAI AgentsAdvanced5 steps

AI Research Agent (Web + Summary)

A LangChain agent in n8n that takes a research question via webhook, uses a web search tool to gather sources, and synthesizes a concise cited brief. Drop-in research assistant you can call from anywhere.

WebhookOpenAISerpAPI

How it works

  1. 1Trigger: webhook receives a research question
  2. 2Agent reasons over the question using a chat model
  3. 3Agent calls a web search tool to gather sources
  4. 4Agent synthesizes a cited summary
  5. 5Return the brief in the webhook response

Setup

  • Add OpenAI credentials to the Chat Model node.
  • Add a SerpAPI key to the Web Search Tool node.
  • POST { question: '...' } to the webhook to run the agent.
  • Swap SerpAPI for Tavily or another search tool if preferred.

Workflow JSON

{
  "name": "AI Research Agent",
  "nodes": [
    {
      "id": "ra01aa",
      "name": "Question Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        200,
        300
      ],
      "parameters": {
        "httpMethod": "POST",
        "path": "research",
        "responseMode": "responseNode"
      }
    },
    {
      "id": "ra02bb",
      "name": "Research Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        440,
        300
      ],
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.body.question }}",
        "options": {
          "systemMessage": "You are a research assistant. Use the search tool to find sources, then write a concise brief with inline citations."
        }
      }
    },
    {
      "id": "ra03cc",
      "name": "Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [
        380,
        480
      ],
      "parameters": {
        "model": "gpt-4o"
      }
    },
    {
      "id": "ra04dd",
      "name": "Web Search Tool",
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "typeVersion": 1,
      "position": [
        520,
        480
      ],
      "parameters": {}
    },
    {
      "id": "ra05ee",
      "name": "Respond",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        700,
        300
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { \"brief\": $json.output } }}"
      }
    }
  ],
  "connections": {
    "Question Webhook": {
      "main": [
        [
          {
            "node": "Research Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Research Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Web Search Tool": {
      "ai_tool": [
        [
          {
            "node": "Research Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Research Agent": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "meta": {}
}

Command Palette

Search for a command to run...