Get a Demo

 

The Meta API integration platform-as-a-service (iPaaS) empowers your developers, data analysts, and IT admin to connect applications and data quickly. 

4 min read

We turned Hubspot (complicated) API into a simpler and powerful API!

Meta API and Hubspot Integration

Since the launch of our platform in October 2020, we at Meta-API acquire more and more user and we need to manage them. HubSpot is now a key tool for our acquisition and sales team. From sending newsletter and welcome emails to follow our new customers, our team need to follow key metrics coming from our platform: how many Spells are our user creating? Are they active? Did they manage to push their next API into production? All these data are key for a meaningful relationship with our users.

We decided to create a bridge between our platform and HubSpot and, of course, we'll use HubSpot APIs and our own platform to create the most flexible and powerful workflow. Here is our journey:

Diving into Hubspot API

Our first step is to replicate a user signup from our platform into HubSpot to allow our team to follow our users and automate communications.

The workflow is pretty simple :

  1. A user signup into Meta API platform

  2. We trigger a Spell on our platform with basic information, like name, email, ids

  3. Our Spell will create or update inside HubSpot a user, a company and a deal

  4. Send a message for us into our newcommers Slack channel to celebrate πŸ₯³

Seem simple right? We just need to call a few API's endpoints (like 4 or 5), do some if/else and it's done. Right?

Right?

https://media.giphy.com/media/A6PcmRqkyMOBy/giphy.gif

We end up with calling more than 14 endpoints on HubSpot API! (and only one on Slack 😌).

Hubspot Connectors

Brace yourself, let's see what is going on.

1. Getting all "config" data

First, we need to get all "foundation" data from HubSpot : Pipeline Ids, Products Ids, properties technical name for associations later

Static DataFrom line 16 to 39, we get all these "static" data

We use at start some configuration variables to allow ourselves a way to update this Spell quickly if we need to rename something on HubSpot.

Connectors configurationHere is an example on how we configure each connectors. The UI interface we built allow us to keep our code clean and small to focus on data manipulation

2. Send a Slack message

That the easiest part : 1 connector, 8 lines of code and it's done!

Slack ConnectorThe Slack connector selected and an example of variable injection

At first (line 41), we prepare the message we will send to us in a variable

Then, we call our Slack connector with:

  • Variable injection for the message

  • Setting the target channel

  • Setting the name of our bot

Finally, we just check if everything goes fine and throw an error if it's not the case. We have built an automatic errors catcher and alerting inside our Spell's engine.

Slack Integration

 

3. Back to Hubspot creation user and company

We want to make our Spell flexible enough to create or update contacts and companies inside HubSpot and avoid creating any duplicated entries.

If both case, we need to retrieve contact's id and company's id for the next steps (line 51 and 52).

First, let's call HubSpot search on contacts

Hubspot Search Contact

Here the body is filled directly inside our code editor and we can rely on the schema given by our connector to provide the right values.

Once done, we'll extract from the search result, on the first entry (because only one contact with a given email can exist on HubSpot) the ID.

Thanks to Javascript optional chaining, we can do it with one line (73) :

hubspotContactId = searchUser.results?.[0]?.id as string;

If we can't retrieve this ID, we'll create the new contact with one connector and then save his ID.

Hubspot New Contact

Nice! Let's do the same with the company

Hubspot New Company

Here we are: we have now a new contact and company but we forget something. In the case of creating a new company, we need to associate the contact to the company (in order the experience all the power of HubSpot's associations) and create the associated deal as well.

 

4. The association inferno:

So let's call a specific endpoint to create this association:

Hubspot Association

Once written, it's seem simple but it's took me a headache to:

1-Figure out the objectType (we can't find a proper list of all object types, even inside Hubspot's documentation) and the direction of the association (should I associate a contact to a company or a company to a contact πŸ€”). Of course, these parameters are not at the same level πŸ™„

Hubspot Object Type

2-Figure out the associationType (no clear list either inside the official doc) and the direction of the association

Hubspot Association Type

3-Then, we need to do the same with deal creation and association the deal with the contact and the company

Hubspot Deal Creation

Hubspot Deal Association

I've tried to use the batch endpoint to create multiple associations at the same time, but fromObjectType and toObjectType must be the same despite the association type. Anyway...

 

5. Add a quote to measure our potential MRR

The last step is to create a new Line entry to add a quote on our deal. That will allow us to measure our potential MRR with our transformation rate.

Hubspot Add Quote

And once again, we have to deal with association.

Please HubSpot: allow us to add a contact id, company id or deal id directly inside the creation request to automatically make the association. That's will save you millions of API's request and all developers will thank you πŸ™

 

6. The dev experience

During all this Spell creation, we were able to hit the Run button to test our code, watch error and check our integrated console and then press the Deploy button to push everything live inside a scalable Serverless function.

We have now our simplified and powerful API !

Our Spell is now finished and we can enjoy the simplicity of calling it from our backend.

Here an example of a valid cURL command to call this API

raycast-untitled

That's it! Behind this simple request is hidden 14 APIs requests and our business logic to create or update exactly what we need to give all the data our team need.

The best part is what that Spell include:

  • Automatic monitoring of each endpoints used as a connector

  • Logging errors and performances

  • Alerting us in case of an error

Hubspot Monitoring

And for us, the tech team, it's a piece of cake to maintain and to upgrade : we just have to update our code and connectors and press the Deploy button once everything is ready. The implementation inside our backend won't change and we are ready to add any new feature at any time.

 

Conclusion

When you start to integrate big solutions like HubSpot, you can't anticipate the complexity of integration before diving deep down inside the documentation or start coding your integration.

Having this capacity to add more and more connectors while discovering the solution is very flexible and generating a simple API abstracting and encapsulating all the code and related requests is reassuring: I know I can use it in any programming language, trigger it with a cron or even use it with a webhook.

All configuration, authentication, monitoring are set apart and I just have to concentrate on choosing the right API endpoints and figuring out how I will manipulate and transform data.

 

Experience it now!

Here is the open spell if you want to use it ==> Automate Company and Deal creation into HubSpot and be notified on Slack

With Meta-API, you can create yourself this kind of integration with any API, private or public, and you can enjoy our catalog of Open Spells, ready to used and customizable at will.

Try it right now and create your free account at https://dashboard.meta-api.io/signup !

Reddit & Discord integration

If you’re a subreddit owner and a Discord server owner, you may want to keep your Discord channel in sync with your subreddit.

Meta API

One step towards the revolution of APIs usage

Hey there πŸ‘‹,

I hope you are doing well in these complicated times.

I’ll try to cheer you up and, maybe, inspire you with this project which is the...

Top 50 most used APIs in Meta API

An API, or application programming interface, is a set of definitions and protocols that facilitate the creation and integration of software...