DEV Community

Manish Kumar
Manish Kumar

Posted on

How to Automatically Turn Blog Posts into Social Media Content with n8n and OpenAI (Free Template)

I publish a blog post. Then I spend the next two hours:

  • Rewriting it as a Twitter thread (5 tweets, each under 280 chars)
  • Adapting it to LinkedIn tone (professional, paragraph breaks, no hashtag spam)
  • Compressing it to an Instagram caption (more emoji, 20+ hashtags)
  • Adding a question hook for Facebook
  • Writing a newsletter snippet to drive click-throughs

Same content. Five rewrites. 2+ hours. Every single post.

So I automated it with n8n and OpenAI. Now each new blog post triggers a workflow that generates all 5 social posts in about 30 seconds, delivers them to Slack for review, and logs them to Google Sheets. I copy-paste and publish.

Here's exactly how it works, and you can grab the free template at the bottom.

The Problem with Manual Content Repurposing

Content repurposing is one of those tasks that feels optional until you look at the math.

If you publish 4 blog posts a month and spend 2 hours per post on social repurposing, that's 8 hours a month — 96 hours a year — on mechanical rewriting work. That's more than two full working weeks, spent on a task that doesn't require your expertise.

The real cost isn't even the time. It's the inconsistency. When you're tired or rushed, the LinkedIn post is weak. The Twitter thread is just the intro paragraph split into 280-char chunks. The Instagram caption is the LinkedIn post with emojis thrown in. The content gets published but it doesn't perform.

AI handles this better than a tired human does at 11 PM before scheduling posts.

How the Workflow Works

The n8n workflow is a linear pipeline: detect new post → fetch content → generate → deliver.

The pipeline:

  1. RSS Trigger (every 30 min) detects new blog posts
  2. Validate Input — catches empty titles/URLs early
  3. Fetch Blog Content — HTTP Request gets full page HTML
  4. Extract Article Text — strips HTML, targets article/main tags
  5. OpenAI GPT-4o generates social posts (with AI fallback on error)
  6. Delivers to Slack, logs to Google Sheets, optionally queues to Buffer

Let me walk through each stage.

Stage 1: Detecting New Blog Posts

The workflow starts with n8n's RSS Feed Trigger node. You point it at your blog's RSS feed URL (usually yourblog.com/feed or yourblog.com/rss.xml) and set a polling interval.

Every 30 minutes, n8n checks the feed. If there's a new item it hasn't seen before, it fires the workflow.

Why RSS instead of a webhook? Most blog platforms (WordPress, Ghost, Webflow, Hashnode, Dev.to) publish RSS feeds automatically. RSS is zero-configuration on the blog side — no webhook setup, no plugin required. If your blog has a feed, you're done.

Stage 2: Input Validation

Before hitting any external API, a Code node validates the RSS item:

const item = $input.item.json;
const title = item.title || '';
const link = item.link || item.url || item.guid || '';

if (!title || !link) {
  throw new Error('Missing title or link from RSS feed');
}

return {
  json: {
    title: title.trim(),
    link: link.trim(),
    description: (item.description || item.summary || '').substring(0, 500)
  }
};
Enter fullscreen mode Exit fullscreen mode

This is simple but important. RSS feeds can have malformed items (especially from older WordPress installs or third-party syndication). Catching bad data early prevents cryptic errors later in the pipeline.

The full version also includes duplicate detection here — it tracks processed URLs in workflow static data and skips items that have already been processed.

Stage 3: Fetching Full Article Content

Here's where most content repurposing tutorials fall short: they use only the RSS excerpt.

RSS descriptions are usually 100-300 words max — often just the post's first paragraph. That's not enough context for OpenAI to generate quality, nuanced social posts that match the full article's tone and key points.

The workflow uses an HTTP Request node to fetch the full blog page HTML, then a Code node extracts the article text:

let content = html;
const articleMatch = html.match(/<article[^>]*>([\s\S]*?)<\/article>/i);
const mainMatch = html.match(/<main[^>]*>([\s\S]*?)<\/main>/i);

if (articleMatch) content = articleMatch[1];
else if (mainMatch) content = mainMatch[1];

content = content
  .replace(/<script[\s\S]*?<\/script>/gi, '')
  .replace(/<style[\s\S]*?<\/style>/gi, '')
  .replace(/<[^>]+>/g, ' ')
  .replace(/&nbsp;/g, ' ')
  .replace(/\s+/g, ' ')
  .trim();

const fullText = content.substring(0, 3000);
Enter fullscreen mode Exit fullscreen mode

It looks for <article> or <main> tags first, strips all HTML, cleans whitespace, and truncates to 3,000 characters — enough content for OpenAI to work with without hitting context limits.

Stage 4: AI Content Generation

The OpenAI node is where the actual work happens. The system prompt is carefully structured to produce consistent, platform-native output.

The prompt enforces per-platform rules: Twitter threads stay under 280 chars per tweet, LinkedIn gets professional paragraph breaks, Instagram gets emoji-friendly storytelling with 20+ hashtags, Facebook gets conversational question hooks, and newsletter snippets create curiosity.

I use GPT-4o-mini by default. It's fast, costs about $0.001-0.003 per post, and produces output that's good enough to publish with minor edits. If you want noticeably higher quality (particularly for LinkedIn), switch to GPT-4o.

The workflow explicitly forces JSON output — no markdown, no code fences. A subsequent Code node parses the JSON and validates all required fields are present.

Stage 5: The AI Fallback Path

This is a feature most tutorials skip, but it matters if you're running this unattended.

If OpenAI is down, rate-limited, or returns invalid JSON, the error output fires instead of breaking the workflow. It routes to a fallback Code node that generates basic posts from the title and excerpt.

The fallback output is basic — but it's better than silence. The Slack message includes a warning that AI generation failed so you know to review it manually.

I've been running this for a few weeks and OpenAI has been unavailable twice during off-hours. The fallback meant zero workflow failures.

Stage 6: Output Delivery

After generation (AI or fallback), three things happen in parallel:

Slack notification: All 5 posts formatted with separators between platforms. Blog title hyperlinked to the original. Hashtags in italic. Delivered to #content.

Google Sheets logging: A content calendar row: date, blog title, URL, all 5 posts, hashtags, AI processed flag, and timestamp.

Buffer integration (optional): Twitter thread and LinkedIn post queued to Buffer for scheduled publishing.

Setting It Up

Prerequisites:

Setup steps:

  1. Import the workflow JSON into n8n (Workflows → Import from File)
  2. RSS Trigger node: Replace the example feed URL with your blog's RSS URL
  3. OpenAI node: Create a new credential → paste your API key
  4. Slack nodes: Create a new credential → paste your Slack Bot Token
  5. Google Sheets node: Create OAuth2 credential → authorize your Google account
  6. Activate the workflow

Estimated setup time: 5 minutes.

The Results

After running this for a few weeks:

  • Consistent promotion: Every post gets distributed, not just the ones I have energy for
  • Better platform fit: GPT-4o-mini actually writes better LinkedIn posts than I do when I'm tired
  • Time saved: ~2 hours per post → ~5 minutes (review + copy-paste from Slack)
  • Content calendar filled automatically: The Google Sheets log doubles as a content record

The quality isn't perfect — you'll still want to review and tweak before publishing. But it's a solid first draft that's 80-90% of the way there.

Customization Tips

Change platforms: Edit the OpenAI system prompt to add Reddit, Threads, Pinterest, or YouTube community posts.

Adjust tone: Add a tone directive: "Write in a casual, conversational tone" or "Write for a technical developer audience."

Add a filter: Insert an IF node after the RSS trigger to only process posts with specific categories or tags.

Direct posting: Replace Slack with platform API nodes — though Twitter's API now requires a paid plan ($100/month), so Slack review + manual posting is usually more practical.

Free Template

The free version handles Twitter + LinkedIn (2 platforms) with basic error handling.

Get the free template on GitHub:

GitHub logo flowyantra / blog-to-social-ai-n8n

Free n8n workflow template — Turn blog posts into Twitter + LinkedIn content using AI. RSS → OpenAI → Slack. 5-minute setup. By FlowYantra.

Blog to Social Posts (AI) — Free n8n Workflow Template

n8n workflow License: MIT OpenAI GPT-4o-mini Made by FlowYantra

Automatically turn every blog post into social media content for Twitter and LinkedIn using n8n and OpenAI. Free template — 5 minutes to set up.

Target keywords: n8n blog to social media automation, n8n content repurposing, automate social media posts n8n


What It Does

This free n8n workflow monitors your blog's RSS feed and automatically generates platform-ready social media posts whenever you publish a new article.

Pipeline:

  1. RSS Feed Trigger detects new blog posts (polls every 30 minutes)
  2. Validates the incoming item (catches malformed RSS entries early)
  3. HTTP Request fetches the full article HTML
  4. Code node strips HTML and extracts clean article text (up to 3,000 chars)
  5. OpenAI GPT-4o-mini generates a Twitter thread (3-5 tweets) + LinkedIn post with hashtags
  6. Slack delivers both posts to your #content channel for review and copy-paste

Cost: ~$0.001-0.003 per blog post in OpenAI API…

Download the JSON file from the repo, import into n8n, add your credentials, and you're running.

Full Version

The full version adds:

  • 5 platforms instead of 2 (+ Instagram, Facebook, Newsletter)
  • Manual trigger for on-demand processing (any URL, not just RSS)
  • Duplicate detection (never reprocesses the same post)
  • AI fallback path (always produces output, even when OpenAI fails)
  • Google Sheets content calendar logging
  • Buffer integration for scheduled posting
  • Full retry logic + Slack error alerts

Available at flowyantra.gumroad.com — $39 one-time, lifetime updates.


Questions about the setup or customization? Drop a comment — happy to help.

Top comments (0)