AutomationFlowsAI & RAG › AI Agent - Search & Summarize

AI Agent - Search & Summarize

AI Agent - Search & Summarize. Uses httpRequest, openAi. Webhook trigger; 10 nodes.

Webhook trigger★★★★☆ complexityAI-powered10 nodesHTTP RequestOpenAI
AI & RAG Trigger: Webhook Nodes: 10 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow follows the HTTP Request → OpenAI recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "AI Agent - Search & Summarize",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "ai-agent",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "webhook-trigger",
      "name": "Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "const query = $input.first().json.body.query || $input.first().json.query || 'latest AI news';\nconst action = $input.first().json.body.action || $input.first().json.action || 'search_and_summarize';\n\nreturn [{ json: { query, action } }];"
      },
      "id": "parse-input",
      "name": "Parse Input",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false
          },
          "conditions": [
            {
              "leftValue": "={{ $json.action }}",
              "rightValue": "search_and_summarize",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ]
        }
      },
      "id": "route-action",
      "name": "Route Action",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        440,
        0
      ]
    },
    {
      "parameters": {
        "url": "=https://www.google.com/search?q={{ encodeURIComponent($json.query) }}&num=5",
        "options": {
          "response": {
            "response": {
              "fullResponse": true
            }
          }
        }
      },
      "id": "web-search",
      "name": "Web Search",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        -100
      ],
      "notes": "Replace with SerpAPI or Brave Search API for production use"
    },
    {
      "parameters": {
        "jsCode": "const query = $('Parse Input').first().json.query;\nconst searchResults = $input.first().json.body || 'No search results available';\n\nconst prompt = `You are a helpful AI research assistant. Based on the following search results for the query \"${query}\", provide:\n\n1. A concise summary (3-5 sentences)\n2. Key findings (bullet points)\n3. Recommended next steps or related topics to explore\n\nSearch Results:\n${typeof searchResults === 'string' ? searchResults.substring(0, 3000) : JSON.stringify(searchResults).substring(0, 3000)}\n\nProvide a well-structured response.`;\n\nreturn [{ json: { prompt, query } }];"
      },
      "id": "build-agent-prompt",
      "name": "Build Agent Prompt",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        880,
        -100
      ]
    },
    {
      "parameters": {
        "resource": "chat",
        "model": "gpt-4",
        "messages": {
          "values": [
            {
              "content": "={{ $json.prompt }}"
            }
          ]
        },
        "options": {
          "maxTokens": 1500,
          "temperature": 0.4
        }
      },
      "id": "ai-agent-respond",
      "name": "AI Agent Respond",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1,
      "position": [
        1100,
        -100
      ],
      "notes": "Replace with local LLM HTTP Request node for offline use"
    },
    {
      "parameters": {
        "jsCode": "const aiResponse = $input.first().json.message?.content || $input.first().json.text || 'No response generated';\nconst query = $('Parse Input').first().json.query;\n\nreturn [{\n  json: {\n    status: 'success',\n    query: query,\n    response: aiResponse,\n    timestamp: new Date().toISOString(),\n    agent: 'n8n-ai-agent-v1'\n  }\n}];"
      },
      "id": "format-response",
      "name": "Format Response",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1320,
        -100
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify($json) }}",
        "options": {}
      },
      "id": "send-response",
      "name": "Send Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1540,
        -100
      ]
    },
    {
      "parameters": {
        "jsCode": "const query = $('Parse Input').first().json.query;\nreturn [{\n  json: {\n    status: 'success',\n    query: query,\n    response: `Direct answer for: ${query}. This path handles non-search queries like calculations, definitions, or simple Q&A.`,\n    timestamp: new Date().toISOString(),\n    agent: 'n8n-ai-agent-v1'\n  }\n}];"
      },
      "id": "direct-answer",
      "name": "Direct Answer",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        660,
        100
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify($json) }}",
        "options": {}
      },
      "id": "send-direct-response",
      "name": "Send Direct Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        880,
        100
      ]
    }
  ],
  "connections": {
    "Webhook Trigger": {
      "main": [
        [
          {
            "node": "Parse Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Input": {
      "main": [
        [
          {
            "node": "Route Action",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route Action": {
      "main": [
        [
          {
            "node": "Web Search",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Direct Answer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Web Search": {
      "main": [
        [
          {
            "node": "Build Agent Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Agent Prompt": {
      "main": [
        [
          {
            "node": "AI Agent Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent Respond": {
      "main": [
        [
          {
            "node": "Format Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Response": {
      "main": [
        [
          {
            "node": "Send Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Direct Answer": {
      "main": [
        [
          {
            "node": "Send Direct Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "tags": [
    {
      "name": "ai-agent"
    },
    {
      "name": "automation"
    },
    {
      "name": "webhook"
    }
  ]
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

AI Agent - Search & Summarize. Uses httpRequest, openAi. Webhook trigger; 10 nodes.

Source: https://github.com/visheshv1/n8n-automation-hub/blob/be5db9378325c2c8cd9dac9611338d1c1d78f09f/workflows/ai-agent.json — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

CLINICAINTEGRAL_secretary. Uses postgres, mcpClientTool, googleDriveTool, toolWorkflow. Webhook trigger; 89 nodes.

Postgres, Mcp Client Tool, Google Drive Tool +14
AI & RAG

Remi 1.1. Uses lmChatOpenAi, memoryPostgresChat, openAi, postgres. Webhook trigger; 89 nodes.

OpenAI Chat, Memory Postgres Chat, OpenAI +7
AI & RAG

This n8n workflow orchestrates a powerful suite of AI Agents and automations to manage and optimize various aspects of an e-commerce operation, particularly for platforms like Shopify. It leverages La

Google Sheets, HTTP Request, Slack +10
AI & RAG

My workflow 7. Uses openAi, redis, httpRequest, agent. Webhook trigger; 77 nodes.

OpenAI, Redis, HTTP Request +8
AI & RAG

What if AI didn't just write content—but actually thought about how to write it? This n8n workflow revolutionizes content creation by deploying multiple specialized AI agents that handle every aspect

Tool Http Request, Anthropic Chat, Airtable +7