Automated LinkedIn Content Generation using AI and Viral Post Analysis - n8n Workflow

Use this powerful n8n workflow to analyze viral LinkedIn posts with Gemini AI, generate custom images, and automatically publish high-performing content. Discover more n8n templates.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Social Media Managers and Content Strategists looking to scale LinkedIn presence.

  • Marketing agencies needing efficient ways to generate high-volume, trend-based content.

  • Automation enthusiasts seeking advanced examples of integrated AI agents within an n8n workflow.

  • Users looking for sophisticated n8n templates involving scheduling, scraping, and publishing.

Overview

Maintaining a strong presence on LinkedIn requires consistent, high-quality content based on current trends. This sophisticated n8n workflow solves the problem of manual content research and creation by automating the entire cycle.

It operates in two phases: first, a scheduled component scrapes target profiles to identify viral posts and saves them to a Google Sheet database. Second, a trigger monitors that sheet, feeding the top-performing content into a custom LangChain AI Agent (powered by Google Gemini). This n8n node analyzes the viral content's structure, tone, and topic, generates a unique image prompt, generates the image via API, and then publishes the complete, trend-optimized post directly to LinkedIn. This advanced n8n workflow leverages the full power of automation to ensure your content is always fresh, relevant, and engaging.

How it Works

This powerful n8n workflow operates in two distinct, linked segments:

Phase 1: Viral Content Discovery


  1. Scheduling: The LinkedIn Content Automation Scheduler (an n8n trigger) starts the scraping process daily or weekly.

  2. Profile Fetching: The workflow fetches a list of target LinkedIn profile URLs from Google Sheets using an n8n node.

  3. Batch Processing: The Process Profiles in Batches n8n node manages the flow, ensuring that profile scraping occurs in manageable chunks to respect API limits.

  4. Scraping: The Scrape LinkedIn Posts API HTTP Request n8n node retrieves recent posts for each target profile.

  5. Rate Limiting: A Rate Limiting Delay n8n node introduces a crucial pause.

  6. Filtering: The Filter High-Engagement Posts n8n node isolates content that meets defined viral metrics (e.g., high likes, comments).

  7. Storage: The viral data is saved into a specific Google Sheets document using a Google Sheets n8n node, acting as the knowledge base for the AI.

Phase 2: AI Creation and Publishing


  1. Triggering: The New Post Data Trigger (a Google Sheets Trigger n8n trigger) instantly activates when new viral data is added.

  2. Preparation: Posts are filtered to include only the most recent data (via the Filter Recent Posts (3 Days) n8n node), and then aggregated for analysis.

  3. AI Analysis: The LinkedIn Content Strategy AI n8n node (a LangChain Agent), powered by the Google Gemini Chat Model, analyzes the aggregate trends and drafts a completely new LinkedIn post and an image generation prompt, ensuring the content is perfectly structured using the JSON Output Parser n8n node.

  4. Image Generation: An HTTP Request n8n node (Generate Post Image) sends the AI-generated prompt to a third-party image API (like Flux).

  5. Media Handling: A second HTTP Request n8n node (Download Generated Image) downloads the binary image data.

  6. Publishing: The Publish to LinkedIn n8n node posts the AI-generated text and the downloaded image to your company or personal profile.

  7. Cleanup: The workflow concludes by using a Code n8n node to extract post identifiers and then a Google Sheets n8n node to Mark Posts as Analyzed, preventing the n8n workflow from reprocessing old data.

Installation Guide

To deploy this comprehensive n8n workflow using one of our available n8n templates, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON and paste it into your n8n canvas using the 'New' -> 'Import from JSON' option.

  2. Google Sheets Setup: You will need two Google Sheet credentials. Configure the Sheets n8n node used for 'Fetch LinkedIn Profile URLs' and 'Save Viral Posts to Sheets' with the necessary Sheet IDs and API access. Crucially, the 'New Post Data Trigger' n8n trigger requires setting up a webhook listener to detect sheet changes in real-time.

  3. AI Credentials: Configure the Google Gemini Chat Model n8n node with your required API key and select the appropriate model.

  4. LinkedIn Credentials: Set up the connection for the 'Publish to LinkedIn' n8n node with the required OAuth credentials to grant publishing access.

  5. Scraping/Image APIs: Configure the HTTP Request n8n nodes (Scrape LinkedIn Posts API, Generate Post Image, Download Generated Image) with the appropriate API keys, endpoints, and headers for your chosen scraping and image generation services.

  6. Activation: Once all credentials are set up for every n8n node, ensure both the scheduler and the Google Sheets n8n trigger are activated.

Node Details

LinkedIn Content Automation Scheduler (n8n trigger): This is the initial n8n trigger, configured to run on a set schedule (e.g., once per day) to initiate the viral content discovery phase.
Fetch LinkedIn Profile URLs (Google Sheets n8n node): Retrieves the list of competitor or target profiles that the n8n workflow will scrape.
Scrape LinkedIn Posts API (HTTP Request n8n node): Executes the actual scraping operation. Key configuration involves setting the target API endpoint and passing the LinkedIn profile URLs from the previous n8n node.
Rate Limiting Delay (Wait n8n node): Essential for respecting external API limitations. Configured with a specific delay time to space out requests.
New Post Data Trigger (Google Sheets Trigger n8n trigger): The primary n8n trigger for the content generation segment. It waits for new rows (viral posts) to be added to the Google Sheet.
Google Gemini Chat Model (LangChain n8n node): Provides the large language model backend for the AI agent, supplying the context and intelligence needed to analyze trends.
LinkedIn Content Strategy AI (LangChain Agent n8n node): This core n8n node contains the prompt and logic for analyzing the aggregated viral posts and generating the content strategy, including the text and image instructions.
Generate Post Image (HTTP Request n8n node): This n8n node sends the AI-generated image prompt to the external DALL-E or Flux API to create the media file.


  • Publish to LinkedIn (LinkedIn n8n node): The final action n8n node, configured to publish the complete item (text and image) to the linked LinkedIn account. It requires appropriate authentication setup.

Related n8n Workflows

Paid

Nodes: 14 Nodes
Updated: December 26 2025
View all
Created by

I love building smart n8n automations that actually work reliably. My focus is on making everyday tasks like email, social media, and CRM workflows simpler using AI. I've shared templates in the n8n community, including a WhatsApp Expense Tracker that people really enjoy. What keeps me excited is constantly trying new things - testing fresh nodes, playing with AI tools like LangChain, and discovering creative ways to connect systems!

Featured*