Reputation: 1
There is a database of people in ACT!, there are a lot of them (21k), when importing into HubSpot, the Activity pane doesn't populate.pic ACT!pic hubspot I'd be very happy if you could help with the code a little bit. Peace out
I tried exporting the base, it exports without Activity, I think I'll try via API to pull it out, and add Activity to Notes
`const fetch = require('node-fetch'); // Для Node.js
async function loadActivitiesFromAct() {
const actApiUrl = '';
const apiKey = '';
try {
const response = await fetch(`${actApiUrl}/activities`, {
headers: {
Authorization: `Bearer ${apiKey}`
}
});
if (response.ok) {
return await response.json();
} else {
console.error(`Failed to load activities from ACT! API: ${response.statusText}`);
return null;
}
} catch (error) {
console.error(`Error loading activities from ACT! API: ${error}`);
return null;
}
}
async function createNoteActivityInHubSpot(noteContent) {
const hubspotApiKey = '';
const hubspotApiUrl = '';
const data = {
engagement: {
active: true,
ownerId: 1,
type: 'NOTE'
},
associations: {
},
metadata: {
body: noteContent
}
};
try {
const response = await fetch(`${hubspotApiUrl}?hapikey=${hubspotApiKey}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
if (response.ok) {
console.log('Note activity created successfully in HubSpot!');
} else {
console.error(`Failed to create note activity in HubSpot: ${response.statusText}`);
}
} catch (error) {
console.error(`Error creating note activity in HubSpot: ${error}`);
}
}
async function importActivitiesFromActToHubSpot() {
const activities = await loadActivitiesFromAct();
if (activities) {
activities.forEach(activity => {
const noteContent = `Activity from ACT!:\n${JSON.stringify(activity)}`;
createNoteActivityInHubSpot(noteContent);
});
}
}
importActivitiesFromActToHubSpot();
`
Upvotes: 0
Views: 33