1. Opening Problem Statement
Meet Sarah, a busy marketing manager running multiple outbound campaigns using Lemlist every week. She spends hours each day manually checking which leads replied to her emails, trying to quickly understand if they’re interested, want to unsubscribe, or just out of office. Misclassifying replies led to wasted follow-ups and frustrated prospects. Sarah lost valuable time sifting through raw emails to find actionable insights, often missing important messages embedded in long replies.
This tedious work cost Sarah an extra 5 hours of manual review weekly and slowed down campaign responsiveness, impacting lead conversion rates. With hundreds of leads replying daily, Sarah needed a smarter, automated way to process incoming Lemlist replies, categorize them quickly, and alert her team effectively.
2. What This Automation Does
This n8n workflow connects directly to Lemlist, detects each new email reply to your campaigns, cleans up the reply text, categorizes the reply using OpenAI’s GPT-4 model, and sends a neatly formatted alert to a Slack channel. Depending on the reply category, it can automatically unsubscribe leads or mark them as interested within Lemlist.
- Detects new replies from Lemlist campaigns in real time.
- Cleans and formats reply text for easy reading.
- Uses OpenAI to categorize replies into Interested, Unsubscribe, Out of office, Not interested, or Other.
- Sends structured Slack notifications with campaign and lead details.
- Automatically unsubscribes leads who reply “Unsubscribe” to save manual effort.
- Marks interested leads in Lemlist for targeted follow-up.
This workflow saves marketing teams hours each week, reduces errors in lead handling, and boosts campaign efficiency through intelligent automation.
3. Prerequisites ⚙️
- n8n Account: An active n8n automation platform account to build and run this workflow.
- Lemlist Account: Access to run campaigns and get API credentials for integration.
- Slack Account: Connected to your workspace where notifications will be sent.
- OpenAI API Access: API key with permission to use GPT-4 or similar model via n8n.
- Basic familiarity with n8n workflow editor is helpful but not mandatory.
4. Step-by-Step Guide
Step 1: Start with Lemlist Trigger on New Reply
Navigate to the n8n editor. Click + Add Node → Search for Lemlist Trigger. Select the event emailsReplied and set the option to trigger only on the first reply (“isFirst” = true). This ensures the workflow activates immediately on new replies from your Lemlist campaigns.
Expected outcome: The node listens for new email replies in real-time from Lemlist campaigns.
Common mistake: Forgetting to set the webhook ID or activating the webhook in Lemlist settings.
Step 2: Format Reply Text with Markdown Node
Add a Markdown node next. Map its html parameter to =${json.text} which passes the raw reply email content. This node cleans and converts the email text into user-friendly, readable Markdown.
Visual check: You should see the textClean field populated with formatted text after the node runs.
Why this matters: Clean replies make downstream processing and Slack alerts much clearer.
Step 3: Categorize Reply Using OpenAI Chat Model
Add the OpenAI Chat Model node. Select GPT-4 (“gpt-4o”) as the model. Next, add the Structured Output Parser node configured with a simple JSON schema to parse the category output.
Link the OpenAI node’s output to the output parser to extract a structured classification, e.g., {"category":"Interested"}.
Prompt example used: The workflow sends the cleaned reply text with instructions to classify into categories like Interested, Out of office, Unsubscribe.
Step 4: Merge Cleaned Text and Classification Data
Use a Merge node in combine mode by position. Merge output from the Markdown node (cleaned text) with OpenAI classification output. This unified data stream simplifies routing further processing.
Step 5: Route Replies to Specific Branches Using Switch Node
Add a Switch node that checks the category classification and routes the reply to one or more branches:
- Unsubscribe: triggers Lemlist node to unsubscribe the lead.
- Interested: calls a HTTP Request node to mark lead interested in Lemlist.
- Others: go to Slack notification.
Set conditions exactly as the workflow does by matching the category string.
Step 6: Automatically Unsubscribe Leads
Add a Lemlist node with operation set to unsubscribe lead. Map the email and campaign ID from the data. This automates list cleaning by unsubscribing leads who reply “Unsubscribe”.
Step 7: Mark Interested Leads
Add an HTTP Request node configured to call Lemlist’s API endpoint to mark a lead as interested. Use POST method with endpoint https://api.lemlist.com/api/campaigns/. Add proper authentication credentials linked to Lemlist API key.
Step 8: Send Alerts to Slack Channel
Use the Slack node to send a structured message block to a configured Slack channel. Customize the message with campaign details, sender and lead emails, LinkedIn URL, categorized reply status, and a snippet preview of the reply text (up to 100 characters).
This gives your sales or marketing team instant visibility on new replies categorized for quick action.
5. Customizations ✏️
- Change Slack Channel: Open the Slack node and update the
channelIdvalue to any Slack channel name you prefer. - Add More Reply Categories: Modify the prompt in the “Categorize lemlist reply” node to add new categories such as “Follow-up” or “Support” and update the switch node rules accordingly.
- Include Additional Fields in Slack: Customize the Slack message JSON to add more details like lead phone number or company name if that data is available from Lemlist.
- Switch to Different OpenAI Model: Change the model parameter in the OpenAI Chat Model node from “gpt-4o” to other available GPT versions depending on accuracy or cost preferences.
- Adjust Reply Preview Length: In the Slack node, modify the substring length in the message blocks from 100 characters to a longer or shorter preview as needed.
6. Troubleshooting 🔧
Problem: “No new replies triggering workflow”
Cause: Webhook not activated or incorrect webhook URL in Lemlist trigger.
Solution: Go to Lemlist Trigger node, verify the webhook ID is activated in Lemlist settings under integrations. Test with a fresh reply to trigger.
Problem: “OpenAI node returns empty or invalid category”
Cause: Prompt issues or API access limits.
Solution: Check API key validity, review prompt text carefully, and verify the Structured Output Parser schema matches the output format exactly.
Problem: “Slack alert missing data or formatting broken”
Cause: Incorrect JSON structure or missing fields from upstream data.
Solution: Use the workflow execution debug mode to check the JSON passed to Slack node. Correct field paths and JSON formatting.
7. Pre-Production Checklist ✅
- Test Lemlist trigger with a real campaign reply
- Validate OpenAI classification with sample replies for accuracy
- Ensure Slack messages look correct in target channel
- Verify automation unsubscribes leads only when category is “Unsubscribe”
- Backup n8n workflow JSON file before deployment
- Check the merge and switch nodes properly route data
8. Deployment Guide
Activate the Lemlist Trigger node webhook by making sure it’s enabled on both n8n and Lemlist integration. Turn the workflow “Active” in n8n and monitor the first few replies for correct Slack alerts and lead status updates. Set up logging within n8n for troubleshooting any failures. Periodically review reply classifications for improvements and adjust the OpenAI prompt or categories if needed.
9. FAQs
Can I use a different messaging platform than Slack?
Currently the workflow uses Slack node for notifications, but you could replace this with Microsoft Teams or Discord nodes with some JSON adjustments.
Does this workflow consume a lot of OpenAI API credits?
The classification step sends relatively short email snippets. Usage depends on volume but typically low for small to medium campaigns.
Is the lead data secured?
All data passes securely via API and within your n8n instance. Ensure credentials are stored safely and n8n access is protected.
10. Conclusion
By following this detailed guide, you’ve built a powerful automation that detects and classifies Lemlist email replies using OpenAI and sends actionable alerts to Slack. This cuts down manual review time by hours weekly, improves lead response accuracy, and automates tedious unsubscribe management.
Next steps: explore adding calendar booking integration for “Interested” leads or exporting replies to a CRM for even deeper follow-up automation. Keep innovating to save more time and convert more leads with intelligent workflows!
Happy automating! 🔑