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
- Searches LinkedIn for posts from the last 24 hours based on your chosen keywords (Kubernetes, Azure, AWS, AI, Automation, SaaS, n8n)
- Filters quality content - Only engages with posts over 350 characters that are original (not reposts)
- 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
- Generates contextual comments using AI that are witty, professional, and add genuine value
- Posts comments and adds reactions to the LinkedIn posts
- Logs everything to Google Sheets for tracking and analysis
- Sends Telegram notifications when the workflow completes
🔧 Prerequisites
Before you can use this workflow, you'll need:
Required Accounts & Credentials
- n8n Account (Cloud or Self-hosted)
- Unipile Account - For LinkedIn API access
- OpenRouter Account - For AI capabilities
- Sign up at: https://openrouter.ai
- Get your API key
- Recommended model:
openai/gpt-4o-mini
(cost-effective)
- Google Account - For Google Sheets logging
- 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
- Copy the workflow JSON
- In n8n, click + Add workflow
- Click the three dots (...) in the top right
- Select Import from File or Import from URL
- Paste the JSON
Step 2: Set Up Google Sheets
-
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 |
-
Name the sheet tab: "Open - New n Random Niche Posts Comment"
-
Share the sheet with your Google account connected to n8n
-
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:
- Click the node
- Find the Document field
- Either select your sheet from the dropdown OR paste your Sheet ID
- Click the Refresh icon to load columns
- Save
Step 4: Set Up Unipile (LinkedIn API)
- Sign up at Unipile: https://unipile.com
- Connect your LinkedIn account in the Unipile dashboard
- Get your Account ID and API Key
- 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)
- Sign up at OpenRouter: https://openrouter.ai
- Get your API key from the dashboard
- Add credits to your account ($5-10 is plenty to start)
- Configure these nodes:
OpenRouter Chat Model6
OpenRouter Chat Model7
OpenRouter Chat Model8
For each node:
- Click the node
- Click Credentials dropdown
- Select Create New
- Paste your OpenRouter API key
- Save
Step 6: Set Up Telegram Notifications (Optional)
-
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
-
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
-
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:
- Open
LinkedIn Search
node
- Find the
url
parameter under Body Parameters
- 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
- Click Execute Workflow (or use Manual Trigger)
- Watch each node execute
- Check for any errors (red nodes)
- Verify data appears in your Google Sheet
- 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
- LinkedIn Search - Fetches posts from LinkedIn via Unipile API
- Code4 - Parses the API response into individual posts
- Code5 - Filters posts to last 24 hours only
- Basic LLM Chain2 - Counts characters in each post
- If2 - Filters posts (350+ chars, original content only)
- Append row in sheet2 - Logs qualifying posts to Google Sheets
- Loop Over Items4 - Processes each post one by one
Analysis & Generation
- Sentiment Analysis2 - AI categorizes post sentiment
- AI Agent2 - Generates contextual comment
- Get Post from LinkedIn2 - Fetches fresh post data
- Comment On Post2 - Posts the AI-generated comment
- Leave Reaction on Post2 - Adds a like to the post
Logging & Notifications
- Update row in sheet9/10/11 - Updates Google Sheet with results
- Wait nodes - Adds delays to avoid rate limiting
- 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:
- Duplicate the
LinkedIn Search
node
- Change keywords in each duplicate
- Add a
Merge
node to combine results
- 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