Hybrid Document and Web Content Analyzer with GPT-4o - n8n Workflow

Use this powerful n8n workflow to analyze local documents (PDF, MD, JSON) and web content (URLs) using GPT-4o. Get structured, accurate answers instantly. Essential n8n templates for knowledge management.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Technical analysts or researchers needing to quickly query large documents.
Users of n8n who require advanced AI-powered text processing capabilities.
Developers looking for robust n8n templates for handling mixed file inputs (local files and URLs).
Automation specialists seeking a complex n8n node combination for information extraction.

Overview

Information retrieval and analysis can be challenging when dealing with diverse sources—local PDFs, markdown documentation, and complex HTML web pages. This specialized n8n workflow solves this by creating a unified processing pipeline capable of ingesting content from local paths or remote URLs, cleaning and processing the data, and then passing it to the highly capable GPT-4o model for deep analysis. This n8n workflow ensures that content, regardless of its origin or format, is accurately analyzed, providing users with well-structured, evidence-based answers. It is one of the most versatile n8n templates for knowledge management and AI-driven content analysis, leveraging the power of custom code and core n8n node logic.

How it Works

This n8n workflow begins with the Document Q&A Chat n8n trigger, which initiates the process upon receiving an input string. This n8n trigger expects input in the strict format: documentpathorurl | yourquestion.


  1. Parsing and Validation: The Parse Document & Question code n8n node analyzes the input, validates the document path/URL and question length, and determines the file type (e.g., PDF, HTML, JSON) and source type (URL or local file).

  2. Conditional Routing: The flow then splits using File Path Check (for local files) and URL Check (for web content) n8n node logic.

  3. Data Acquisition: If local, the Read Document File and Extract Document Content n8n nodes load and extract text from the file. If remote, the Fetch Web Content HTTP Request n8n node retrieves the raw HTML or text data.

  4. Content Preparation: The Process Document Content code n8n node is crucial. It cleans the content, specifically stripping HTML tags from web pages and handling other structural formats (like Markdown, JSON). It also implements truncation to manage token limits, ensuring the data is ready for the AI.

  5. AI Analysis: The cleaned content and the user's question are sent to the Analyze Document & Answer n8n node (a LangChain Agent). This agent utilizes a connection to the OpenAI Document Analyzer (using the GPT-4o model). The agent's prompt includes detailed instructions, ensuring the final output is highly structured, uses tables and bullet points, and accurately addresses the query based only on the provided content. This sophisticated prompt design is key to making this n8n workflow successful.

Installation Guide

To use this n8n workflow, follow these steps:


  1. Import: Copy the provided JSON code and import it directly into your n8n instance using the 'New' menu > 'Import from JSON'.

  2. OpenAI Credentials: You must configure the required credentials for the OpenAI Document Analyzer n8n node. Click on the node, select 'Create New Credential' for the OpenAI API, and enter your OpenAI API key.

  3. Local File Access (if applicable): If you intend to analyze local files, ensure the n8n execution environment has file system access to the paths specified in your inputs.

  4. Activation: Save the n8n workflow and set it to 'Active'. Since the trigger is a Chat Trigger, you will interact with it via the designated webhook or chat UI.

Node Details

Document Q&A Chat (Langchain Chat Trigger): The starting n8n node. It registers a webhook (simple-doc-analyzer-chat) to receive user input, acting as the primary n8n trigger for the analysis process.
Parse Document & Question (Code Node): This custom n8n node handles input validation and separation. It determines if the input is a URL or file path and identifies the file extension, setting key variables for downstream routing.
File Path Check / URL Check (If Nodes): Core logic n8n nodes that route the execution path based on the isUrl boolean value determined in the previous step.
Fetch Web Content (HTTP Request Node): Used exclusively for URL inputs. It fetches content, setting headers like User-Agent to successfully retrieve text and HTML content from the web.
Extract Document Content (Extract From File Node): Used for local files. This n8n node specifically pulls text data out of binary files loaded by the Read Binary File n8n node.
Process Document Content (Code Node): A critical processing n8n node. It performs content cleanup, especially sanitizing HTML by removing script/style tags and converting it to plain text. It also truncates content over 15,000 characters to optimize token usage for the LLM.
OpenAI Document Analyzer (LM Chat OpenAI Node): Configures the connection to the large language model, specifically selecting the gpt-4o model for high-quality analysis.
Analyze Document & Answer (LangChain Agent Node): This final n8n node executes the core task. It contains an extensive, structured prompt, leveraging the processed content and user question to generate a detailed, formatted report.

Related n8n Workflows

Free

Nodes: 9 Nodes
Updated: December 26 2025
View all
Created by

An enthusiast DevOps Engineer with 3+ years of experience in devops tools and automation.

Featured*