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 Portal to create an account and log in.
  2. Create a new Integration using one of our Hubspot templates
27442744
  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.
27442744
  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.
27442744
  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.
27442744
  1. Back in the Fusebit Portal, find the Integration you would like to connect to the new HubSpot App you just created. Select the Connector tied to that integration

📘

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

28202820
  1. Select Enable Production Credentials in the Connector Configuration and then paste in the Client ID and Client Secret you obtained earlier from the HubSpot 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.
28202820
  1. Paste the URL provided by Fusebit in the HubSpot Configuration section under OAuth2 Redirect URL into your HubSpot App under *Redirect URL.
28202820
  1. Go back to the Installs tab of your Integration and delete any existing Installs. Now, any time a new user installs your Integration, you should now see your HubSpot App information displayed during the authorization step.

🚧

Existing users will need to re-authenticate once you complete this step.

  1. You can now hit Run in the Editor again, and you should be prompted to sign into your own HubSpot App.

📘

Some Fusebit users have reported that they sometimes see errors during the authorization step within the first 5-10 minutes after creating a new HubSpot App and making changes to things like Scopes. If you see such errors, please wait a few minutes and try hitting Run again, authorization should now succeed!

Good job! 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 HubSpot 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.
40244024
  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
40244024
  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.
40244024

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.
40244024

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:


Did this page help you?