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:
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 :
A user signup into Meta API platform
We trigger a Spell on our platform with basic information, like name, email, ids
Our Spell will create or update inside HubSpot a user, a company and a deal
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?
We end up with calling more than 14 endpoints on HubSpot API! (and only one on Slack 😌).
Brace yourself, let's see what is going on.
First, we need to get all "foundation" data from HubSpot : Pipeline Ids, Products Ids, properties technical name for associations later
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.
That the easiest part : 1 connector, 8 lines of code and it's done!
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.
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
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.
Nice! Let's do the same with the 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.
So let's call a specific endpoint to create this 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 🙄
2-Figure out the associationType (no clear list either inside the official doc) and the direction of the association
3-Then, we need to do the same with deal creation and association the deal with the contact and the company
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...
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.
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 🙏
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.
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
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
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.
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.
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 !