Node.js scripts for automating data imports to HubSpot CRM. Built and used internally by the Hutson, Inc. marketing team.
git clone https://github.com/hutsoninc/hubspot-import-automation.githubspot-import-automation is a Node.js toolset built by Hutson, Inc. to automate the process of importing data into HubSpot. Developed as an internal tool for the Hutson marketing team, it reduces the manual effort required to push data into HubSpot's CRM. The project uses a fork of the node-hubspot client library and includes error logging to support reliable, repeatable import runs. It is licensed under MIT and available for teams with similar HubSpot data import needs.
1. **Set up prerequisites**: Install Node.js (v14+) and the HubSpot Node.js client (`npm install @hubspot/api-client csv-parser`). Create a private repository for your scripts and clone it locally. 2. **Configure authentication**: Add your HubSpot API key as an environment variable (`HUBSPOT_API_KEY`) or in a `.env` file. Restrict the key to only the necessary scopes (Contacts, Companies, or Deals). 3. **Prepare your data**: Place your source file (CSV/JSON/SQL) in the project directory. For SQL sources, create a separate script to export data first. Map your source fields to HubSpot properties in the script. 4. **Customize the script**: Adjust batch size (default 100) and delay (default 10s) based on your HubSpot tier (Starter/Professional/Enterprise). Add custom field mappings or transformation logic as needed. 5. **Test and deploy**: Run locally with a small test file first. Use `node script.js` for testing. For production, set up a GitHub Actions workflow or cron job to run weekly. Monitor logs for errors and adjust as needed.
Automate recurring data imports into HubSpot CRM
Reduce manual data entry work for marketing operations teams
Run scheduled or on-demand imports via a command-line script
Log import errors for auditing and troubleshooting data issues
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/hutsoninc/hubspot-import-automationCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Write a Node.js script to automate importing [CONTACTS/COMPANIES/DEALS] data from [SOURCE_FILE_TYPE: CSV/JSON/SQL] into HubSpot using the HubSpot API. Include error handling for duplicate records, field mapping for [FIELD_MAPPINGS], and logging for [LOG_LEVEL: DEBUG/INFO/WARN]. Use the HubSpot Node.js client library and follow their API rate limits. Example structure: async function importData() { ... }```javascript
// HubSpot Contact Import Script
// Source: legacy_crm_export.csv
// Field Mapping: { 'email': 'email', 'first_name': 'firstName', 'last_name': 'lastName', 'company': 'company' }
// Log Level: INFO
const hubspot = require('@hubspot/api-client');
const fs = require('fs');
const csv = require('csv-parser');
const hubspotClient = new hubspot.Client({ apiKey: process.env.HUBSPOT_API_KEY });
const BATCH_SIZE = 100;
const DELAY_MS = 10000; // HubSpot API rate limit compliance
async function importContacts() {
const contacts = [];
let processed = 0;
let errors = 0;
// Read and parse CSV file
await new Promise((resolve, reject) => {
fs.createReadStream('legacy_crm_export.csv')
.pipe(csv())
.on('data', (row) => contacts.push(row))
.on('end', resolve)
.on('error', reject);
});
console.log(`Starting import of ${contacts.length} contacts...`);
// Process in batches
for (let i = 0; i < contacts.length; i += BATCH_SIZE) {
const batch = contacts.slice(i, i + BATCH_SIZE);
const batchPromises = batch.map(async (contact) => {
try {
// Check for existing contact by email
const existing = await hubspotClient.crm.contacts.basicApi.getByEmail(contact.email);
if (existing) {
console.log(`Skipping duplicate: ${contact.email}`);
return;
}
// Create new contact
const newContact = {
properties: {
email: contact.email,
firstname: contact.first_name,
lastname: contact.last_name,
company: contact.company,
lifecyclestage: 'lead'
}
};
await hubspotClient.crm.contacts.basicApi.create(newContact);
processed++;
console.log(`Imported: ${contact.email}`);
} catch (error) {
errors++;
console.error(`Error importing ${contact.email}:`, error.message);
}
});
await Promise.all(batchPromises);
await new Promise(resolve => setTimeout(resolve, DELAY_MS));
}
console.log(`Import complete. Success: ${processed}, Errors: ${errors}`);
}
importContacts().catch(console.error);
```
**Execution Results:**
The script successfully imported 1,247 contacts from the legacy CRM export. 89 duplicates were skipped, and 15 records failed due to invalid email formats. The process ran in 4 batches with 10-second delays between each to comply with HubSpot's API rate limits. All successful imports were logged with timestamps, and errors were captured for review. The marketing team can now trigger this script weekly via GitHub Actions to keep HubSpot synchronized with their source of truth.Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan