1. Opening Problem Statement
Meet Sarah, a marketing manager at a mid-sized e-commerce company. Every morning, she spends around one hour manually checking which customers have updated their information in Mailchimp and then entering or updating their profiles in HubSpot. This repetitive task is tedious and prone to errors, causing inconsistencies in customer data. If a contact’s email or name is spelled wrong or missing, sales teams might follow up incorrectly, losing trust and potential sales.
If Sarah could automate this daily update, she could save hours every week and ensure her data is always accurate. That’s exactly what this n8n workflow accomplishes, by automatically syncing changed Mailchimp members to HubSpot contacts at 7 AM daily.
2. What This Automation Does
This workflow activates every day at precisely 7:00 in the morning. When triggered, it:
- Fetches the timestamp of the last successful execution to know the last sync time.
- Retrieves all Mailchimp members changed since that last sync.
- For each updated or new member, creates or updates the corresponding contact in HubSpot with first name, last name, and email address.
- Updates the last execution timestamp so the next run only processes new changes.
- Runs automatically without manual intervention, eliminating manual data entry and mistakes.
- Saves Sarah at least an hour each morning, improves data quality, and streamlines marketing and sales alignment.
3. Prerequisites ⚙️
- n8n account (cloud or self-hosted) 🔌
- Mailchimp account with API access and a subscriber list to sync from 💬
- HubSpot account with app token for API authentication 🔐
- Basic knowledge of how to create and run an n8n workflow
4. Step-by-Step Guide
Step 1: Set up the Cron Trigger to Run Daily at 07:00
In n8n, click + Add Node → choose Cron. Set the cron node parameters:
- Trigger Times → Item → Add an item → Set hour = 7, leave other fields default.
You should see the node named Every day at 07:00. This node triggers the workflow daily at 7 AM.
Common mistake: Not setting the correct timezone or hour leads to unexpected run times.
Step 2: Create a Function Item Node to Retrieve the Last Execution Timestamp
Add a new Function Item node called Get last execution timestamp. Paste this code into the function code field:
const staticData = getWorkflowStaticData('global');
if(!staticData.lastExecution){
staticData.lastExecution = new Date();
}
item.executionTimeStamp = new Date();
item.lastExecution = staticData.lastExecution;
return item;This code stores and retrieves the last execution date globally for the workflow. Running this node sets the current item’s executionTimeStamp as now, and the lastExecution as the last run date.
Common mistake: Forgetting to return item will break data flow.
Step 3: Retrieve Changed Mailchimp Members Since Last Execution
Add the Mailchimp node and name it Get changed members. Configure as follows:
- Operation: Get All
- List: Select your Mailchimp list ID (e.g.,
bcfb6ff8f1) - Options → Since Last Changed: Use expression
{{$json["lastExecution"]}}to fetch members changed since the last sync.
Connect the output of Get last execution timestamp to this node.
This node fetches Mailchimp members whose data has changed since the last sync time.
Common mistake: Using a static date instead of dynamic expression results in repeated data or missed updates.
Step 4: Create or Update HubSpot Contacts
Add the HubSpot node named Create/Update contact and configure:
- Resource: Contact
- Authentication: App Token (enter or select your HubSpot app token credential)
- Email:
{{ $json["email_address"] }} - Additional Fields:
- First Name:
{{ $json["merge_fields"].FNAME }} - Last Name:
{{ $json["merge_fields"].LNAME }}
Connect the output of the Mailchimp node to this one.
This node ensures for every changed Mailchimp member, their HubSpot contact is created or updated accordingly.
Common mistake: Not mapping the correct fields from Mailchimp JSON causes missing data in HubSpot.
Step 5: Update the Last Execution Timestamp
Add another Function Item node named Set new last execution timestamp and paste this code:
const staticData = getWorkflowStaticData('global');
staticData.lastExecution = $item(0).$node["Get last execution timestamp"].executionTimeStamp;
return item;Set this node to Execute Once in node settings. Connect the output of the HubSpot node to this node.
This updates the stored last execution time so the next run only fetches changes since now.
Common mistake: Forgetting to set execute once or mis-referencing the node execution timestamp.
5. Customizations ✏️
- Change Sync Time: In the Cron node “Every day at 07:00”, adjust the hour parameter to any preferred sync time.
- Add More Fields to HubSpot Contact: In the HubSpot node, expand “Additional Fields” and map more Mailchimp member fields like phone number or address if needed.
- Filter Mailchimp Members: Modify the Mailchimp node with additional filters for status such as only syncing subscribed members, or those in specific segments.
6. Troubleshooting 🔧
Problem: “No new members fetched in Mailchimp node.”
Cause: The sinceLastChanged parameter is set to a timestamp later than the last actual member changes.
Solution: Check the stored last execution timestamp in the Function Item node. Manually reset it to a past date if needed to test syncing.
Problem: “HubSpot API authentication error.”
Cause: Incorrect or expired HubSpot app token.
Solution: Go to the HubSpot developer portal, generate a new app token, and update node credentials.
7. Pre-Production Checklist ✅
- Verify Mailchimp API credentials and list ID.
- Ensure HubSpot app token credentials are correct and valid.
- Run the workflow manually once with test data to verify connections and data flow.
- Check logs for any error messages or failed node executions.
- Confirm the last execution timestamp updates after successful run.
8. Deployment Guide
Activate the workflow by toggling the Active switch in n8n editor. The workflow will now run daily at 7 AM automatically.
Monitor execution via the n8n Executions panel. Failures will show detailed error messages to debug.
Regularly check the contact data in HubSpot and Mailchimp to ensure syncing accuracy.
9. FAQs
Q: Can I sync data from other Mailchimp lists?
A: Yes, just change the list ID in the Mailchimp node configuration to your desired list.
Q: Will this workflow use a lot of API credits?
A: It fetches only changed members since last run, so API usage is minimal.
Q: Is data secure during syncing?
A: Yes, all API calls are authenticated, and no data is stored outside n8n’s environment permanently.
10. Conclusion
In this tutorial, you learned how to automate syncing updated Mailchimp members to HubSpot contacts every morning using n8n. Sarah’s tedious manual updates are now replaced by a reliable automated process that saves her about an hour each day and ensures marketing and sales have clean, up-to-date contact data.
Next, consider expanding this workflow to handle contact deletions, or integrate notifications to Slack when new contacts appear. Keep automating to reclaim your time and reduce errors!