Back to list
n8n と OpenAI を使ってブログ記事を自動的に SNS コンテンツに転換する方法(無料テンプレート付き)
How to Automatically Turn Blog Posts into Social Media Content with n8n and OpenAI (Free Template)
Translated: 2026/3/21 3:08:05
Japanese Translation
ブログ記事を公開した後、私は次の 2 時間を費やす:Twitter のスレッド(5 つのツイート、各 280 文字未満)への書き換え、LinkedIn のトーンに適応(プロフェッショナルで、段落を区切り、ハッシュタグのスパムを排除)、Instagram のキャプションへの圧縮(より多くの絵文字、20 以上のハッシュタグ)、Facebook への質問フックの追加、クロックを駆使してクリック率を高めるニュースレタースニペットの作成です。同じコンテンツ。5 つのリタッチ。2 時間以上。それぞれの投稿に対して。私はこれを n8n と OpenAI を使って自動化しました。今、新しいブログ投稿はワークフローをトリガーし、約 30 秒以内にすべての 5 つの SNS ポストを生成し、Slack にレビューのために渡され、Google Sheets にロギングされます。私はコピー&ペーストして公開します。これがどのように機能するかを完全に説明し、下部で無料テンプレートを取得できます。コンテンツの再用途は、数学を見てからだけオプションに見えるそのようなタスクの一つです。月に 4 つのブログ記事を公開し、投稿あたり 2 時間を SNS 再用途のために費やす場合、それは月に 8 時間、年に 96 時間、機械的な書き換え作業のために費やされます。それは、専門性を必要としないタスクのために、より 2 つの完全な作業週間を費やします。実際のコストは時間ではありません。それは一貫性の欠如です。あなたが疲れたり急ぎすぎたりすると、LinkedIn の投稿は弱く、Twitter のスレッドは 280 文字のチャンクに分割されたイントロパラグラフのだけで、Instagram のキャプションは絵文字が投げ込まれた LinkedIn の投稿のだけです。コンテンツは公開されますが、それは機能しません。AI は、投稿スケジュール前に 11 時に疲れた人間よりもはるかに良くこれを処理します。n8n のワークフローは線形のパイプラインです:新しい投稿を検出 → コンテンツを取得 → 生成 → 配信。パイプライン:RSS トリガー(30 分ごと)は新しいブログ記事を検出します、入力を確認して空のタイトル/URL を早期にキャッチします、ブログコンテンツを取得して HTTP リクエストで完全なページ HTML を取得し、記事テキストを抽出して HTML を除去し、記事/メインタグを目標とします、OpenAI GPT-4o は SNS ポストを生成し(エラー時に AI にフォールバックします)、Slack へ配信し、Google Sheets にロギングし、オプションとして Buffer へキューします。各ステージを通っていきましょう。ワークフローは n8n の RSS Feed トリガーノードで始まります。あなたはあなたのブログの RSS フィード URL(通常 yourblog.com/feed または yourblog.com/rss.xml)にそれを設定し、 POLLING INTERVAL を設定します。30 分ごとに、n8n はフィードをチェックします。新しいアイテムが見つかったら、それはワークフローを発火させます。なぜ RSS なのかウェブhooks? 多くのブログプラットフォーム(WordPress、Ghost、Webflow、Hashnode、Dev.to)は自動的に RSS フィードを公開します。RSS はブログ側でのゼロ構成です— 設定なし、プラグインなし。もしあなたのブログにフィードがある場合、あなたは完了しています。何らかの外部 API へのアクセス前に、Code ノードは RSS アイテムを検証します: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) } }; これは単純ですが重要です。RSS フィードには malformed アイテムが含まれる可能性があります(特に古い WordPress インストールやサードパーティ製のシンディケーションの場合)。これはパイプラインの後に暗号的なエラーを防ぎます。フルバージョンにはここでは重複検出も含まれます— 処理済みの URL をワークフローの静的データに追跡し、すでに処理されたアイテムをスキップします。ここでは、多くのコンテンツ再用途のチュートリアルが不足しています: 彼らは RSS 抜粋のみを使用します。RSS 記述は通常 100〜300 文字未満で、よく記事の最初のパラグラフだけです。それは OpenAI が記事全体のトーンと主要なポイントに一致する質の高い、ニュアンスのある SNS ポストを生成するのに十分な文脈がありません。ワークフローは、完全なブログページの HTML を取得し、その後 Code ノードで記事テキストを抽出します:let content = html; const articleMatch = html.match(/]*>([\s\S]*?)<\/article>/i); const mainMatch = html.match(/]*>([\s\S]*?)<\/main>/i); if (articleMatch) content = articleMatch[1]; else if (mainMatch) content = mainMatch[1]; content = content .replace(/[^a-zA-Z0-9 \p{L}\p{N}]+/g, ' ') .replace(/[\u200B-\u200D\uFEFF]/g, '') .replace(/<[^>]+>/g, ' ').
Original Content
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. 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. The n8n workflow is a linear pipeline: detect new post → fetch content → generate → deliver. The pipeline: RSS Trigger (every 30 min) detects new blog posts Validate Input — catches empty titles/URLs early Fetch Blog Content — HTTP Request gets full page HTML Extract Article Text — strips HTML, targets article/main tags OpenAI GPT-4o generates social posts (with AI fallback on error) Delivers to Slack, logs to Google Sheets, optionally queues to Buffer Let me walk through each stage. 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. 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) } }; 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. 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(/]*>([\s\S]*?)<\/article>/i); const mainMatch = html.match(/]*>([\s\S]*?)<\/main>/i); if (articleMatch) content = articleMatch[1]; else if (mainMatch) content = mainMatch[1]; content = content .replace(//gi, '') .replace(//gi, '') .replace(/<[^>]+>/g, ' ') .replace(/ /g, ' ') .replace(/\s+/g, ' ') .trim(); const fullText = content.substring(0, 3000); It looks for
or
tags first, strips all HTML, cleans whitespace, and truncates to 3,000 characters — enough content for OpenAI to work with without hitting context limits. 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. 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. 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. Prerequisites: n8n instance (self-hosted or cloud) OpenAI API key — platform.openai.com/api-keys Slack workspace + bot app — api.slack.com/apps Google account (for Sheets OAuth2) Your blog's RSS feed URL Setup steps: Import the workflow JSON into n8n (Workflows → Import from File) RSS Trigger node: Replace the example feed URL with your blog's RSS URL OpenAI node: Create a new credential → paste your API key Slack nodes: Create a new credential → paste your Slack Bot Token Google Sheets node: Create OAuth2 credential → authorize your Google account Activate the workflow Estimated setup time: 5 minutes. 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. 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. The free version handles Twitter + LinkedIn (2 platforms) with basic error handling. Get the free template on GitHub: / blog-to-social-ai-n8n Blog to Social Posts (AI) — Free n8n Workflow Template 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: RSS Feed Trigger detects new blog posts (polls every 30 minutes) Validates the incoming item (catches malformed RSS entries early) HTTP Request fetches the full article HTML Code node strips HTML and extracts clean article text (up to 3,000 chars) OpenAI GPT-4o-mini generates a Twitter thread (3-5 tweets) + LinkedIn post with hashtags Slack delivers both posts to your #content channel for review and copy-paste Cost: ~$0.001-0.003 per blog post in OpenAI API… View on GitHub Download the JSON file from the repo, import into n8n, add your credentials, and you're running. 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.