DEV Community

AgoraIntelligence
AgoraIntelligence

Posted on

One Piece of Content, Four Platforms, One Webhook Call — Content Repurposing with n8n and GPT-4o-mini

One Piece of Content, Four Platforms, One Webhook Call — Content Repurposing with n8n and GPT-4o-mini

The biggest bottleneck in content marketing isn't ideas. It's adaptation.

You write a good LinkedIn post. Then you need to turn it into a Twitter thread. Then a Telegram message for your channel. Then a newsletter intro. Each platform has different tone, format, and length requirements. By the time you've adapted the same idea four times, you've spent an hour on distribution instead of creation.

This workflow collapses that hour into a single webhook call.

What It Does

Send a topic or article URL to an n8n webhook. Get back:

  • LinkedIn post — professional tone, 150-300 words, hook + insight + CTA
  • Twitter/X thread — 3 tweets, punchy, ready to paste
  • Telegram message — casual, with emojis, for your channel
  • Newsletter intro — subject line + opening paragraph, 100-150 words

LinkedIn and Telegram publish automatically. Twitter and newsletter content are returned ready-to-paste (X API requires a paid subscription — we skip that dependency).

Optionally: a DALL-E 3 image matching the content, 1024x1024.

Everything gets logged to Google Sheets.

Why One Webhook Call

The naive approach uses four separate OpenAI calls — one per platform. This costs 4× more tokens and introduces 4× more failure points.

The better approach: one structured JSON output call that returns all four variants simultaneously.

const prompt = `
You are a content strategist. Generate platform-optimized content for this topic.

Topic: ${topic}
Brand voice: ${CONFIG.brand_voice}
Language: ${CONFIG.language}
Industry: ${CONFIG.industry}

Return a JSON object with exactly these keys:
{
  "linkedin": "full LinkedIn post text",
  "twitter_thread": ["tweet 1", "tweet 2", "tweet 3"],
  "telegram": "Telegram message with emojis",
  "newsletter_subject": "Email subject line",
  "newsletter_intro": "Opening paragraph for newsletter"
}

Rules:
- LinkedIn: professional, add 3 relevant hashtags at the end
- Twitter: each tweet max 280 chars, thread format with numbering
- Telegram: conversational, 2-4 emojis, max 300 chars
- Newsletter: subject under 50 chars, intro under 150 words
`;
Enter fullscreen mode Exit fullscreen mode

With response_format: { type: "json_object" } in the API call, you get clean structured output every time — no regex parsing, no format failures.

Workflow Architecture

Webhook (POST) → Parse input (topic/URL)
  → [Optional] Fetch URL → Extract article text
  → Code: Build structured prompt
  → OpenAI: Generate all 4 variants (JSON mode)
  → [Optional] DALL-E 3: Generate image
  → Parallel branches:
      → LinkedIn: Publish post via API
      → Telegram: Send via bot
      → Sheets: Log everything
  → Respond: Return JSON with all content + publish URLs
Enter fullscreen mode Exit fullscreen mode

The parallel branches mean LinkedIn and Telegram publish simultaneously — no sequential wait.

Triggering It

The webhook accepts a simple POST:

curl -X POST https://your-n8n.com/webhook/repurpose \
  -H "Content-Type: application/json" \
  -d '{
    "topic": "Why most automation projects fail in the first 90 days",
    "url": null,
    "generate_image": false
  }'
Enter fullscreen mode Exit fullscreen mode

Or with an article URL to repurpose:

curl -X POST https://your-n8n.com/webhook/repurpose \
  -H "Content-Type: application/json" \
  -d '{
    "topic": null,
    "url": "https://example.com/article-to-repurpose",
    "generate_image": true
  }'
Enter fullscreen mode Exit fullscreen mode

Response includes all generated content plus publication status:

{
  "linkedin": "The #1 reason automation projects fail...",
  "twitter_thread": ["1/ Most companies start automating the wrong things...", "2/..."],
  "telegram": "🤖 Hot take: most automation projects die in month 2...",
  "newsletter_subject": "Why your automation will fail",
  "newsletter_intro": "Last quarter we analyzed...",
  "image_url": "https://oaidalleapiprodscus.blob.core.windows.net/...",
  "linkedin_post_id": "urn:li:share:123456",
  "telegram_message_id": 42,
  "logged_at": "2026-07-26T14:32:00Z"
}
Enter fullscreen mode Exit fullscreen mode

The CONFIG Node

const CONFIG = {
  openai_credential: "your-openai-credential-id",

  // LinkedIn
  linkedin_access_token: "YOUR_LINKEDIN_TOKEN",
  linkedin_person_urn: "urn:li:person:YOUR_ID",

  // Telegram
  telegram_token: "YOUR_BOT_TOKEN",
  telegram_chat_id: "@yourchannel",

  // Google Sheets
  sheet_id: "YOUR_SPREADSHEET_ID",
  gcp_credential: "your-service-account-credential-id",

  // Content settings
  brand_voice: "professional but direct, no corporate jargon",
  language: "English",
  industry: "B2B SaaS / automation",
  default_hashtags: ["#automation", "#n8n", "#AI"],

  // Image generation (costs ~$0.04 per image with DALL-E 3)
  generate_images_by_default: false
};
Enter fullscreen mode Exit fullscreen mode

LinkedIn API Setup

LinkedIn's API requires OAuth with w_member_social scope. The flow:

  1. Create a LinkedIn App at linkedin.com/developers
  2. Add w_member_social and r_liteprofile permissions
  3. Generate an access token (valid 60 days — set a reminder to refresh)
  4. Get your Person URN: GET https://api.linkedin.com/v2/userinfo

Publishing a post:

POST https://api.linkedin.com/v2/ugcPosts
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json

{
  "author": "urn:li:person:YOUR_ID",
  "lifecycleState": "PUBLISHED",
  "specificContent": {
    "com.linkedin.ugc.ShareContent": {
      "shareCommentary": { "text": "{{linkedin_content}}" },
      "shareMediaCategory": "NONE"
    }
  },
  "visibility": { "com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC" }
}
Enter fullscreen mode Exit fullscreen mode

LinkedIn token expiry gotcha: tokens expire after 60 days. Either implement the OAuth refresh flow in n8n (complex) or set a calendar reminder to regenerate it. Most people do the calendar reminder.

Cost Per Run

Component Cost
GPT-4o-mini (all 4 variants) ~$0.003
DALL-E 3 image (optional) ~$0.040
n8n execution $0 (self-hosted)
Total without image ~$0.003
Total with image ~$0.043

At $0.003 per run, you'd need 333 daily repurposing runs to spend $1/day. For most content creators publishing 1-3 times per day, the monthly cost is under $0.30.

What This Is Good For (and What It Isn't)

Good for:

  • Repurposing blog posts and articles across channels
  • Consistent weekly content without the copy-paste grind
  • Teams where one person creates and others distribute

Not good for:

  • Content requiring deep research or original reporting
  • Platforms requiring native video/carousel formats
  • Situations where brand voice is extremely specific — AI needs calibration time

The quality improves dramatically when you fill in the brand_voice and industry fields with specifics. "Professional B2B SaaS company that sells to CTOs, writes like Paul Graham, no buzzwords" produces noticeably better output than "professional."

Get the Workflow

The complete 14-node workflow is available at n8nmarkets.com. Search "Social Media Content Repurposer".

Includes: workflow JSON, Sheets logging template, LinkedIn OAuth setup guide, and curl commands to test every branch before connecting real social accounts.


What's your current content distribution process? Curious whether people are using schedulers like Buffer/Hootsuite alongside this kind of automation, or replacing them entirely.

Top comments (0)