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

78 views · 📱 Social Media & Email Marketing

💡 Pro Tip — If you’re pulling LinkedIn data through HTTP requests or dealing with API restrictions, there’s a community node called ScraperNode that handles this natively. It has dedicated scrapers for profiles, companies, jobs, and people search — you just pass a URL and get structured data back.

View All Scrapers

Description

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

📦 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 URLPost ContentName of AuthorAuthor’s Profile HeadlineProfile URL of AuthorIDSentiment of PostComment Generated by AIError
  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:

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:

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:

Schedule Automation

Add a Schedule Trigger node to run automatically:

📊 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

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

What to Avoid

LinkedIn Best Practices

📈 Performance & Costs

Expected Results

API Costs (Approximate)

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

🐛 Troubleshooting

Common Issues

Issue: “Column names were updated” error

Issue: LinkedIn API returns 403 error

Issue: AI comments are generic or low quality

Issue: No posts found

Issue: Workflow hangs on Loop Over Items

Getting Help

🔐 Security & Privacy

Data Protection

Compliance

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)

Planned Features

👨‍💻 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:

🙏 Acknowledgments

Built with:


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

Last updated: October 2025

🔗 Nodes Used

Google Sheets, HTTP Request, Telegram, AI Agent, Basic LLM Chain, Structured Output Parser

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup