Skip to main content

Automate LinkedIn content using viral post analysis with Gemini AI & Flux image generation

Workflow preview

Workflow preview
100%
Automate LinkedIn content using viral post analysis with Gemini AI & Flux image generation preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

LinkedIn Viral Post Scraper + AI Content Generator with Auto Publishing Who's it for Content creators, social media managers, marketing agencies, and LinkedIn growth hackers who want to automate th...

Best for

  • Content Creation automation workflows
  • Multimodal AI automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.lmchatgooglegemini, n8n-nodes-base.scheduletrigger, n8n-nodes-base.googlesheets, n8n-nodes-base.splitinbatches, n8n-nodes-base.httprequest, n8n-nodes-base.wait, n8n-nodes-base.filter, n8n-nodes-base.googlesheetstrigger

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Roshan Ramani.

Original n8n.io source

1.1 Workflow description

Title
Automate LinkedIn content using viral post analysis with Gemini AI & Flux image generation
Workflow name
Automate LinkedIn content using viral post analysis with Gemini AI & Flux image generation

LinkedIn Viral Post Scraper + AI Content Generator with Auto Publishing

Who's it for

Content creators, social media managers, marketing agencies, and LinkedIn growth hackers who want to automate their content strategy by analyzing viral posts and generating original, high-engagement content at scale.

What it does

This comprehensive automation pipeline combines LinkedIn data intelligence with AI-powered content creation to build a complete content marketing system:

Data Collection Phase:

  • Automatically scrapes high-engagement posts from target LinkedIn profiles
  • Filters content based on viral metrics (20+ likes, comments, or reposts)
  • Stores trending content data in Google Sheets for analysis
  • Runs on a 12-hour schedule with built-in rate limiting

Content Generation Phase:

  • AI analyzes trending patterns and engagement triggers from collected data
  • Generates original LinkedIn posts using Google Gemini's advanced language model
  • Creates custom visuals using AI image generation (HuggingFace Flux model)
  • Automatically publishes complete posts with images to your LinkedIn company page
  • Tracks processed content to prevent duplicate analysis

How it works

The workflow operates in two connected phases. The scraping phase monitors specified LinkedIn profiles, collecting high-performing posts into a centralized database. When new viral content is detected, the AI analysis phase triggers automatically, identifying trending topics and creating original content that leverages proven engagement patterns while maintaining authenticity.

Requirements

APIs and Credentials:

  • Google Sheets API (for data storage and profile management)
  • Apify API key (for LinkedIn post scraping)
  • Google Gemini API access (for content generation)
  • HuggingFace API token (for image generation)
  • LinkedIn API access (for publishing)

Setup Prerequisites:

  • Google Sheets document with LinkedIn profile URLs
  • LinkedIn company page for publishing
  • Self-hosted n8n instance (uses community nodes)

How to set up

  1. Configure Data Sources: Create a Google Sheet with two tabs - one for target LinkedIn profile URLs and another for storing scraped data
  2. API Integration: Add all required API credentials to n8n credential manager
  3. Customize Filters: Adjust engagement thresholds (currently 20+ for each metric) based on your niche
  4. AI Prompt Tuning: Modify the content generation prompt to match your brand voice and industry focus
  5. Publishing Settings: Configure your LinkedIn organization ID and posting preferences
  6. Schedule Optimization: Set scraping frequency based on your content needs and API limits

How to customize the workflow

Content Targeting: Modify the profile list in Google Sheets to focus on specific industries, thought leaders, or competitors in your niche.

Engagement Thresholds: Adjust the filter conditions to be more or less selective about which posts qualify as "viral" content.

AI Voice Customization: Edit the comprehensive system prompt in the LinkedIn Content Strategy AI node to match your brand personality, industry terminology, and content style preferences.

Visual Branding: Customize image generation prompts to include your brand colors, logo elements, or specific visual styles.

Publishing Schedule: Modify the trigger frequency and add conditional logic to publish at optimal times for your audience.

Data Retention: Add cleanup nodes to manage historical data and prevent Google Sheets from becoming unwieldy over time.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Google Gemini Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1

Block 2 - LinkedIn Content Automation Scheduler

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.2

Block 3 - Fetch LinkedIn Profile URLs

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.5

Block 4 - Process Profiles in Batches

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 5 - Scrape LinkedIn Posts API

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 6 - Rate Limiting Delay

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Block 7 - Filter High-Engagement Posts

Type / Role
n8n-nodes-base.filter - filter
Config choices
Version 2.2

Block 8 - Save Viral Posts to Sheets

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.5

Block 9 - New Post Data Trigger

Type / Role
n8n-nodes-base.googleSheetsTrigger - googleSheetsTrigger
Config choices
Version 1

Block 10 - Filter Recent Posts (3 Days)

Type / Role
n8n-nodes-base.filter - filter
Config choices
Version 2.2

Block 11 - Aggregate Trending Content

Type / Role
n8n-nodes-base.aggregate - aggregate
Config choices
Version 1

Block 12 - LinkedIn Content Strategy AI

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 2.2

Block 13 - JSON Output Parser

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.3

Block 14 - Generate Post Image

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 15 - Download Generated Image

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 16 - Publish to LinkedIn

Type / Role
n8n-nodes-base.linkedIn - linkedIn
Config choices
Version 1

Block 17 - Extract Analyzed Post URLs

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 18 - Mark Posts as Analyzed

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.7

Block 19 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 20 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Automate LinkedIn content using viral post analysis with Gemini AI & Flux image generation
Complexity advanced
Nodes 20
Categories Content Creation, Multimodal AI
Author Roshan Ramani
Published 28 Aug 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/7973/7973.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Automate LinkedIn content using viral post analysis with Gemini AI & Flux image generation do?

LinkedIn Viral Post Scraper + AI Content Generator with Auto Publishing Who's it for Content creators, social media managers, marketing agencies, and LinkedIn growth hackers who want to automate th...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Content Creation, Multimodal AI use case.