APIs & Integrations

timhantec
Member

Create a webhook for form submissions

We are using form submissions to track participants to our training classes and webinars and are looking to integrate the data into our website so that we can indicate when a class is full.

 

I looked into integrating with your API and came across:

https://developers.hubspot.com/docs/methods/forms/get-submissions-for-a-form

 

This looks like exactly what I'm looking for but questioning how the website is going to obtain the information. Based on the documentation I can either use an API key or OAuth. However, OAuth isn't really an option as we want the website backend to access this information and not the user of our website. I could use an API key but it seems they are only intended for quick tests and not intended for commercial use. There's also the danger of using an API key since it looks like it gives global access to the account, this isn't something that we want.

 

Is it possible to access this information through some other means? I see on the developer account I can create webhooks but they are only available for Contacts, Company and Deal objects.

0 Upvotes
4 Replies 4
lscanlan
HubSpot Alumni
HubSpot Alumni

Create a webhook for form submissions

Hi @timhantec,

 

You're right about the API keys: they do in fact grant global access. What about creating a private app using oauth? We have some instructions about creating an app here: https://developers.hubspot.com/docs/faq/how-do-i-create-an-app-in-hubspot. When you're creating the app you'll have an option to make the app public or private. A private app won't get any visibility, and so it will only be installed for your account.

 

Let me know if you think this will do the trick or if you have any other questions about it.

 

 - Leland

Leland Scanlan

HubSpot Developer Support
0 Upvotes
timhantec
Member

Create a webhook for form submissions

The issue is that we want our website backend to extract information from Hubspot independant of the user browsing our website. How do you propose we do that without asking each user of our website to sign in to Hubspot?

 

In other words, the website backend is the intended user to Hubspot. The information it pulls and displays is independant to any user browsing the website.

0 Upvotes
lscanlan
HubSpot Alumni
HubSpot Alumni

Create a webhook for form submissions

Hi @timhantec,

 

I think you can probably get this working via Oauth. You'd install the integration to your own HubSpot account. And then the integration would make the GET request to https://developers.hubspot.com/docs/methods/forms/get-submissions-for-a-form. Since the integration makes the request with the access token tied to your refresh token, the request is made specifically to the portal where the integration is installed. You'd make those requests from your own backend so that no access token is exposed. You'd then store that information in your backend. And when the webinar or training class fills up, you'll have that information stored on your backend, which would then update your website to indicate that the class/webinar is full. I suppose you could make those requests periodically (like every X amount of minutes). And then make an update to the website when there are no more seats left.

 

Or I think you probably could actually use the Webhooks API: https://developers.hubspot.com/docs/methods/webhooks/webhooks-overview. I think there would be a few steps involved, but it should be possible. If you subscribe to contact-based updates, you could listen for the property hs_calculated_form_submissions. So depending on how much traffic you get, that might be a lot of submissions. But you'll get a payload for each time a form is submitted, which updates that property for the contact that submitted the form. In the payload you'll get the contact's ID, which you can then use to get their form submissions from the endpoint documented here: https://developers.hubspot.com/docs/methods/contacts/get_contact. And once you find the latest form that they've submitted, you could use the original form submission endpoint that you found here: https://developers.hubspot.com/docs/methods/forms/get-submissions-for-a-form, to see how many submissions your form has. Like I said, it's a few steps. But might be a bit more real-time than just getting the form submissions every X minutes.

 

I'm mostly just brainstorming here, but at least conceptually I think that should work. Another possibility I wanted to point out is our integration with GoToWebinar: https://knowledge.hubspot.com/articles/kcs_article/integrations/use-the-gotowebinar-integration-with.... I don't know if that's a possibility for you. But you can sync HubSpot form submissions with GoToWebinar webinars. I'm not sure what that would look like on your end for syncing the GoToWebinar data with your website, but they would at least automatically handle the registrations and number of seats per webinar.

 

Let me know if you have questions about those ideas? Or if anyone else has accomplished something like this, please chime in.

 

 - Leland

Leland Scanlan

HubSpot Developer Support
timhantec
Member

Create a webhook for form submissions

Leland,

 

Thanks for the ideas.

 

Here's what we ended up doing... The forms are embedded into our website and with some Javascript, an event was setup to detect when each form was submitted. This just triggered our backend to store whatever information we wanted from the embedded form.