Back to Templates

Automate LinkedIn Engagement with GPT-4o Sentiment Analysis & Smart Comments

Created by

Created by: Punit || punitkumar

Punit

Last update

Last update 14 hours ago

Categories

Share


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