APIs & Integrations

JKnott
Member

Deal webhooks triggering multiple times.

SOLVE

I've setup a webhook on our deal stages.  So as a deal enters a certain column, it should fire a webhook once, however it is being fired 3 times..  Any ideas?


0 Upvotes
1 Accepted solution
Mike_Eastwood
Solution
Key Advisor | Gold Partner
Key Advisor | Gold Partner

Deal webhooks triggering multiple times.

SOLVE

Hi @JKnott 

 

I've found the HubSpot API to be overly excitable with Webhooks. If you don't reply to HuBSpot within milliseconds then HubSpot assumes you weren't listening and tries again (we've all had relationships like that).

 

So, what we typically do is receive the JSON from the Webhook, pass it to a Job Queue and reply "success" to HubSpot as soon as possible, so we can process the data without HubSpot nagging.

 

Also, you'll want to check the attemptNumber (see below) in the JSON.

 

And, you'll also want to check for mutliple objects in the JSON - HubSpot can batch the replies (see below).

 

// batched Webhook Data
[
  {
    "objectId": 1246965,
    "propertyName": "lifecyclestage",
    "propertyValue": "subscriber",
    "changeSource": "ACADEMY",
    "eventId": 3816279340,
    "subscriptionId": 25,
    "portalId": 33,
    "appId": 1160452,
    "occurredAt": 1462216307945,
    "subscriptionType":"contact.propertyChange",
    "attemptNumber": 0
  },
  {
    "objectId": 1246978,
    "changeSource": "IMPORT",
    "eventId": 3816279480,
    "subscriptionId": 22,
    "portalId": 33,
    "appId": 1160452,
    "occurredAt": 1462216307945,
    "subscriptionType": "contact.creation",
    "attemptNumber": 0
  }
]

 

Have fun

Mike

 

p.s. thanks for the mention @dennisedson 

View solution in original post

5 Replies 5
Mike_Eastwood
Solution
Key Advisor | Gold Partner
Key Advisor | Gold Partner

Deal webhooks triggering multiple times.

SOLVE

Hi @JKnott 

 

I've found the HubSpot API to be overly excitable with Webhooks. If you don't reply to HuBSpot within milliseconds then HubSpot assumes you weren't listening and tries again (we've all had relationships like that).

 

So, what we typically do is receive the JSON from the Webhook, pass it to a Job Queue and reply "success" to HubSpot as soon as possible, so we can process the data without HubSpot nagging.

 

Also, you'll want to check the attemptNumber (see below) in the JSON.

 

And, you'll also want to check for mutliple objects in the JSON - HubSpot can batch the replies (see below).

 

// batched Webhook Data
[
  {
    "objectId": 1246965,
    "propertyName": "lifecyclestage",
    "propertyValue": "subscriber",
    "changeSource": "ACADEMY",
    "eventId": 3816279340,
    "subscriptionId": 25,
    "portalId": 33,
    "appId": 1160452,
    "occurredAt": 1462216307945,
    "subscriptionType":"contact.propertyChange",
    "attemptNumber": 0
  },
  {
    "objectId": 1246978,
    "changeSource": "IMPORT",
    "eventId": 3816279480,
    "subscriptionId": 22,
    "portalId": 33,
    "appId": 1160452,
    "occurredAt": 1462216307945,
    "subscriptionType": "contact.creation",
    "attemptNumber": 0
  }
]

 

Have fun

Mike

 

p.s. thanks for the mention @dennisedson 

dsmarion
Contributor

Deal webhooks triggering multiple times.

SOLVE

Hi @Mike_Eastwood 

 

Can you recommend a specific job queue?  I am using nodejs and I can find several on NPM as well as articles on building your own.  What are you using?

0 Upvotes
Mike_Eastwood
Key Advisor | Gold Partner
Key Advisor | Gold Partner

Deal webhooks triggering multiple times.

SOLVE

Hi @dsmarion 

 

The stack I use for integrations – that I can't build in HubSpot – includes Laravel (php, mysql) deployed to AWS using Vapor. Vapor converts the Job Queue to use Amazon's infrastructure.

 

While it's a little opaque I don't have to manage servers so I have more time to play on the fun stuff. 

 

Have fun

Mike

dsmarion
Contributor

Deal webhooks triggering multiple times.

SOLVE

Hi Mike.  Thanks for the quick reply 🙂

 

I do have a large Laravel project I wrote a few years ago that is using the built-in jobs.  That project is hosted on AWS EC2 Amazon Linux using Beanstalkd as the queue and Supervisor for the worker processes.  Works really well.  I am not familiar with Vapor.

 

For these HubSpot integrations I am using Node.js with Express hosted in Docker containers (also hosted in AWS EC2 Amazon Linux) and so I need a queue built for Node.js  I see several options but I was hoping someone already using one could save me time with a recommendation.

 

I'd be interested in what "fun stuff" you are currently playing with 😎

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

Deal webhooks triggering multiple times.

SOLVE

Hey @JKnott 

Welcome to the Community!

You can see duplicates

Per the docs:

NOTE ON UNIQUENESS: We do not guarantee that you will only get a single notification for an event. Though this should be rare, it is possible that we will send you the same notification multiple times.

 

Are you always seeing this?

@Mike_Eastwood , any other reasons this might happen?

0 Upvotes