Case study · built and shipped

A Modular Viral Content Engine for LinkedIn & X with Human Approval

This project is a 156-node n8n engine that automates the full social media content lifecycle for LinkedIn and X across six modular sub-systems. It scrapes competitor profiles and viral posts via Apify, classifies ideas as evergreen, and saves them to Google Sheets. An LLM agent then writes brand-voiced posts — grounded by Perplexity web research — and generates matching images with Gemini, styled against a reference image. Each post is sent to Telegram for human approval, repurposed for X, and auto-published on schedule to both platforms with status tracking. A Telegram bot also lets the user generate posts from their own ideas on demand.

Six modular sub-systems
Brand-voiced, research-grounded generation
Human-in-the-loop via Telegram
The goal

Automate the full social content lifecycle — discover viral ideas, generate on-brand posts and images, approve, repurpose, and auto-publish.

Pain points & objectives
  • The whole content lifecycle is a weekly slog. Finding what's working in your niche, writing original on-brand posts, designing images, adapting them per platform, and publishing on schedule is a continuous, multi-hour-per-week grind.
  • Inspiration and ideation don't scale manually. Tracking competitor and inspiration accounts to spot genuinely viral, evergreen ideas — and filtering out personal noise — is tedious and easy to let slip.
  • Full automation feels risky, but full manual control is slow. Teams want hands-off generation and publishing yet still need a moment to approve or reject each post before it represents their brand publicly.
The build

The brief: automate 90% of the content lifecycle without losing the final say.

The client wanted an end-to-end engine that handles nearly everything between "what should I post?" and "it's live on LinkedIn and X" — discovering viral ideas in their niche, writing posts in their voice, generating matching imagery, repurposing across platforms, and publishing on a schedule — while keeping a human gate before anything goes public. We delivered this as a 156-node n8n workflow organised into six modular sub-systems, deliberately built so each piece can run as its own workflow and be triggered independently, by schedule or on demand via a Telegram bot.

System 1 — Initialization (optional). A setup routine scrapes LinkedIn competitor and inspiration profiles via Apify, filters to accounts whose posts clear a popularity bar (over 100 likes), and saves them to a "Competitors" Google Sheet — building the seed list the discovery engine learns from.

System 2 — Content Discovery. Weekly (a Saturday-night schedule trigger, or on demand), the engine reads those competitor URLs, scrapes their recent posts via Apify, filters for high engagement, and removes duplicates. A text classifier then sorts each post into "evergreen" niche content versus "personal/other," so only timeless, on-topic ideas are saved as "viral ideas" to a sheet. The user is notified on Telegram when the run completes.

System 3 — Post Generation. For each idea marked "Ready," an LLM agent acts as an expert LinkedIn writer working strictly within the brand's defined voice, audience, and "content buckets" (Automation Basics, Real Implementations, Case Studies, Future & Trends). It can call a web-research sub-workflow (Perplexity, with a lower-cost research provider as an alternative) to ground the post in current, verifiable information, then outputs a structured 200–300-word post plus a hook and an image description. That description drives image generation via Gemini's image model (or OpenAI image editing), styled against a reference image pulled from Google Drive for visual consistency. The finished post and image are sent to Telegram for human review before anything proceeds.

System 4 — Repurposing for X. Approved LinkedIn posts are automatically adapted for X — condensed to instant-value, sub-280-character posts or short threads — reusing the same generated image so branding stays consistent across platforms. Generated X content is appended to the sheet.

System 5 — Auto-Publishing. Separate schedule triggers publish validated content to each platform: LinkedIn in the early evening and X shortly after (using X's OAuth1 credential, with images uploaded via the dedicated media endpoint). The system only posts rows marked valid, updates each record's status in Google Sheets after publishing, and notifies the user on Telegram. Running X a beat behind LinkedIn is a built-in best practice.

System 6 — On-demand Telegram helper (SMS). A Telegram bot lets the user drive the engine manually using a structured command format — generating a post from their own idea, kicking off scraping, or running research on demand. It includes a user-ID guard (rejecting unauthorised senders) and input validation that politely flags malformed commands.

Why this design works. The six-system split is the key decision: by separating discovery, generation, repurposing, and publishing into independent workflows wired together with Execute Workflow calls, each stage can be tested, scheduled, and reused in isolation — and the same generation logic serves both automated ideas and the user's own. Google Sheets acts as the shared spine and status ledger across every system (competitors, ideas, posts, publishing status), Google Drive stores generated imagery, and Telegram provides both the approval gate and the manual control surface. The result automates roughly 90% of the content lifecycle while preserving a human checkpoint before any post represents the brand publicly — and it runs on self-hosted infrastructure, keeping credentials and content under the owner's control.

Pipeline stages
  1. Initialization (optional) — scrape LinkedIn competitor/inspiration profiles via Apify, filter by engagement, and save to a Competitors sheet.
  2. Content discovery — weekly, scrape competitors' posts, filter for high engagement, dedupe, and classify evergreen vs personal, saving viral ideas to a sheet.
  3. Post generation — for each "Ready" idea, an LLM agent (with Perplexity research) writes a brand-voiced LinkedIn post plus an image description.
  4. Image generation — create a matching image via Gemini's image model (or OpenAI), styled against a reference image from Google Drive.
  5. Human approval — send the post and image to Telegram for the user to approve or reject before proceeding.
  6. Repurpose for X — adapt approved posts into sub-280-character X content or threads, reusing the same image.
  7. Auto-publishing — scheduled triggers post validated content to LinkedIn and X, update status in Sheets, and notify the user.
  8. On-demand helper — a guarded Telegram bot lets the user trigger generation from their own ideas, scraping, or research.
Tools & platforms
  • n8n — workflow orchestration (156 nodes, six modular sub-workflows, self-hosted)
  • Apify — LinkedIn competitor-profile and viral-post scraping
  • DeepSeek & Google Gemini (via OpenRouter / direct) — post generation, classification, and repurposing LLMs
  • Perplexity — web research grounding (with a lower-cost research provider as an alternative)
  • Gemini image model / OpenAI image editing — AI image generation, styled against a reference image
  • n8n Text Classifier — evergreen vs personal content sorting
  • Google Sheets — shared data spine and status ledger (competitors, ideas, posts, publishing status)
  • Google Drive — generated-image storage and reference style image
  • Telegram — human-in-the-loop approval and on-demand command bot
  • LinkedIn API — automated LinkedIn publishing
  • X (Twitter) API — automated tweet/thread publishing (OAuth1) with media upload
  • Schedule Triggers — weekly discovery and daily publishing cadences
Want one of these?

Got a workflow no one’s been able to build?

A free 20-minute call. Bring the messy, ambitious, “is this even possible” version, and I’ll tell you if it’s buildable and roughly how.