This Integration allows full access to the HubSpot API from your application. Fusebit's multi-tenant approach makes it easy for you to manage multiple HubSpot connections on behalf of your app's users. Our Node.js-based programming model and lightweight deployment story make it easy to customize the Integration with any necessary business logic.

Getting Started

  1. Use the Fusebit Management PortalFusebit Management Portal - The Fusebit Management Portal enables you to easily setup and manage all your integrations in one place. Link: https://manage.fusebit.io to create an account and log in.
  2. Create a new Integration using one of our Hubspot templates
  1. You will then be able to run the Integration, download it's code, modify it, and deploy your changes. Detailed instructions on how to get started with an Integration are available here.

Invoking the HubSpot API

The Integration template comes pre-configured with some example calls that invoke HubSpot's API, for example:

const contacts = await hubspotClient.crm.contacts.getAll();

The hubspotClient object provided by Fusebit is an instance of the @hubspot/api-client package. The full reference documentation for the package is available here.

Fusebit ensures the above SDK object is already bootstrapped with the HubSpot credentials of the user invoking the integration. You do not need to worry about obtaining an access token or refresh token for them -- Fusebit does that for you automatically.

Creating your own HubSpot App

Out of the box, Fusebit's HubSpot Integration uses our own demonstration application in HubSpot. This is only done to make it easier for you to get started, however you will need to register your own HubSpot App for use in Production.

  1. Go to https://developers.hubspot.com/ and create a HubSpot Developer Account. Once created, select Create an app.
  1. In the Basic info section of your app, navigate to Auth. Note the Client ID and Client Secret as you will need those later.
  1. If the method(s) you want to invoke against the HubSpot API require certain permissions see here, add the appropriate scopes under the Scopes section. The crm.objects.contacts.read scope is necessary to run the example provided later.
  1. Back in the Fusebit Portal, find the Integration you would like to connect to the new Slack App you just created. Select the ConnectorConnector - A connector is the package from Fusebit that manages the relationship between one or more integrations and a specific service. One of the most common types of connector is an OAuth connector, which takes care of the OAuth negotiation between your customers and the service you're integrating, so that you don't have to! tied to that integration

πŸ“˜

If more than one Integration is linked to that same Connector, they will all use the new Slack App you are about to configure.

  1. Select Enable Production Credentials in the Connector Configuration and then paste in the Client ID and Client Secret you obtained earlier from the Slack App you created. Also, list the permissions your code requires in the Bot Token Scopes field. To use the example provided later in this guide, specify the crm.objects.contacts.read scope.

🚧

When switching a Connector to a different HubSpot App, all IdentityIdentity - An identity is a unique relationship one of your customers has with a service. An identity can be used by multiple integrations to act on that service on behalf of your customer. objects associated with that Connector will be deleted. Your users will need to re-authenticate against HubSpot after you make the change.

  1. Paste the URL provided by Fusebit in the HubSpot Configuration section under OAuth2 Redirect URL into your HubSpot App under *Redirect URL.

πŸ‘

Good Job!

Now, any time a new user installs your Integration, you should now see your HubSpot App information displayed during the authorization step.

Also, now that you've configured your own app, you can also leverage our Webhooks SDK to receive events from HubSpot!

Receiving events from HubSpot

With this HubSpot App configuration, your Fusebit Integration will be able to sync any updates directly with HubSpot. But you will likely also want to have your application respond to events from HubSpot (on behalf of your users) without having to poll for changes first.

We can achieve that by configuring your HubSpot App and leveraging their Webhooks API and connecting it to Fusebit.

  1. Make sure you are using your own Slack App and have configured your Connector with that app's secrets. In your Connector, note the Events API Request URL as you will need it in the next step.
  1. In your HubSpot App configuration screen, go to Webhooks and in the Target URL field, paste the URL you copied from Fusebit in the previous step
  1. You need to decide what event types you would like to listen to, to do this click on Create Subscriptions and select the specific objects and events you would like to subscribe to.
HubSpot will automatically notify you if your app is missing a specific scope for a requested event and add it for you, however you must remember to add the new scope to the Connector in the HubSpot App Scopes field in the portal.HubSpot will automatically notify you if your app is missing a specific scope for a requested event and add it for you, however you must remember to add the new scope to the Connector in the HubSpot App Scopes field in the portal.

HubSpot will automatically notify you if your app is missing a specific scope for a requested event and add it for you, however you must remember to add the new scope to the Connector in the HubSpot App Scopes field in the portal.

  1. Now, activate the subscriptions as HubSpot pauses them by default when being added.

Once you have configured HubSpot Webhooks for your Connector, you can receive events in your Integration. The Connector will route all events from the workspace (team) that your Integration was authorized for when it was created.

  1. Finally, update your integration.js to add the following handler, in this example - we are listening for new changes from HubSpot and logging the new value to console.
integration.event.on('/:componentName/webhook/:eventtype', async (ctx) => {

  const new_value = ctx.req.body.data.propertyValue;
  console.log ('There is a new update to your Hubspot Contact! Updated Value:' new_value)
  
// Insert your code here and invoke your backend to perform an action using this information!
});

Helpful References

Want to learn more about how to work with HubSpot Webhooks? Here's some helpful references: