Executive Summary
Build a production-ready n8n workflow that converts a single news article URL into platform-optimized social posts (LinkedIn, Reddit, X/Twitter) plus an AI-generated image. The 8-node architecture below is cost-aware, robust, and designed for scale:

Workflow Architecture at a Glance
Here's the streamlined, production-ready 8-node workflow :
Manual Trigger → HTTP Request → HTML Parser → OpenAI GPT (LinkedIn)
→ OpenAI GPT (Reddit) → OpenAI GPT (X/Twitter) → OpenAI Image → Output FormatterThis system ensures each article URL becomes a LinkedIn post (200–250 words), Reddit post (300–400 words), and tweet (<280 characters) , all accompanied by a social-optimized AI image .
Platform-Specific Optimization
LinkedIn: Insight-driven, short paragraphs, clear call-to-engagement.
Reddit: Contextual, non-promotional, encourages discussion.
Twitter/X: Short, punchy, curiosity-driven.

High-level workflow design
Manual Trigger — user pastes article URL (or webhook/bookmarklet triggers).
HTTP Request — fetch article HTML with safe headers and optional rendering fallback.
HTML Parser — extract title, author, published date, main content (or call an extractor like Mercury/Readability).
OpenAI GPT (LinkedIn) — produce 200–250 word professional post.
OpenAI GPT (Reddit) — produce 300–400 word discussion post with context.
OpenAI GPT (X/Twitter) — produce <280 char viral-optimized tweet.
OpenAI Image — build DALL·E 3 prompt from article and generate image in landscape/1.91:1 for social.
Output Formatter — assemble final JSON with content + image URL, metadata, QA score.
Sample Outputs (toy example using a TechCrunch-style headline)
Input URL: https://www.c-sharpcorner.com/ 2025/09/01/ai-startup-raises-series-b/
Extracted title: AI startup raises $120M to scale privacy-preserving ML
LinkedIn (sample, 220 words):
Companies investing in privacy-preserving ML are betting that trust will be the real competitive edge...
[two short paragraphs with insights and one practical takeaway]
Hashtags:#AI #Privacy #ML
Engagement question: What steps is your org taking to make ML models privacy-aware?
Reddit (sample, 350 words) — summary, bullet points, 3 open questions suitable for r/MachineLearning.
Tweet (sample):
New $120M bet on privacy-first ML — is trust the next moat in AI? 🔐 #AI #Privacy
Image: a clean, blue-toned photo-realistic composition showing abstract neural-network overlays on a city skyline (1200×628 px).
Node 1 — Manual Trigger
Purpose: Accept a news article URL + optional metadata (platform toggles/tone).
n8n config:
Node type:
Manual Trigger(orWebhookfor automation).Inputs:
url(string, required)source(string, optional — e.g., TechCrunch, BBC)force_render(boolean, optional) — if true, use a headless-render servicepreferred_image_style(enum: photographic, illustration, flat, minimal)
Usage: If you want a one-click from the browser, create a Webhook node and a bookmarklet that opens a request.
Fallback: When used as a webhook, validate origin: check headers.referer or HMAC signature.
Validation snippet (Function node style):
// Validate input
const item = items[0].json;
if (!item.url || !/^https?:\/\/.+/i.test(item.url)) {
throw new Error('Invalid or missing URL in input');
}
return items;Node 2 — HTTP Request (Fetch HTML)
Purpose: Retrieve raw HTML. Use headers & user-agent; optionally route through a renderer for JS-heavy pages.
n8n config (HTTP Request node):
Method:
GETURL:
{{$json["url"]}}Response Format:
StringTimeout:
150000(150s) — for slow pagesHeaders:
User-Agent: Mozilla/5.0 (compatible; n8n-bot/1.0; +https://yourdomain.example)Accept-Language: en-US,en;q=0.9
Follow Redirects: true
Authentication: none (unless internal)
Query Parameters: none
Options:
If site blocks non-browser UA: set
Accept&User-Agentto a real browser UA.For paywalled/dynamic content: set
force_render=trueand call a headless rendering service (Puppeteer cloud, Rendertron, Browserless). Configure the rendering service URL in credential settings.
JS fallback (Function node to optionally render):
// Example: If response doesn't contain main article markers, call renderer
const html = $json['body'] || '';
if (html.length < 2000 || !/article|<main|schema.org\/Article/i.test(html)) {
// Call external renderer via HTTP Request node or cloud function
// Put a flag so we don't loop indefinitely
return [{ json: { needsRendered: true } }];
}
return [{ json: { html } }];Error handling:
Retry on 5xx with exponential backoff (2s, 6s, 18s) up to 3 tries.
If the domain blocks requests, return a clear error and suggestion: "Use the browser bookmarklet or pass article text".
Security/legal note: Do not bypass paywalls illegally. Prefer user-provided content copy/paste for subscriber content.
Node 3 — HTML Parser (extract article)
Purpose: Extract: title , author , published_date , lead_image , and main_text .
Two approaches:
n8n Built-in HTML Extract node (fast; CSS selectors).
Function node + Cheerio (fallback for complex pages) — we include both.
A) HTML Extract Node config (preferred)
Mode:
HTMLInput:
{{$node["HTTP Request"].json["body"]}}Fields to extract:
Title: selector
meta[property="og:title"], titleAuthor:
meta[name="author"], .authorDate:
meta[property="article:published_time"], time[datetime]Lead image:
meta[property="og:image"]Main content: selector heuristics like
article, main, .article-body, .post-content
Use
multiplefalse for scalars,multipletrue for paragraphs (then join).
Selectors + Regex fallback:
Title:
document.querySelector('meta[property="og:title"]')?.content || document.titleDate format: parse ISO-like using
new Date().
B) Function node using Cheerio (robust)
If you prefer a code approach (n8n Function node supports cheerio via importing), use this:
const cheerio = require('cheerio'); // available in n8n Function?
// If not, the HTTP Request node can call a cloud function that runs cheerio.
const html = $node['HTTP Request'].json['body'];
const $ = cheerio.load(html);
function meta(name) {
return $(`meta[name="${name}"]`).attr('content') || $(`meta[property="${name}"]`).attr('content');
}
const title = meta('og:title') || $('title').first().text().trim();
const author = meta('author') || $('[rel=author]').first().text().trim() || $('.author').first().text().trim();
const date = meta('article:published_time') || $('time[datetime]').attr('datetime') || $('meta[name="date"]').attr('content');
const lead_image = meta('og:image') || $('img').first().attr('src');
// Main content heuristics: article > p, .article-body p, .post-content p
let paragraphs = [];
['article', '.article-body', '.post-content', '.entry-content', 'main'].some(sel => {
const p = $(`${sel} p`).map((i, el) => $(el).text().trim()).get().filter(Boolean);
if (p.length) { paragraphs = p; return true; }
});
if (!paragraphs.length) {
// fallback: largest block of text
const candidates = $('p').map((i, el) => $(el).text().trim()).get();
paragraphs = candidates.slice(0, 12);
}
const mainText = paragraphs.join('\n\n').trim();
return [{ json: { title, author, date, lead_image, mainText, sourceDomain: new URL($node['HTTP Request'].json.url).hostname } }];Regex patterns (useful for cleanup):
Remove scripts/styles:
/<script[\s\S]*?>[\s\S]*?<\/script>/giand/<style[\s\S]*?>[\s\S]*?<\/style>/giTrim consecutive whitespace:
/\s{2,}/g→' 'Remove inline ads or "Read more" footers:
/Read more|Subscribe|Sign up|Continue reading/gi
Validation:
Minimum mainText length: 200 chars → else abort with suggestion "Try forced renderer or manual copy".
Node 4 — OpenAI GPT (LinkedIn)
Purpose: Generate 200–250 word professional, thought-leadership LinkedIn post with hashtags and an engagement question.
Authentication: Use n8n OpenAI node credentials (OpenAI API Key). You can use the built-in OpenAI node or an HTTP Request node calling the OpenAI REST API.
Model recommendation:
GPT-4o for best quality & succinctness if budget allows. Otherwise, gpt-3.5-turbo for cost savings. For production, recommend using GPT-4o for LinkedIn only if ROI is justified. (Model availability depends on your OpenAI plan.) n8n Docs+1
Prompt engineering
System prompt (system):
You are a professional communications specialist crafting LinkedIn posts for senior technology audiences. Tone: authoritative, helpful, and concise. Use thought leadership framing and recommend one practical takeaway. Provide 3 relevant hashtags. Include a single engagement question at the end. User prompt (user):
Article title: {{title}}
Source: {{sourceDomain}}
Published: {{date}}
Lead sentence / summary: {{firstParagraph}}
Full text excerpt (for context): {{mainText (first 800 tokens)}}
Instructions:
- Write a LinkedIn post of 200-250 words.
- Use a professional tone and include 2–3 industry insights based on the article content.
- Add exactly 3 hashtags (relevant, no more).
- Finish with a single engagement question (e.g., "What do you think about...?").
- Avoid mentioning "as an AI" or "I as an AI".
- Keep paragraphs short (max 2 sentences each).
Return as JSON with keys: "post_text", "hashtags", "engagement_question". n8n OpenAI Node config (chat completion):
Resource:
Chat CompletionModel:
gpt-4o(orgpt-3.5-turbo)Messages: JSON array with
role:systemandrole:userabove.Max tokens: 600
Temperature: 0.2 (professional)
Top_p: 0.9
Frequency_penalty: 0.2
Presence_penalty: 0.0
Token optimization strategies:
Send only the first 800–1200 tokens of the article in
usercontext (trim long articles).Provide a short
firstParagraph+ 2–3 bullet key points extracted by parser instead of the full article.
Error handling & retry:
On rate limit (429), implement exponential backoff: wait 2s → 6s → 18s, retry 3 times.
If the model returns content > 250 words, run a quick truncation/rewriter pass to enforce limits.
Fallback: If GPT fails, use a templated filler:
[Title]: short 220-word template based on title and first paragraph... (insert paraphrase)Node 5 — OpenAI GPT (Reddit)
Purpose: Produce a 300–400 word Reddit-friendly post designed to provoke discussion in a relevant subreddit. Include context and discussion prompts.
System prompt:
You are a community manager writing a Reddit post for a tech/business subreddit. Tone: neutral, open-ended, encouraging discussion. Provide background, key points, and 3 discussion prompts. Avoid promotional language and first-person marketing. Target length: 300-400 words. User prompt:
Title: {{title}} — write a Reddit post suitable for r/technology or r/business.
Include:
- A short summary (2-3 sentences)
- 3 evidence-backed talking points (concise)
- Encouraging open-ended questions (3)
Length: 300–400 words.
Return JSON: { "post_body", "discussion_prompts", "suggested_subreddits": ["r/technology"] } 
Join the conversation! Your thoughts help the community grow.