Sync Deal URL from another URL to custom field in HubSpot
SOLVE
We are currently using both ActiveCampaign (HIPAA compliant) and HubSpot (not HIPAA compliant) and would like to migrate the bulk of our sales activities to HubSpot. The contingency there is that we can't story personal health information in HS so we we'd like to keep it in the notes section of the deal in AC. This means A we need parody for deals in both CRMS (easy enough) but also B we need a way to sync the deal URL from AC into the custom property in HS so sales can just quickly click it, open the deal, and put in notes.
You have several options to tackle this challenge. The first one, which I would recommend due to HIPAA compliance, is to acquire OperationsHub Professional if you haven't already.
With OperationsHub Professional, you can create a workflow that runs on a daily basis. Within this workflow, a custom code block can include tokens for both ActiveCampaign and HubSpot. The code block can start by checking in ActiveCampaign if a particular deal already exists. If the deal doesn’t exist, it can be created in HubSpot as a new deal, and the URL of the object in ActiveCampaign can be added to a custom property in the HubSpot deal.
If the deal already exists, no creation will be made. Of course, you can add further logic to this workflow to update relevant data from ActiveCampaign to the HubSpot deal, if necessary.
Additionally, I would advise conducting an initial import/export of these deals before activating the integration, to ensure data consistency and ease the transition between the two systems.
The second option is to create a similar solution using Zapier, Integromat, or another third-party integration provider. However, it's my assessment that these solutions may not be approved due to HIPAA compliance requirements.
Here's a simplified POC code conforming to the HubSpot Custom Code structure:
exports.main = async (event) => {
// Assume acAPI and hsAPI are the endpoints for ActiveCampaign and HubSpot
const activeCampaignAPI = process.env.acAPI;
const hubSpotAPI = process.env.hsAPI;
// Assume dealInfo is obtained from somewhere in your workflow
const dealInfo = event.inputFields['hs_record_id'];
// Function to check if deal exists in ActiveCampaign
async function checkDealInAC(dealId) {
try {
const response = await fetch(`${activeCampaignAPI}/deals/${dealId}`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${process.env.acToken}`
}
});
const data = await response.json();
return data && data.deal;
} catch (error) {
console.error('Error checking deal in AC:', error);
return false;
}
}
// Function to create deal in HubSpot
async function createDealInHS(dealInfo) {
try {
const response = await fetch(`${hubSpotAPI}/deals`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.hsToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(dealInfo)
});
const data = await response.json();
return data && data.deal;
} catch (error) {
console.error('Error creating deal in HS:', error);
return null;
}
}
// Function to update deal in HubSpot
async function updateCustomPropertyInHS(dealId, acUrl) {
try {
const response = await fetch(`${hubSpotAPI}/deals/${dealId}`, {
method: 'PATCH',
headers: {
'Authorization': `Bearer ${process.env.hsToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
properties: {
'activeCampaignDealUrl': acUrl
}
})
});
return response.ok;
} catch (error) {
console.error('Error updating custom property in HS:', error);
return false;
}
}
// Main workflow logic
async function mainWorkflow() {
const dealExists = await checkDealInAC(dealInfo.id);
if (!dealExists) {
const newDeal = await createDealInHS(dealInfo);
if (newDeal) {
await updateCustomPropertyInHS(newDeal.id, dealInfo.url);
}
}
}
// Run the main workflow and output any results
await mainWorkflow();
}
// Mac@mcb.dk
You have several options to tackle this challenge. The first one, which I would recommend due to HIPAA compliance, is to acquire OperationsHub Professional if you haven't already.
With OperationsHub Professional, you can create a workflow that runs on a daily basis. Within this workflow, a custom code block can include tokens for both ActiveCampaign and HubSpot. The code block can start by checking in ActiveCampaign if a particular deal already exists. If the deal doesn’t exist, it can be created in HubSpot as a new deal, and the URL of the object in ActiveCampaign can be added to a custom property in the HubSpot deal.
If the deal already exists, no creation will be made. Of course, you can add further logic to this workflow to update relevant data from ActiveCampaign to the HubSpot deal, if necessary.
Additionally, I would advise conducting an initial import/export of these deals before activating the integration, to ensure data consistency and ease the transition between the two systems.
The second option is to create a similar solution using Zapier, Integromat, or another third-party integration provider. However, it's my assessment that these solutions may not be approved due to HIPAA compliance requirements.
Here's a simplified POC code conforming to the HubSpot Custom Code structure:
exports.main = async (event) => {
// Assume acAPI and hsAPI are the endpoints for ActiveCampaign and HubSpot
const activeCampaignAPI = process.env.acAPI;
const hubSpotAPI = process.env.hsAPI;
// Assume dealInfo is obtained from somewhere in your workflow
const dealInfo = event.inputFields['hs_record_id'];
// Function to check if deal exists in ActiveCampaign
async function checkDealInAC(dealId) {
try {
const response = await fetch(`${activeCampaignAPI}/deals/${dealId}`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${process.env.acToken}`
}
});
const data = await response.json();
return data && data.deal;
} catch (error) {
console.error('Error checking deal in AC:', error);
return false;
}
}
// Function to create deal in HubSpot
async function createDealInHS(dealInfo) {
try {
const response = await fetch(`${hubSpotAPI}/deals`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.hsToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(dealInfo)
});
const data = await response.json();
return data && data.deal;
} catch (error) {
console.error('Error creating deal in HS:', error);
return null;
}
}
// Function to update deal in HubSpot
async function updateCustomPropertyInHS(dealId, acUrl) {
try {
const response = await fetch(`${hubSpotAPI}/deals/${dealId}`, {
method: 'PATCH',
headers: {
'Authorization': `Bearer ${process.env.hsToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
properties: {
'activeCampaignDealUrl': acUrl
}
})
});
return response.ok;
} catch (error) {
console.error('Error updating custom property in HS:', error);
return false;
}
}
// Main workflow logic
async function mainWorkflow() {
const dealExists = await checkDealInAC(dealInfo.id);
if (!dealExists) {
const newDeal = await createDealInHS(dealInfo);
if (newDeal) {
await updateCustomPropertyInHS(newDeal.id, dealInfo.url);
}
}
}
// Run the main workflow and output any results
await mainWorkflow();
}
// Mac@mcb.dk
Should you have any further questions or need more assistance, feel free to reach out in this thread. I wish you the best of luck with the implementation and your transition to HubSpot.