Animated data flow diagram

AI Web Query & Semantic Re-Ranking Agent

Version: 1.0.0 | Last Updated: 2025-05-16

Integrates with:

Google Gemini Brave Search Langchain OpenAI Anthropic

Overview

Unlock Precision Web Research with this AI Agent

This powerful n8n AI Agent automates the complex process of web research. It takes your natural language research question, intelligently formulates an optimized search query using Large Language Models (LLMs), executes the search via the Brave Search API, and then employs another LLM to semantically re-rank the results and extract key information. Stop sifting through irrelevant search pages and get straight to the insights you need.

This agent acts as an intelligent research assistant, capable of:

  • Intelligent Query Formulation: Understanding the intent behind your question to craft effective search terms.
  • Automated Web Searching: Programmatically querying the Brave Search engine for fresh, comprehensive results.
  • Semantic Result Re-Ranking: Analyzing search result snippets (titles, descriptions) for contextual relevance to your original question and prioritizing the most valuable links.
  • Information Extraction: Pulling out salient details from the top-ranked results.

Key Features & Benefits

  • AI-Driven Query Optimization: Leverages LLMs (Google Gemini by default) to translate broad research questions into precise, effective search queries, improving result quality.
  • Brave Search Integration: Utilizes the Brave Search API for real-time, privacy-respecting web searches.
  • Advanced Semantic Re-Ranking: Goes beyond keyword matching by using LLMs to understand the meaning and context of search results, delivering a ranked list of the top 10 most relevant URLs.
  • Structured & Actionable Output: Returns results in a clean JSON format, including ranked URLs (with titles and descriptions) and extracted information, ready for use in other automations or reports.
  • Flexible LLM Integration: Comes pre-configured with Google Gemini, but includes nodes for easy swapping to OpenAI (GPT-4, etc.) or Anthropic (Claude) models to suit your preferences or existing subscriptions.
  • Time-Aware Analysis: Incorporates the current date into its processing to ensure the relevance of time-sensitive information.
  • Webhook Triggered: Easily callable from other n8n workflows or external applications.

Use Cases

  • B2C E-commerce: Automate market research by finding latest trends, competitor analysis, or customer sentiment from the web, with results ranked for relevance.
  • B2B SaaS: Streamline product research by identifying emerging technologies, understanding competitor features, or gathering industry reports, all intelligently queried and re-ranked.
  • Founders & Solopreneurs: Quickly gather and synthesize information for business plans, investment pitches, or content creation, saving hours of manual searching.
  • CTOs & Heads of Automation: Implement an intelligent information retrieval backbone for internal knowledge bases or customer-facing Q&A systems.

Prerequisites

  • An n8n instance (Cloud or self-hosted).
  • Google Gemini API Key (or API key for your chosen LLM like OpenAI or Anthropic).
  • Brave Search API Key (a free tier is available).
  • Credentials for Google Gemini (or chosen LLM) and Brave Search configured in your n8n instance.

Setup Instructions

  1. Download the n8n workflow JSON file.
  2. Import the workflow into your n8n instance.
  3. Configure LLM Credentials:
    • The 'Agent Model' and 'Parser Model' nodes are pre-configured for Google Gemini. Add your Google Gemini API key to the 'Google Gemini (PaLM) Api account 4' credential or create a new one and select it in these nodes.
    • Alternatively, to use OpenAI or Anthropic: disconnect the 'Agent Model' (Gemini) from 'Semantic Search -Query Maker' and 'Semantic Search - Result Re-Ranker'. Connect the 'OpenAI Chat Model' or 'Anthropic Chat Model' node instead. Configure your OpenAI/Anthropic credentials in these nodes. You'll also need to connect a suitable parser model if you change the LLM for the 'Auto-fixing Output Parser' nodes.
  4. Configure Brave Search API Key:
    • In the 'Query' (HTTP Request) node, update the X-Subscription-Token header value with your Brave Search API Key. Refer to the 'Sticky Note4' in the workflow for instructions on getting a free Brave Search API key.
  5. Triggering the Workflow:
    • The workflow is triggered via the 'Webhook' node. Copy its 'Production URL'.
    • You can send a POST request to this URL with a JSON body containing your query, for example: {"Research Question": "What are the latest advancements in AI for drug discovery?"}. The 'Webhook Call' node within the template provides an example of how to call this webhook (you'd typically use a similar HTTP Request node from another workflow or application).
  6. (Optional) Customize the prompts in the 'Semantic Search -Query Maker' and 'Semantic Search - Result Re-Ranker' LLM Chain nodes to tailor query generation and result analysis to your specific needs.
  7. Activate the workflow.

Tags:

AI AgentWeb ResearchSemantic SearchLLMInformation RetrievalBrave SearchGoogle GeminiAutomationLangchain

Want your own unique AI agent?

Talk to us - we know how to build custom AI agents for your specific needs.

Schedule a Consultation