APIs & Integrations

hilton22
Contributor | Elite Partner
Contributor | Elite Partner

Hubspot Addon - to many request based on form submission

Hi,

 

Recently I have developed a Addon, using my Hubspot Dev Account. This app sends a webhook to the endpoint of my application. The main goal here is to create or update a deal to a contact, based on a Hubspot form. For that, my app needs to check if there is a deal for this contatc request, before create or update a deal. 

 

The webhook scopes are:

- contact.creation

- propertyOne -> contact.propertyChange
- propertyTwo -> contact.propertyChange


So far, so good... the app is working fine. But recently I detected a problem:

If the user clicks several times at the submit button on the form, Hubspot sends to my app the same number of requests, before the user been redirected to the "thank you" page.

 

The result is a duplicated or triplicated "deal" in Hubspot.

 

Can anyone help me with that?

 

Thanks,

 

PS: the form and the page, both was created using Hubspot native tools (Form and Design tools ). It's not a embedded form in a external site.

 

0 Upvotes
4 Replies 4
WendyGoh
HubSpot Employee
HubSpot Employee

Hubspot Addon - to many request based on form submission

Hey @hilton22,

 

A couple of clarification point here:

1. By 'HubSpot sends to my app the same number of requests' do you mean that you received multiple contact.creation Webhook subscription notifications for the same submission email? 

 

2. Thinking further on this case, I was wondering how do you determine when to create/update a deal? Perhaps you can add a layer of if/else checking mechanism? i.e. if the contact vid exist in the system > check if it has a deal > if it doesn't, create > if it does, update.  

 

This way, it is unlikely that there will be duplicated/triplicated deals created.

0 Upvotes
hilton22
Contributor | Elite Partner
Contributor | Elite Partner

Hubspot Addon - to many request based on form submission

Hello @WendyGoh,

 

Any news about this issue?

 

Thanks,

0 Upvotes
WendyGoh
HubSpot Employee
HubSpot Employee

Hubspot Addon - to many request based on form submission

Hey @hilton22,

 

Apologise on the delayed in response.

 

But the main reason that I'm posting here is that, every test that I made creating new contacts, clicking only once on the submit button, the result in Hubspot was the expected one. But every new contact created by clicking more than once on the submit button, duplicates or triplicates the associanted deal. Dispite the fact that the monitor tool always shows only the 3 requests.

 

In order for me to further troubleshoot this, could you share with me the following:

 

1. The page url in which the form in question is on

2. The app ID

3. The portal ID 

0 Upvotes
hilton22
Contributor | Elite Partner
Contributor | Elite Partner

Hubspot Addon - to many request based on form submission

Hi @WendyGoh,

 

Thank you for the reply! 

Sorry if I was not clear on my post. Let's clarify:

1. Observing the "Monitor" tool at the Hubspot app interface, I'm receiving only the 3 requests. In theory, it's the expected result when a new contact is created. Considering that the two others properties of the scope has been fullfill by the user.

 

Observing again my app, I'm realising that, in some cases, a "race condition" may happening. I need to fix this!

 

But the main reason that I'm posting here is that, every test that I made creating new contacts, clicking only once on the submit button, the result in Hubspot was the expected one. But every new contact created by clicking more than once on the submit button, duplicates or triplicates the associanted deal. Dispite the fact that the monitor tool always shows only the 3 requests.

 

2. There are layers that determine when create or update the deal. This application in specific doesn't have a data base to store the Hubspot data. I'll try to synthetize the process:

a) For each index of the Hubspot request array, the app gets the "objectId" and consume the Hubspot API (V3) to get the contact information, using the method "Read".  

b) If the contact exists, the app checks if the properties that is need exists. If exists, the process goes on, otherwise returns false.

c) If the conditions is satisfied, the API is consumed again, to check if there a deal associated with this contact object.

d) If the contact doesn't have any associeted deal object, the API is consumed again to create a new deal object,  and than consumed again to associate this new deal to the contact.

e) If there is already a deal or deals associated, the API is consumed again to get every deal informations, from the associated deal or deals.

f) The app checks if any of those deals matches with the requested data. If match, the deal is updated, otherwise a new deal is created.

 

That is how the plugin works. I don't know if I'm doing something wrong, but that's how I managed to make it work.

I hope it clarifies.

 

Thanks,  

0 Upvotes