{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "812de487-e4d4-4b50-9b1b-dd51ae6bff51",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -440,
        -60
      ],
      "parameters": {
        "inputSource": "jsonExample",
        "jsonExample": "{\n    \"enqueue\": true,\n    \"maxPages\": 5,\n    \"url\": \"https://apify.com\",\n    \"method\": \"GET\",\n    \"prompt\":\"collect all contact informations available on this website \"\n   \n}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "796399e7-7027-469d-861e-c56811323091",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -220,
        -60
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/mohamedgb00714~firescraper-ai-website-content-markdown-scraper/run-sync-get-dataset-items?token=YOUR_TOKEN_HERE",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n    \"enqueue\": {{ $json.enqueue }},\n    \"getHtml\": false,\n    \"getText\": false,\n    \"maxPages\": {{ $json.maxPages }},\n    \"screenshot\": false,\n    \"startUrls\": [\n        {\n            \"url\": \"{{ $json.url }}\",\n            \"method\": \"{{ $json.method }}\"\n        }\n    ]\n}",
        "sendBody": true,
        "specifyBody": "json"
      },
      "typeVersion": 4.2
    },
    {
      "id": "da495119-6f7f-443b-8360-37015a3cb3a1",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        0,
        -60
      ],
      "parameters": {
        "options": {},
        "batchSize": "=1"
      },
      "typeVersion": 3
    },
    {
      "id": "5e9e67bf-5725-4021-b7dc-f3c2ad2083cb",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        440,
        -40
      ],
      "parameters": {
        "text": "={{ $('When Executed by Another Workflow').item.json.prompt }}\nthis is only analyse of one page of full website here is the  metadata and markdown of page {{ $json.url }}\nmetadata:{{ JSON.stringify( $json.metadata) }}\nmarkdown:{{ $json.markdown }}\n",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "1c9014f7-fbcb-4dec-a4ff-eb441c8654c3",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        440,
        260
      ],
      "parameters": {
        "model": "google/gemini-2.5-flash",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "97d26611-95cd-4d32-9217-d79a93889783",
      "name": "AI Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        920,
        -240
      ],
      "parameters": {
        "text": "={{ JSON.stringify($json) }}",
        "options": {
          "systemMessage": "=You are a helpful assistant you should collect alll informations from input to respond to this prompt with json format {{ $('When Executed by Another Workflow').item.json.prompt }}\n"
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "6b84a208-802b-470c-9bcd-3c700f635f79",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        520,
        -300
      ],
      "parameters": {
        "options": {},
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "output"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e752bfa3-f3b1-4909-a99f-36401379ab69",
      "name": "OpenRouter Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        940,
        -20
      ],
      "parameters": {
        "model": "google/gemini-2.5-pro-preview",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c5c2ac9f-013f-489f-bb56-f3359a7e5523",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1280,
        -440
      ],
      "parameters": {
        "width": 760,
        "height": 2420,
        "content": "\n# \ud83d\udd0d AI-Powered Website Prompt Executor (Apify + OpenRouter)\n\nThis workflow combines the power of [Apify](https://apify.com) and [OpenRouter](https://openrouter.ai) to **scrape website content** and **execute any custom prompt** using AI. You define what you want \u2014 whether it\u2019s extracting contact details, summarizing content, collecting job offers, or anything else \u2014 and the system intelligently processes the site to give you results.\n\n## \ud83d\ude80 Overview\n\nThis workflow allows you to:\n1. Input a URL and define a prompt.\n2. Scrape the specified number of pages from the website.\n3. Process each page\u2019s metadata and Markdown content.\n4. Use AI to interpret and respond to the prompt on each page.\n5. Aggregate and return structured output.\n\n## \ud83e\udde0 How It Works\n\n### Input Example\n\n```json\n{\n  \"enqueue\": true,\n  \"maxPages\": 5,\n  \"url\": \"https://apify.com\",\n  \"method\": \"GET\",\n  \"prompt\": \"collect all contact informations available on this website\"\n}\n````\n\n### Workflow Steps\n\n| Step | Action                                                                                                                                                                         |\n| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| 1    | Triggered by another workflow with JSON input.                                                                                                                                 |\n| 2    | Calls the Apify actor [`firescraper-ai-website-content-markdown-scraper`](https://apify.com/mohamedgb00714/firescraper-ai-website-content-markdown-scraper) to scrape content. |\n| 3    | Loops through the scraped pages.                                                                                                                                               |\n| 4    | AI analyzes each page based on the input prompt.                                                                                                                               |\n| 5    | Aggregates AI outputs across all pages.                                                                                                                                        |\n| 6    | Final AI processing step to return a clean structured result.                                                                                                                  |\n\n---\n\n## \ud83d\udee0 Technologies Used\n\n* **Apify** \u2013 Scrapes structured content and Markdown from websites.\n* **OpenRouter** \u2013 Provides access to advanced AI models like Gemini.\n* **LangChain** \u2013 Handles AI agent orchestration and prompt interpretation.\n\n---\n\n## \ud83d\udd27 Customization\n\nCustomize the workflow via the following input fields:\n\n* `url`: Starting point for scraping\n* `maxPages`: Limit the number of pages to crawl\n* `prompt`: Define any instruction (e.g., \u201csummarize this website,\u201d \u201cextract product data,\u201d \u201clist all emails,\u201d etc.)\n\nThis allows dynamic, flexible use across various use cases.\n\n---\n\n## \ud83d\udce6 Output\n\nThe workflow returns a JSON result that includes:\n\n* Processed prompt responses from each page\n* Aggregated AI insights\n* Structured and machine-readable format\n\n---\n\n## \ud83e\uddea Example Use Cases\n\n* \ud83d\udd0d Extracting contact information from websites\n* \ud83d\udcc4 Summarizing articles or company profiles\n* \ud83d\udecd\ufe0f Collecting product information\n* \ud83d\udccb Extracting job listings or news\n* \ud83d\udcec Generating outreach lists from public data\n* \ud83e\udd16 **Used as a tool within other AI agents for real-time web analysis**\n* \ud83e\udde9 **Integrated as an external tool in MCP (Multi-Component Prompt) servers to enhance AI capabilities**\n\n---\n\n## \ud83d\udd10 API Credentials Required\n\nYou will need:\n\n* **Apify API token** \u2013 For running the scraper actor\n* **OpenRouter API key** \u2013 For AI-powered prompt processing\n\nSet these credentials in your environment or n8n credential manager before running.\n\n\n\n\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}