Skip to main content

Automate LinkedIn engagement with GPT-4o sentiment analysis & smart comments

Workflow preview

Workflow preview
100%
Automate LinkedIn engagement with GPT-4o sentiment analysis & smart comments 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 Auto Engagement AI Agent Automatically find, analyze, and engage with relevant LinkedIn posts using AI powered sentiment analysis and comment generation Template Overview This workflow ...

Best for

  • Social Media automation workflows
  • AI Chatbot automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.httprequest, n8n-nodes-base.code, @n8n/n8n-nodes-langchain.chainllm, n8n-nodes-base.if, @n8n/n8n-nodes-langchain.lmchatopenrouter, @n8n/n8n-nodes-langchain.outputparserstructured, @n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.sentimentanalysis

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Automate LinkedIn engagement with GPT-4o sentiment analysis & smart comments
Workflow name
Automate LinkedIn engagement with GPT-4o sentiment analysis & smart comments

LinkedIn Auto-Engagement AI Agent

Automatically find, analyze, and engage with relevant LinkedIn posts using AI-powered sentiment analysis and comment generation

πŸ“‹ Template Overview

This workflow automates LinkedIn engagement by searching for relevant posts, analyzing their sentiment, generating contextual comments using AI, and posting them automatically. Perfect for DevOps professionals, cloud architects, and automation enthusiasts who want to maintain an active LinkedIn presence without spending hours manually commenting.

🎯 What This Workflow Does

  1. Searches LinkedIn for posts from the last 24 hours based on your chosen keywords (Kubernetes, Azure, AWS, AI, Automation, SaaS, n8n)
  2. Filters quality content - Only engages with posts over 350 characters that are original (not reposts)
  3. Analyzes sentiment using AI to categorize posts into 7 types:
    • Informational/Educational Content
    • Happy Announcement
    • Sad/Negative Feelings
    • Hiring Posts
    • Not English Language
    • Neutral
    • None of the Above
  4. Generates contextual comments using AI that are witty, professional, and add genuine value
  5. Posts comments and adds reactions to the LinkedIn posts
  6. Logs everything to Google Sheets for tracking and analysis
  7. Sends Telegram notifications when the workflow completes

πŸ”§ Prerequisites

Before you can use this workflow, you'll need:

Required Accounts & Credentials

  1. n8n Account (Cloud or Self-hosted)
  2. Unipile Account - For LinkedIn API access
  3. OpenRouter Account - For AI capabilities
    • Sign up at: https://openrouter.ai
    • Get your API key
    • Recommended model: openai/gpt-4o-mini (cost-effective)
  4. Google Account - For Google Sheets logging
  5. Telegram Account - For notifications (optional but recommended)

Technical Requirements

  • Basic understanding of n8n workflows
  • Ability to create and manage Google Sheets
  • Ability to create a Telegram bot (5 minutes, step-by-step below)

πŸ“¦ Setup Instructions

Step 1: Import the Workflow

  1. Copy the workflow JSON
  2. In n8n, click + Add workflow
  3. Click the three dots (...) in the top right
  4. Select Import from File or Import from URL
  5. Paste the JSON

Step 2: Set Up Google Sheets

  1. Create a new Google Sheet with these exact column headers in Row 1:

    Post URL Post Content Name of Author Author's Profile Headline Profile URL of Author ID Sentiment of Post Comment Generated by AI Error
  2. Name the sheet tab: "Open - New n Random Niche Posts Comment"

  3. Share the sheet with your Google account connected to n8n

  4. Copy the Sheet ID from the URL (between /d/ and /edit)

Step 3: Configure Google Sheets Nodes

Update the Sheet ID in these 4 nodes:

  • Append row in sheet2
  • Update row in sheet9
  • Update row in sheet10
  • Update row in sheet11

For each node:

  1. Click the node
  2. Find the Document field
  3. Either select your sheet from the dropdown OR paste your Sheet ID
  4. Click the Refresh icon to load columns
  5. Save

Step 4: Set Up Unipile (LinkedIn API)

  1. Sign up at Unipile: https://unipile.com
  2. Connect your LinkedIn account in the Unipile dashboard
  3. Get your Account ID and API Key
  4. Update these nodes with your credentials:
    • LinkedIn Search
    • Get Post from LinkedIn2
    • Comment On Post2
    • Leave Reaction on Post2

For each node:

  • Find the X-API-KEY header parameter
  • Paste your Unipile API key
  • Find the account_id parameter
  • Paste your Unipile account ID

Step 5: Set Up OpenRouter (AI)

  1. Sign up at OpenRouter: https://openrouter.ai
  2. Get your API key from the dashboard
  3. Add credits to your account ($5-10 is plenty to start)
  4. Configure these nodes:
    • OpenRouter Chat Model6
    • OpenRouter Chat Model7
    • OpenRouter Chat Model8

For each node:

  1. Click the node
  2. Click Credentials dropdown
  3. Select Create New
  4. Paste your OpenRouter API key
  5. Save

Step 6: Set Up Telegram Notifications (Optional)

  1. Create a Telegram Bot:

    • Open Telegram and search for @BotFather
    • Send /newbot
    • Choose a name (e.g., "LinkedIn Bot")
    • Choose a username (must end in 'bot')
    • Save the API Token BotFather gives you
  2. Get Your Chat ID:

    • Start a chat with your bot
    • Send any message
    • Visit: https://api.telegram.org/botYOUR_TOKEN/getUpdates
    • Find your Chat ID in the JSON response
  3. Configure the Telegram Node:

    • Open Send a text message2 node
    • Add your Bot Token in credentials
    • Replace the chatId with your Chat ID

Step 7: Customize Keywords (Optional)

Want to search for different topics? Update the LinkedIn Search URL:

Current keywords: Kubernetes, Azure, n8n, AWS, AI, Automation, SaaS

To change:

  1. Open LinkedIn Search node
  2. Find the url parameter under Body Parameters
  3. Modify the keywords= section

Example for DevOps tools:

keywords=%22Terraform%22%20OR%20%22Docker%22%20OR%20%22Kubernetes%22%20OR%20%22Jenkins%22

Step 8: Test the Workflow

  1. Click Execute Workflow (or use Manual Trigger)
  2. Watch each node execute
  3. Check for any errors (red nodes)
  4. Verify data appears in your Google Sheet
  5. Check your Telegram for the completion message

🎨 Customization Options

Modify AI Comment Style

Edit the AI Agent2 node prompt to change comment style:

You're an expert on [YOUR EXPERTISE].

Look at this post and drop in a thoughtful comment - {{ $json['Post Content'] }}

Guidelines:
- Write like a [YOUR STYLE]
- [YOUR RULES]
- Maximum 2 sentences

Only export the response and nothing else.

Change Sentiment Categories

Edit the Sentiment Analysis2 node to add/remove categories based on your needs.

Adjust Filtering Criteria

Modify the If2 node to change:

  • Minimum character count (currently 350)
  • Post type filters
  • Date range filters

Schedule Automation

Add a Schedule Trigger node to run automatically:

  • Recommended: 2-3 times per day (morning, afternoon, evening)
  • Avoid running too frequently to prevent spam detection

πŸ“Š Workflow Nodes Explained

Core Processing Flow

  1. LinkedIn Search - Fetches posts from LinkedIn via Unipile API
  2. Code4 - Parses the API response into individual posts
  3. Code5 - Filters posts to last 24 hours only
  4. Basic LLM Chain2 - Counts characters in each post
  5. If2 - Filters posts (350+ chars, original content only)
  6. Append row in sheet2 - Logs qualifying posts to Google Sheets
  7. Loop Over Items4 - Processes each post one by one

Analysis & Generation

  1. Sentiment Analysis2 - AI categorizes post sentiment
  2. AI Agent2 - Generates contextual comment
  3. Get Post from LinkedIn2 - Fetches fresh post data
  4. Comment On Post2 - Posts the AI-generated comment
  5. Leave Reaction on Post2 - Adds a like to the post

Logging & Notifications

  1. Update row in sheet9/10/11 - Updates Google Sheet with results
  2. Wait nodes - Adds delays to avoid rate limiting
  3. Send a text message2 - Telegram notification on completion

βš™οΈ Advanced Features

Rate Limiting

The workflow includes 1-minute wait times between actions to avoid LinkedIn's spam detection. You can adjust these in the Wait nodes.

Error Handling

  • Failed comments are logged in the "Error" column
  • Retry logic built into update nodes (5 retries, 5-second intervals)
  • Errors don't stop the workflow from processing other posts

Multi-Niche Support

To engage with multiple niches:

  1. Duplicate the LinkedIn Search node
  2. Change keywords in each duplicate
  3. Add a Merge node to combine results
  4. Connect to the rest of the workflow

πŸš€ Usage Tips

Best Practices

  • Start slow: Run manually 2-3 times to ensure everything works
  • Monitor results: Check your Google Sheet daily
  • Refine prompts: Adjust AI prompts based on comment quality
  • Vary timing: Schedule runs at different times of day
  • Stay authentic: Review and approve comments if needed

What to Avoid

  • ❌ Running too frequently (max 3-4 times per day)
  • ❌ Using generic keywords that return spam
  • ❌ Commenting on your own posts
  • ❌ Using the same comment style repeatedly
  • ❌ Engaging with low-quality content

LinkedIn Best Practices

  • Focus on adding genuine value
  • Engage with diverse content (not just one niche)
  • Avoid hashtags in comments
  • Keep comments concise (2 sentences max)
  • Build relationships, not just visibility

πŸ“ˆ Performance & Costs

Expected Results

  • Posts found: 20-100 per run (depending on keywords)
  • Posts filtered: 10-30 qualifying posts
  • Comments posted: 5-15 per run (after sentiment filtering)
  • Time saved: 1-2 hours of manual engagement per day

API Costs (Approximate)

  • Unipile: ~$29/month for LinkedIn API access
  • OpenRouter: Free
  • n8n: Free (self-hosted)Subscript
  • Google Sheets: Free
  • Telegram: Free

Total estimated cost: $30-50/month for full automation

πŸ› Troubleshooting

Common Issues

Issue: "Column names were updated" error

  • Solution: Refresh columns in Google Sheets nodes

Issue: LinkedIn API returns 403 error

  • Solution: Check Unipile account status and API limits

Issue: AI comments are generic or low quality

  • Solution: Refine the AI Agent2 prompt with more specific guidelines

Issue: No posts found

  • Solution: Check keyword relevance and time range settings

Issue: Workflow hangs on Loop Over Items

  • Solution: Check wait times and ensure all nodes are properly connected

Getting Help

πŸ” Security & Privacy

Data Protection

  • All LinkedIn credentials are handled by Unipile (OAuth)
  • API keys are stored securely in n8n credentials
  • Google Sheets data is private to your account
  • No third-party data sharing

Compliance

  • Respects LinkedIn's rate limits
  • Follows LinkedIn's Terms of Service
  • Only engages with public posts
  • No scraping of private data

Ethical Use

This workflow is designed for: βœ… Authentic professional networking βœ… Adding value to discussions βœ… Saving time on routine engagement

Please avoid: ❌ Spamming or aggressive self-promotion ❌ Misleading or deceptive comments ❌ Violating LinkedIn's community guidelines

πŸ“ Changelog & Updates

Version 1.0 (Current)

  • Initial release
  • Core functionality: search, filter, analyze, comment
  • Google Sheets logging
  • Telegram notifications
  • Multi-keyword support

Planned Features

  • Multi-account support
  • Advanced scheduling options
  • Comment approval workflow
  • Analytics dashboard
  • A/B testing for comment styles

πŸ‘¨β€πŸ’» About the Creator

This workflow was created to solve the challenge of maintaining consistent LinkedIn engagement while focusing on actual work. After spending too many hours manually commenting, I built this automation to handle the repetitive parts while keeping comments authentic and valuable.

πŸ“„ License

This workflow template is free to use and modify for personal and commercial purposes. Attribution is appreciated but not required.

🀝 Contributing

Found a bug? Have an improvement idea?

Feel free to:

  • Share your modifications
  • Report issues in the n8n community
  • Suggest new features
  • Create your own variations

πŸ™ Acknowledgments

Built with:

  • n8n - The workflow automation platform
  • Unipile - LinkedIn API integration
  • OpenRouter - AI model access
  • Google Sheets - Data logging
  • Telegram - Notifications

Ready to automate your LinkedIn engagement? Import this workflow and start building your professional network on autopilot!

Last updated: October 2025

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 - Search LinkedIn Posts

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

Block 2 - Extract Posts from Results

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

Block 3 - Filter Recent Posts

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

Block 4 - Count Post Characters

Type / Role
@n8n/n8n-nodes-langchain.chainLlm - chainLlm
Config choices
Version 1.7

Block 5 - Filter Long Non-Reposts

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

Block 6 - Character Count LLM Model

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

Block 7 - Parse Character Count

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

Block 8 - Generate AI Comment

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

Block 9 - Analyze Post Sentiment

Type / Role
@n8n/n8n-nodes-langchain.sentimentAnalysis - sentimentAnalysis
Config choices
Version 1.1

Block 10 - Add Reaction to Post

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

Block 11 - Process Posts in Batches

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

Block 12 - Log Post to Sheet

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

Block 13 - Update Sentiment Results

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

Block 14 - Update Comment Results

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

Block 15 - Post AI Comment

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

Block 16 - Log Error Results

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

Block 17 - Wait Before Next Action

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

Block 18 - Wait Before Error Logging

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

Block 19 - Sentiment Analysis LLM Model

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

Block 20 - Comment Generation LLM Model

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

Block 21 - Send Completion Notification

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

Block 22 - Get Post Details

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

Block 23 - Manual Workflow Trigger

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

Block 24 - Sticky Note

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

Showing the first 24 of 29 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Automate LinkedIn engagement with GPT-4o sentiment analysis & smart comments
Complexity advanced
Nodes 29
Categories Social Media, AI Chatbot
Author Punit
Published 08 Oct 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/9385/9385.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 engagement with GPT-4o sentiment analysis & smart comments do?

LinkedIn Auto Engagement AI Agent Automatically find, analyze, and engage with relevant LinkedIn posts using AI powered sentiment analysis and comment generation Template Overview This workflow ...

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 Social Media, AI Chatbot use case.