AI-Powered Website Prompt Execution using Apify and Gemini - n8n Workflow

Scrape websites and run advanced custom analysis prompts using this powerful n8n workflow. Integrate Apify scraping data with Gemini via OpenRouter to get structured results.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Automation developers looking for advanced n8n templates for web data processing.
Researchers needing to execute complex queries across large website archives.
Marketing and sales teams requiring structured data (like contact info or product lists) extracted via AI.
Users who need a dynamic n8n trigger for reusable web scraping automation.

Overview

The challenge of web data extraction often lies not just in scraping the content, but interpreting it to answer specific, nuanced questions. This powerful n8n workflow solves this by tightly integrating web scraping with large language model (LLM) analysis. Utilizing an Apify scraper accessed via an HTTP Request n8n node, the automation efficiently gathers structured content and Markdown from target websites. The unique value is found in the subsequent AI Agent steps: the workflow dynamically applies a user-defined prompt to every scraped page. This enables tasks far beyond standard scraping, such as extracting specific competitive intelligence, summarizing vast sections of a site, or creating structured output for further analysis. This robust n8n workflow provides a scalable, repeatable solution.

How it Works

This reusable n8n workflow begins with the When Executed by Another Workflow n8n trigger, which accepts input parameters defining the target URL, maximum pages to scrape, and the crucial custom AI prompt.


  1. Scraping Initiation: The workflow passes these parameters to an HTTP Request n8n node, which synchronously executes an Apify Web Scraper Actor. This actor gathers the raw content and markdown for analysis.

  2. Batch Processing: The results are fed into the Loop Over Items n8n node, splitting the scraped pages into individual items, ensuring each page is analyzed separately.

  3. Page-Level AI Analysis: For each page, the first AI Agent n8n node takes the original prompt, the page metadata, and the page markdown. This agent uses the OpenRouter Chat Model (Gemini 2.5 Flash) to perform a focused analysis against the specific content of that single page.

  4. Data Aggregation: The Aggregate n8n node collects the individual AI analyses from all processed pages.

  5. Final Synthesis: A second, final AI Agent1 n8n node receives the combined output. Using a highly capable model via OpenRouter Chat Model1 (Gemini 2.5 Pro) and a strong system prompt, it synthesizes all the extracted information into a clean, final, structured JSON response based on the user's original n8n trigger prompt. This provides the ultimate actionable result from the entire n8n workflow.

Installation Guide

To deploy this n8n template, follow these steps:


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

  2. Set Apify Credentials: Locate the HTTP Request n8n node. You must replace yourapifyapi_token in the URL parameter with your actual Apify API key. This is essential for the Apify scraper to run.

  3. Set OpenRouter Credentials: The OpenRouter Chat Model n8n node and OpenRouter Chat Model1 n8n node require an existing OpenRouter API key credential. Set up a new credential if one does not exist and ensure both LLM nodes are using the correct connection.

  4. Testing: Use the Test function on the initial n8n trigger node (When Executed by Another Workflow) to simulate an incoming request and ensure all credentials are valid before deployment.

Node Details

When Executed by Another Workflow (n8n trigger): This node acts as the entry point, defining the structure of the input required to run the n8n workflow, including url, maxPages, and the AI prompt.
HTTP Request (n8n node): Executes the third-party Apify Web Scraper. It dynamically constructs the request body using data passed from the n8n trigger, specifically targeting a markdown content scraper actor.
Loop Over Items (n8n node): Essential for iteration. It splits the array of scraped results (one item per page) into single batches, allowing the downstream AI Agent to analyze page-by-page.
AI Agent (LangChain n8n node): This is the core logic n8n node for per-page analysis. It combines the original user prompt with the current page's markdown content, using LLM capabilities to fulfill the instruction.
OpenRouter Chat Model / OpenRouter Chat Model1 (n8n node): These nodes provide the language model backend (Gemini 2.5 Flash and Pro, respectively) used by the AI Agents. The selection of a more powerful model for the final synthesis (AI Agent1) ensures high-quality, structured output for the final n8n workflow result.
Aggregate (n8n node): Gathers the output field from every item processed by the looping AI Agent step, preparing the collection of partial answers for the final synthesis n8n node.

Related n8n Workflows

Free

Nodes: 7 Nodes
Updated: December 26 2025
View all
Created by
Msaid Mohamed el hadi
Msaid Mohamed el hadi

Hi! I’m Mohamed El Hadi, a passionate developer and automation expert from Algeria. I specialize in building smart, scalable workflows using n8n to streamline business operations, save time, and drive innovation. 🌍 Open to collaborations | 🤖 Automation lover | 💼 Founder of EcoPetDZ & AADL Auto Reload