1. Opening Problem Statement
Meet Lucas, a busy sales manager who handles hundreds of email leads coming through Lemlist campaigns every day. Manually sifting through each replied email to determine the lead’s interest, updating their HubSpot CRM records, and informing his sales team wastes hours daily. Often, leads who express interest fall through the cracks, or out-of-office replies delay timely follow-ups. This confusion leads to lost deals, missed opportunities, and a stressed-out sales team struggling to keep up.
Lucas estimates spending at least 3 hours per day processing these replies manually, causing delays and errors that cost potential revenue. He knows there has to be a better way to automate this tedious process while maintaining personalized follow-ups and accurate CRM updates.
2. What This Automation Does
When this n8n workflow runs, it intelligently categorizes incoming email replies from Lemlist leads using OpenAI, then takes the correct next steps in HubSpot CRM and notifies the sales team on Slack accordingly. Specifically, it:
- Catches Lemlist email replies through a webhook trigger.
- Uses OpenAI to classify responses into categories like “Interested,” “Out of Office,” “Unsubscribe,” or “Other.”
- Unsubscribes leads in Lemlist automatically if they choose to opt-out.
- Marks leads as “Interested” in Lemlist and creates a new deal in HubSpot CRM.
- Adds follow-up tasks within HubSpot for out-of-office replies.
- Sends customized Slack notifications about the lead’s status to the sales team.
This automation saves Lucas hours every day, eliminates manual entry errors, prioritizes the hottest leads instantly, and ensures no opportunity slips through the cracks.
3. Prerequisites ⚙️
- n8n account with access to create workflows 🔌
- Lemlist account with API access and an active campaign 🔑
- HubSpot account with OAuth2 API credentials 🔑
- Slack workspace with OAuth2 API credentials 🔑
- OpenAI API key to categorize email texts 🔑
4. Step-by-Step Guide
Step 1: Set Up the Lemlist Lead Replied Trigger
Navigate to your n8n editor, click + New Workflow. Add the node Lemlist Trigger (type: n8n-nodes-base.lemlistTrigger), select event emailsReplied and set isFirst to true. This triggers the workflow whenever a lead replies to your campaign email.
You should see n8n displaying Webhook URL generated—note this URL to configure in your Lemlist campaign settings.
Common mistake: Forgetting to add this webhook URL in Lemlist leads to no data triggering the workflow.
Step 2: Add OpenAI Node to Categorize Replies
Add an OpenAI node (n8n-nodes-base.openAi) connected from Lemlist Trigger. Use the following prompt template:
=The following is a list of emails and the categories they fall into:
Categories=["interested", "Out of office", "unsubscribe", "other"]
Interested is when the reply is positive.
{{$json["text"].replaceAll(/^s+|s+$/g, '').replace(/(rn|n|r)/gm, "")}}
Category:This instructs OpenAI to read the email reply content and classify it. Choose temperature 0 and max tokens 6 for precise results.
Expected result: Outputs category as a string, e.g., “Interested” or “Out of office.”
Common mistake: Using overly broad prompts can confuse classification.
Step 3: Merge Data for Processing
Add a Merge node (n8n-nodes-base.merge) which combines the original data from the trigger with the OpenAI classification output. Configure it to combine by position and prefer input 1 in case of conflicts.
Outcome: Single data-set including the email reply and its categorized label.
Step 4: Add Switch Node for Conditional Logic Based on Reply
Insert a Switch node (n8n-nodes-base.switch). Configure rules as follows on property text (trimmed string):
- If value is “Unsubscribe,” output to branch 0.
- If value is “Interested,” output to branch 1.
- If value is “Out of Office,” output to branch 2.
- Else fallback to branch 3.
This splits execution path according to the lead’s reply category.
Step 5: Handle Unsubscribe Leads in Lemlist
On branch 0 from the Switch, connect to Lemlist – Unsubscribe node (n8n-nodes-base.lemlist), configured for unsubscribe operation on lead email and campaign ID from JSON data.
Outcome: The lead is unsubscribed from your campaign immediately upon reply.
Common mistake: Not passing correct campaign ID leads to unsubscribe failure.
Step 6: Handle Interested Leads to Mark and Create Deal
From branch 1, connect to two nodes in parallel:
- Lemlist Mark as Interested – An HTTP Request node (
n8n-nodes-base.httpRequest) calling Lemlist’s API to mark the lead email as interested in the campaign. - HubSpot – Get contact ID – Retrieve contact details by lead email.
Then, connect HubSpot Get contact ID node to HubSpot – Create Deal node (n8n-nodes-base.hubspot) which creates a new deal associated with that contact. Lastly, connect the created deal to a Slack notification node (n8n-nodes-base.slack) informing your team with a link to the deal.
Expected outcome: Hot leads are marked, deals created instantly, and teams notified.
Common mistake: Forgetting to authenticate HubSpot OAuth2 properly causes failures.
Step 7: Handle Out of Office Leads with Follow-up Tasks
From branch 2, connect to HubSpot – Get contact ID1 node (same HubSpot contact retrieval), which then triggers follow up task node (n8n-nodes-base.hubspot) to create a task in HubSpot engagement to remind you to follow up once available.
Outcome: Out of office messages automatically schedule a follow-up task—no lead falls off your radar.
Step 8: Send Generic Slack Notifications for Other Replies
The fallback branch 3 leads to Slack1 node (n8n-nodes-base.slack), which sends a Slack message about other types of replies, with links to Lemlist campaign reports.
5. Customizations ✏️
- Change Campaign or Team: In Lemlist – Unsubscribe or HTTP Request nodes, update
campaignIdorteamIdto target different campaigns. - Adjust AI Categories: Modify the OpenAI prompt to add more categories or refine classification.
- Add More Slack Channels: Duplicate Slack nodes and configure for different sales teams or notification priorities.
- Customize HubSpot Engagements: Change the task details or deal stages in HubSpot nodes to match your sales pipeline.
- Extend with CRM Updates: Add other HubSpot nodes to update contact properties based on replies.
6. Troubleshooting 🔧
- Problem: “Workflow not triggered by Lemlist replies”
Cause: Webhook URL not set in Lemlist campaign settings.
Solution: Copy webhook URL from Lemlist Trigger node and paste it in Lemlist’s webhook settings precisely. - Problem: “OpenAI classification returns wrong categories”
Cause: Prompt wording too ambiguous.
Solution: Simplify the prompt and add clear examples as in the provided workflow. - Problem: “HubSpot nodes fail authentication”
Cause: OAuth2 credentials expired or insufficient scopes.
Solution: Reauthorize OAuth2 or check permission scopes in HubSpot developer portal. - Problem: “Lead unsubscribe fails”
Cause: Incorrect campaign ID passed.
Solution: Verify campaign ID in Lemlist unsubscribe node configuration.
7. Pre-Production Checklist ✅
- Verify Lemlist webhook is active and receiving reply events.
- Test OpenAI node with sample email replies to confirm accurate categorization.
- Ensure HubSpot OAuth2 credentials are valid and have necessary permissions.
- Verify Slack notification posts successfully in desired channel.
- Test unsubscribe functionality with a test lead in Lemlist campaign.
- Conduct end-to-end test from lead reply to Slack notification confirming deal creation or task scheduling.
8. Deployment Guide
Once tested, activate your workflow in n8n by toggling the active switch in the top right. Monitor the first few lead replies through the Executions tab to ensure smooth operations.
Enable error notifications in n8n to catch any failures early, and review logs regularly. This workflow scales well for medium sales teams and can be extended or adapted to other CRMs or messaging platforms.
9. FAQs
- Can I use Pipedrive or Salesforce instead of HubSpot? Yes, but you will need to replace HubSpot nodes with respective CRM API nodes and adapt authentication.
- Does this consume a lot of OpenAI credits? Each email classification uses minimal tokens—cost is low, but monitor your API usage.
- Is my data safe while using hubspot and Lemlist APIs? Yes, OAuth2 authentication and standard API security practices apply.
- Can this handle thousands of leads daily? n8n workflows can scale with proper resource allocation and webhook throughput.
10. Conclusion
By following this guide, you have automated your entire lead reply handling pipeline — from catching Lemlist replies, using AI to categorize them, updating HubSpot CRM, and notifying your sales team on Slack.
This saves several hours daily, reduces human error, and ensures every lead gets a timely, appropriate response. You can now focus your energy on closing deals rather than managing data.
Next, consider adding automated follow-ups for “Interested” leads, integration with Google Sheets for reporting, or enriching leads with data from LinkedIn.
You’ve just boosted your sales productivity dramatically. Great job! 🎉