AI Agent for Website Analysis and Q&A using Google Sheets - n8n Workflow

A comprehensive n8n workflow for web crawling, data extraction using GPT-5 nano, and AI-powered Q&A. Store SEO data in Google Sheets and use an n8n agent to instantly query indexed content.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • SEO specialists needing automated content analysis and internal/external link auditing.

  • Content managers looking to rapidly index and summarize external websites.

  • Technical users seeking advanced examples of using LangChain AI agents and custom tooling within an n8n workflow.

  • Anyone looking for robust n8n templates for web scraping and large language model integration.

Overview

This powerful n8n workflow provides a dual-mode solution for interacting with website content. When a new URL is provided, the workflow enters Crawl Mode. It automatically finds the sitemap, fetches every page, uses AI (GPT-5 nano) to extract structured data like language, H1 hierarchy, internal links, external links, and a summary, storing everything neatly in a Google Sheet. Once the initial indexing is complete, the workflow switches permanently to Agent Mode.

In Agent Mode, the system acts as a conversational AI that responds to user queries 'as if it were the website itself.' It uses the Google Sheet database as its primary knowledge base, allowing it to answer complex questions instantly without recrawling. This entire process is orchestrated via n8n node connectivity, offering a robust and scalable solution for creating a private knowledge base from external web data. This unique n8n trigger setup ensures a seamless transition between crawling and Q&A phases.

How it Works

The entire process is initiated by a user message through the dedicated n8n trigger (Chat web).


  1. Schema Check (Dual Mode Selection): The n8n workflow first checks the associated Google Sheet using the Get data schema n8n node to see if the target website has already been indexed (i.e., if the 'Data schema' flag is set to true).

  2. Branch A (Indexed - Agent Mode): If the schema exists, the flow proceeds to the AI Agent (powered by GPT-5 nano). This n8n Agent uses two tools: Get row(s) in sheet in Google Sheets to query the indexed data and HTTP Request2 for live lookups if necessary. The Agent's output is delivered back to the user via Respond to Chat1.

  3. Branch B (New URL - Crawl Mode): If the schema does not exist, the flow validates the user's input URL using a structured AI Agent1 and an OpenAI Chat Model1. If the URL is valid, the n8n workflow continues.

  4. Sitemap Discovery: The workflow generates a random User-Agent, fetches the robots.txt file, extracts the sitemap URL, and downloads the sitemap index.

  5. Target Sitemap Selection: A Message a model n8n node (using GPT-4o) analyzes the sitemap index and user-defined options to pinpoint the specific sitemap (e.g., pages) for crawling.

  6. URL Processing Loop: The specific sitemap is parsed, and the Split URLs n8n node creates a separate item for every page URL. The Loop Over Items node then processes each URL.

  7. Data Extraction: For each page, an HTTP Request n8n node fetches the content, which is converted to Markdown. A specialized AI extractor (Message a model1, using GPT-5 nano) is instructed to pull out key SEO elements (Summary, H1, links, language).

  8. Data Storage & Flagging: The extractor utilizes the Append row in sheet in Google Sheets tool to save the structured data. Simultaneously, a separate branch ensures the 'Data schema' flag is set to true via the Complete n8n node, completing the initial cycle so that subsequent inquiries activate Agent Mode.

Installation Guide

To deploy this expert n8n workflow, follow these steps:


  1. Import the JSON: Copy the provided n8n workflow JSON code and import it directly into your n8n instance.

  2. Configure Credentials: You will need to set up credentials for the following services:

OpenAI API Key: Required for all Large Language Model nodes (GPT-5 nano, GPT-4o, and the AI Agents).
Google Sheets OAuth2: Required for the Google Sheets nodes to read and write data.
* Basic Authentication: Required for the Chat web n8n trigger to secure the public webhook access.

  1. Set up Google Sheet: Create a Google Sheet document titled 'Web chat Workflow' (or update the document ID in all Google Sheets nodes). The sheet must contain the following column headers for the data extraction process to function correctly: Lang, Page URL, External URLs, Internal URLs, Summary Content, H1 and hierarchy, and Data schema.

  2. Activate the Workflow: Ensure all nodes are correctly connected and configured, then activate the entire n8n workflow. The Chat web n8n trigger will provide a public webhook URL for interaction.

Node Details

Chat web (n8n trigger): The starting point for the n8n workflow. It is a LangChain Chat Trigger with Basic Auth enabled, designed to capture user text input (chatInput) for processing.
Get data schema (Google Sheets n8n node): Checks the target Google Sheet for a row where 'Data schema' is true. This determines whether the workflow is in Agent Mode (data exists) or Crawl Mode (data needed).
AI Agent (LangChain n8n node): The core of the Agent Mode. It is configured to act 'as a website' and is linked to the OpenAI Chat Model (gpt-5-nano) and Simple Memory for context continuity. It uses Google Sheets as a knowledge tool.
AI Agent1 (LangChain n8n node): Used in Crawl Mode for input validation. This agent strictly enforces a JSON output using the Structured Output Parser to confirm if the user input is a valid URL (URL_bool).
UA Rotativo1 (Code n8n node): Executes custom JavaScript to select a random User-Agent string (desktop/mobile variants) for HTTP Request nodes, helping to mitigate scraping detection.
Req robots / Maping Sitemap (HTTP Request n8n node): These nodes handle the low-level web extraction necessary to discover and download the site's robots.txt and subsequent sitemap index file, using custom headers provided by the n8n node.
XML / XML1 (XML n8n node): Converts the downloaded sitemap XML content into usable JSON format for further processing by the AI.
Message a model (OpenAI n8n node, GPT-4o): Used strategically after sitemap parsing. This powerful n8n node is tasked with analyzing the sitemap index structure and selecting the specific sitemap URL (e.g., pages sitemap) based on internal flags.
Loop Over Items (SplitInBatches n8n node): Manages the iteration over the list of individual page URLs derived from the sitemap.
Message a model1 (OpenAI n8n node, GPT-5 nano): The page content extractor. It is configured with a system prompt to perform structured analysis on the HTML (converted to Markdown) and uses the Append row in sheet in Google Sheets node as a tool to save the extracted details directly into the database.

Related n8n Workflows

Free

Nodes: 20 Nodes
Updated: December 26 2025
View all
Created by
Oriol Seguí
Oriol Seguí

Completion of a higher degree on the way to university (computer engineering)

Featured*