Extract structured data from webpages with Apify and OpenAI
Ready for 3.0Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.
Nodes used (8)
- Webhook
n8n-nodes-base.webhook - Edit Fields (Set)
n8n-nodes-base.set - If
n8n-nodes-base.if - HTTP Request
n8n-nodes-base.httpRequest - Respond to Webhook
n8n-nodes-base.respondToWebhook - AI Agent
@n8n/n8n-nodes-langchain.agent - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Structured Output Parser
@n8n/n8n-nodes-langchain.outputParserStructured
What it does
Quick overview This workflow exposes a webhook that finds or accepts a target webpage, scrapes it to clean Markdown using Apify, and uses OpenAI with a dynamic schema to return structured JSON fields requested by the caller. How it works 1. Receives a POST webhook request containing either a direct targeturl or a subject + websitedomain, plus a required targetdata array of fields to extract. 2. Validates that targetdata is provided and returns a 400 response if it is missing or empty. 3. Resolves the page URL by using the provided targeturl or running an Apify Google Search Scraper site: query and taking the first organic result. 4. If no matching URL is found, returns a 404 response to the caller. 5. Scrapes the resolved URL with Apify Website Content Crawler (optionally using provided cookies) and normalizes the returned Markdown and content length. 6. If the scraped content is too short, returns a 200 response with success:false indicating no content could be extracted. 7. Sends the page content and requested field definitions to OpenAI and returns a 200 response with the extracted fields as structured JSON (using "NA" for missing values). Setup 1. Create an Apify account and add an n8n Header Auth credential that sends Authorization: Bearer <APIFYTOKEN, then select it on both Apify HTTP Request steps. 2. Add an OpenAI API credential and select it for the OpenAI chat model used for extraction. 3. Configure the webhook path in your calling app and send a JSON body with targetdata plus either targeturl or subject and websitedomain (and optional cookies). 4. Adjust defaults such as crawler type, crawl limits, timeouts, and minimum content length in the workflow’s configuration values if needed. Additional info Extract structured data from any webpage using Apify and AI 📥 Open full documentation on Notion Need help customizing? Contact me for consulting and support : Linkedin MY NEW YOUTUBE CHANNEL 👉 Subscribe to my new YouTube channel. Here I'll share videos and Shorts with practical tutorials and FREE templates for n8n. !The AI Doctor