Select Page

Introduction

At Growth Automation Services, we specialize in automating business processes to drive growth, efficiency, and productivity. One common challenge businesses face is migrating customer data from one CRM system to another—like Salesforce to HubSpot. In this article, we’ll provide you with a comprehensive guide on how to migrate your data, specifically notes and files, from Salesforce to HubSpot using Python.

Prerequisites

Before you get started, you will need the following:

  • Salesforce Account: Access to your Salesforce CRM with administrative privileges.
  • HubSpot Account: An active HubSpot account.
  • Python Environment: Python 3.x installed.
  • API Keys: API keys for Salesforce and HubSpot. You can find out how to get your HubSpot API key in this article and all the information you will need for Salesforce here.

Required Python Libraries

You’ll need to install the following Python libraries:

  • simple_salesforce for Salesforce API interaction
  • hubspot-api-client for HubSpot API interaction

You can install these libraries using pip:

PY

pip install simple_salesforce
pip install hubspot-api-client

Code Walkthrough

Step 1: Export Data from Salesforce

Initialize Salesforce API Connection

First, you’ll need to authenticate and establish a connection with the Salesforce API.

PY

from simple_salesforce import Salesforce
sf = Salesforce(username=’my_username’, password=’my_password’, security_token=’my_token’)

Fetch Contacts & Notes

Now, fetch the records you need to migrate. In our example, we focus on contacts and notes.

PY

contacts = sf.query(“SELECT Id, Name, … FROM Contact”)
notes = sf.query(“SELECT Id, Body, ParentId FROM Note WHERE ParentId IN …”)

Step 2: Transform Data as Necessary

This step involves converting your Salesforce data into a format that HubSpot can accept. For this example, we’ll assume that minimal transformation is needed.

Step 3: Import Data into HubSpot

Initialize HubSpot API Connection

Just like with Salesforce, the first step is to initialize the API connection with HubSpot.

PY

from hubspot import HubSpot
api_client = HubSpot(api_key=’my_api_key’)

Upload Contacts

After establishing the connection, you can proceed to upload your contacts.

PY

for contact in contacts[‘records’]:
       api_client.crm.contacts.basic_api.create(
            simple_public_object_input={
                 “properties”: {
                      “firstname”: contact[‘FirstName’],
                      “lastname”: contact[‘LastName’],
                  }
            }
     )

Upload Notes as Engagements

HubSpot refers to notes as “engagements,” and you can upload them using the Engagements API

PY

for note in notes[‘records’]:
      api_client.crm.engagements.basic_api.create(
            engagement_creation_request={
                  “engagement”: {
                        “type”: “note”,
                        “body”: note[‘Body’],
                   },
                  “associations”: {
                         “contactIds”: [note[‘ParentId’]],
                    }
          }

Step 4: Link Notes & Files to Contacts

In some cases, you may need to programmatically associate each note and file with the corresponding contact or account in HubSpot.

Conclusion

Data migration can be complex, but it’s crucial for the growth and efficiency of your business. With the right tools and expertise, this process can be automated, saving you both time and money. At Growth Automation Services, we excel in automating such processes, ensuring seamless Salesforce to HubSpot integrations.

For more help or consultation on your data migration needs, feel free to contact us.

We hope this guide serves as a useful resource for your Salesforce to HubSpot migration needs. It’s not just about transferring data; it’s about setting the foundation for scalable, automated growth.