HubSpot-Salesforce Bidirectional Sync using MuleSoft Composer

Sandeep Singh
Another Integration Blog
8 min readSep 6, 2023

Introduction

MuleSoft Composer (Composer) makes it easy to build process automation for data, using clicks instead of code. When you create a secure process to connect the information stored in different systems, you build a real-time, integrated view of your customers and your business.

To automate processes with Composer, you build a flow that contains every step in the process:

Selecting the data that you specify from a system such as Google Sheets, HubSpot, Workday, or a Salesforce org

Performing actions on the data, such as syncing it to another system

You choose when to trigger the flow: when something happens, like a change to a record or row, or at intervals of time that you specify. Flows can be as simple or complex as your business needs.

Use Case

In this Blog, we see one of the use cases of MuleSoft Composer, which is Integration Between HubSpot and Salesforce.

What Is Salesforce?

Salesforce is the most sophisticated CRM, It holds the top spot in the industry. With a consolidated perspective of all of your groups, it aids in the growth of your organization. It provides a flexible, adaptable solution for businesses, with speedier deployment, ensuring a higher return on investment for your company. It provides a single point of truth for all departments, including sales, services, and marketing, along with specialized knowledge.

What Is HubSpot?

Additionally, HubSpot offers cloud-based CRM software. However, it includes apps for the Sales Hub, Service Hub, and CMS Hub. It will grow your scaling business in an improved manner, with a variety of tools and integrations.

Let’s get started:

First of all, we will need HubSpot and Salesforce accounts for the integration.

Creating a trial account in HubSpot and creating a Private app within it involves several steps. Here’s a step-by-step procedure to guide you through the process:

Step 1: Go to HubSpot Website

- Open your web browser and navigate to the HubSpot website: https://www.hubspot.com/

Step 2: Sign Up for a Trial Account

- On the HubSpot homepage, click on the “Get HubSpot Free” button.

Step 3: Complete Sign-Up Form

- Fill out the sign-up form with your email address, company name, and other required information.

Step 4: Set Up Your Account

- Follow the prompts to set up your trial account. You may need to provide additional information about your company and marketing needs.

Step 5: Access Your HubSpot Dashboard

- Once your account is set up, you will be redirected to your HubSpot dashboard.

Step 7: Go to the Developer Dashboard

- In your HubSpot dashboard, click on your profile picture in the top right corner, and then select “Profile & Preferences.”

Step 8: Navigate to “Private Apps” — In the Integrations section, click on “Private Apps” in the left-hand menu.

Step 9: Click on the “Create App” button to create a new private app.

Step 10: Fill Out Private App Details

- In the Basic Info, provide the following details:

- Name: Give your app a name.

- Description: Provide a brief description of your app’s purpose (optional).

.

Step 11: Now Click on the Scopes Tab as shown in the picture. Under the “Scopes” section, select the scopes (permissions) required for your app to access HubSpot’s APIs. These permissions will determine what data your app can access. Since you have created a trial account, you can provide all the read and write scopes. Checkbox all the scopes (CRM scopes mandatory).

Step 12: Once you’ve filled out the required details and scopes, click the “Create app” button in the top right corner to save your private app.

Step 13: Now it will show a prompt as shown in the below picture. Click on “Continue creating”.

Step 14: Your Private App is successfully created. Copy the access token and store it securely as it will be used to connect to the private app.
You can also find this access token on the Private Apps home page.

For Salesforce, we need to create a developer account and have to create another user. So that we can achieve bidirectional sync.

Step 1: Go to the Salesforce Developer Website

- Open your web browser and navigate to the Salesforce Developer website: https://developer.salesforce.com/signup

Step 2: Complete Sign-Up Form

- Fill out the form and click on the Submit button.
Note: The username should be unique and it should be in email ID format(e.g. abc@test.com)

Step 3: Verify Your Email

- Salesforce will send you a verification email to the email address you provided. Click on the verification link in the email to confirm your account by creating a password

Step 4: Use the URL mentioned in the email while Login with username and password

- In my case it is https://apisero329-dev-ed.develop.my.salesforce.com/

- Now the Developer Account is created and we’ll proceed with creating a user.

Step 5: Click on Home

- Under the Administration section click on Users.

Step 6: Click On New Users

  • Fill all the fields and assign Profiles so that the user can create the records. Note: I have assigned System Administrator(in the trial account we can create only one user as System Administrator. If you want to create another user then you can uncheck the Active checkbox and create a new user).

Step 7: Click Save

  • After Saving the entry. Click on Reset Password(this will notify the user to access your salesforce account only after they reset the password.)

Step 8: Create Custom fields and External ID

Use Case 1: HubSpot-Salesforce Flow Design

Step 1: Add a trigger condition i.e. On a New or updated record in HubSpot(fetch any created/updated record) as below
Step 2: Select Record Type (in our case it is “Contact”)

Step 3: Select the fields that you want to be synced

Step 4: Now add an Action condition i.e. Create or update the record in Salesforce and add the object name in Object Type

Step 5: Select the External ID field to match and do field mappings according to the business needs

Example: In the below snapshot Street Address field of HubSpot is mapped to the Address field of Salesforce

Step 6: Add a condition to check if the record creation/modification is successful or not.

Step 7: If yes, add an action condition i.e. Update Record in HubSpot (to update Salesforce Record ID back to HubSpot) else perform operation according to your business needs (here we are terminating the flow)

Use Case 2: Salesforce-HubSpot Flow Design

Step 1: Add a trigger condition i.e. On a New or updated record in Salesforce(fetch any created/updated record) as below
Step 2: Select Object Type (in our case it is “ Custom Contact”)

Note: This process is a Bi-directional sync, records can be created/modified from both the end systems. So, to avoid infinite looping we are excluding the records that are modified by the Salesforce user assigned to the HubSpot-Salesforce sync process (Use Case 1).

Step 3: Add a filter condition i.e. Exclude the records modified by the user assigned for Use Case 1 (refer to the below snapshot)

Step 4: Select the fields that you want to be synced

Step 5: Now add an Action condition i.e. Create or update the record in HubSpot and add the object name in Record Type

Step 6: Select the External ID field to match and do field mappings according to the business needs

Step 7: Add a condition to check if the record creation/modification is successful or not

Step 8: If yes, add an action condition i.e. Update Record in Salesforce (to update HubSpot ID back to Salesforce) else perform operation according to your business needs (here we are terminating the flow)

Note: Don’t forget to Save and Activate both flows after implementation.

Working of Bi-directional Sync:
Use Case 01:

Step 1: Create a new record in HubSpot

Step 2: Execution Flow

Step 3: Record will be synced in Salesforce

Use Case 02:

Step 1: Create a new record in Salesforce

Step 2: Execution Flow

Step 3: The record will be synced in HubSpot

Thanks for reading! If you’ve got ideas to contribute to this conversation please comment. If you like what you read and want to see more, clap me some love! Follow me here, or connect with me on LinkedIn.

Thanks to my Co-Authors: Manas Singh and Vanshi Tiwari

--

--