Written by Rob Ainslie | Last Updated 6/6/2020
Estimated time to complete: 1 hour
Watch an overview of the tutorial components and finished product
The overall goal of this tutorial is to show how to use Integromat to send data to the HubSpot Timeline API. This implementation has many use cases, so for this tutorial, we will use Google Sheets as a sample app trigger, but the integration trigger could be any app or other integraton source.
For the specific use case, imagine a scenario where webinar attendees are added to a Google Sheet and you want to log that on the HubSpot Timeline. The benefit of the HubSpot Timeline API is that you can maintain the many-to-one relationship of ‘webinar attendance’ to Contact.
Integromat is a low-cost but powerful integration platform as a service (iPaaS), which this tutorial uses because of one particular feature that is available in their free tier that is typically only available in most other Enterprise grade iPaaS systems - that feature is the ability to create an arbitrary oAuth connection. Why is that important? Read on!
The HubSpot Timeline API is a ‘platform’ level API that is typically only available to HubSpot integrators that create developer apps. All developer-based apps must utilize oAuth as the authentication method (as opposed to key based authentication using a specific portal’s HAPI key). oAuth is great because it allows a user to authorize an app to their portal without sending passwords or one-size-fits-all API keys directly to the integrator. Though oAuth is more secure than using integration keys, it also requires overhead and technical know-how to set up. Luckily, Integromat takes care of most of the heavy lifting, allowing us to easily use powerful APIs without having to code at all! Nice!
This tutorial will follow these steps. Read on for the specifics:
Easy peasy - sign up for a free Integromat account. I recommend using Google Sign In, but that’s up to you. See how their pricing works here - they offer a ton of functionality and limit based on data usage, not on features. Feel free to do their onboarding walkthrough, or skip.
A Scenario is where we setup the app connections, logic and steps of our integration. Scenarios can be scheduled or triggered, which is helpful if there are certain times when an integration needs to poll an API for changes. Integromat also supports webhook based triggers where they provide you a webhook URL to send data to. This could be used in something like a HubSpot Workflow, where you webhook the data from the Workflow to the integration scenario. But for now, we’ll use Google Sheets as the trigger app. Let’s create the Scenario
We will create the initial shell of the integration scenario and the starting condition
Due to certain HubSpot APIs being limited to oAuth as their authentication method (such as the Timeline API, CRM Cards and Webhooks), we’re forced to create our own app to authenticate to HubSpot. Integromat does have an out-of-the-box HubSpot connector that you can authorize for a slew of other standard integration triggers and actions, however we’re not using them (or the HubSpot CRM app connection) in this tutorial.
Next, we’ll create the HTTP connection using oAuth 2.0 as the authorization method. This set of steps is one of the features that sets Enterprise grade iPaaS from others. The gist is that we’ll create a new HTTP connection in Integromat and provide it several configuration options and secret keys provided by your HubSpot developer portal app. The HubSpot app needs to be configured for the correct scopes (scopes grant the integration access to only certain data in HubSpot).
Most of the details to add for the oAuth connection are provided to us by our HubSpot app. Navigate back to your HubSpot Developer portal and click to the ‘Auth’ tab
www.integromat.com/oauth/cb/oauth2contacts, oAuth, timeline and integration-sync and then Save changes. client id and client secret for your app auth in Integromat. Copy them one at a time and paste in Integromat. Note: the client secret should never be shared publicly - this is the hidden key that should only be used in server-side applications.To complete the oAuth connection, in Integromat add the following:
HubSpot Webinar Apphttps://app.hubspot.com/oauth/authorizehttps://api.hubapi.com/oauth/v1/tokencontacts, oauth, timeline, and integration-sync - these must exactly match the scopes chosen in your HubSpot app!Client ID and Client Secret from your HubSpot AppShow Advanced Settings and change Scope separator to SpaceCreate a connection dialog should look like these two screenshots: Continue and you will be prompted to log-in to HubSpot, and then to Grant access to the app - choose the portal you want the integration installed into - that could be your personal portal or a test portal. Congrats, you just setup an oAuth app in a HubSpot portal! Celebrate!
Next, we will create a new Timeline Event type in our HubSpot app. Once created, you will see additional segmentation options in HubSpot Lists, Workflows and Lead Scoring
New event type Contact webinar_name and a data type of Stringwebinar_date, data type: Datewebinar_presenter, data type: Stringwebinar_category, data type: Enumeration, options: lead_gen, tutorial and customer_marketingOnce all properties are added, the screen should look like:
Content tab and edit the Header template and Detail template. Copy and paste the following:Webinar attendance: {{webinar_name}} on {{#formatDate webinar_date format="short"}}{{/formatDate}}
Detail template:
This event was created on {{#formatDate timestamp}}{{/formatDate}}
**Webinar Name**: {{webinar_name}}
**Webinar Category**: {{webinar_category}}
**Webinar Presenter**: {{webinar_presenter}}
**Webinar Date**: {{#formatDate webinar_date format="short"}}{{/formatDate}}
Create. Your Timeline Event Type should look like this: Whew. Now, we’re really ready to rock and roll
Navigate back to Integromat, and in the template details for the ‘Make a OAuth 2.0 request’, input the following:
https://api.hubapi.com/integrators/timeline/v3/eventsPOSTRawJSON (application/json)eventTemplateId to match the event ID in your HubSpot app (screenshot below)
{"eventTemplateId":"1005087","email": "{{1.`0`}}","tokens":{"webinar_name":"{{1.`1`}}","webinar_date":"{{formatDate(1.`2`; "x")}}","webinar_category":"{{1.`4`}}","webinar_presenter":"{{1.`3`}}"}}
Copy the evetTemplateId and replace in the above body: raw request can be finnicky - the above should work. (Integromat does have a handy ‘JSON’ action step to better format common JSON bodies, but we aren’t using it here).Before running your integration scenario, double check these pieces:
Assuming all of the pieces are in place, click the ‘Run Once’ button in the bottom right of your Integromat Scenario and then view the output logs:
If your output received a 201 response code, go find the contacts in your HubSpot portal and inspect the timeline (you may need to select the integration in the Contact Timeline filters):
If you need to troubleshoot, copy and paste new rows into the Google Sheet and then run the scenario again, using the output logs to troubleshoot.
You did it! You integrated to the HubSpot Timeline!
Some random final notes: