APIs & Integrations

ASpyropoulos
Participant

Webhook events received in wrond order

SOLVE

Hi all,

One of our operators change the lifecyclestage from the UI from value: lead to value: salesqualifiedlead.

That had an effect on receiving 2 events in our systems. 

{
...
"eventId": 1580172922,
"occurredAt": 1716234420436,
"subscriptionType": "company.propertyChange",
"attemptNumber": 0,
"propertyName": "lifecyclestage",
"propertyValue": "salesqualifiedlead",
"changeSource": "DEALS",
"sourceId": "deals-lifecycle-sync"
...
}

and later this:

{
....
"eventId": 3524437215,
"occurredAt": 1716234420020,
"subscriptionType": "company.propertyChange",
"attemptNumber": 0,
"propertyName": "lifecyclestage",
"propertyValue": "lead",
"changeSource": "CRM_UI",
...
}

Why does the hubspot system produced 2 events instead of 1 that has the value that changed?

0 Upvotes
1 Accepted solution
james-portant
Solution
Contributor

Webhook events received in wrond order

SOLVE

Hi @ASpyropoulos,

Yeah, that's right, when handling lifecycle stage changes in HubSpot, it is possible to receive multiple webhook events due to the different sources that can trigger property changes. Here's waht might have happened in your case:

  1. Event from DEALS: The first event (eventId: 1580172922) with changeSource: DEALS and propertyValue: salesqualifiedlead indicates that the lifecycle stage change was synchronized due to a related deal. This means that an associated deal's change in stage caused an automatic update in the company's lifecycle stage.

  2. Event from CRM_UI: The second event (eventId: 3524437215) with changeSource: CRM_UI and propertyValue: lead indicates a manual change made by an operator directly through the HubSpot UI.

The reason these events appear out of order and both were produced instead of a single consolidated event could be due to the following reasons:

  • Asynchronous Processing: HubSpot processes changes asynchronously, meaning that changes from different sources might be handled in parallel. This can result in events being dispatched in an order that does not necessarily reflect the actual sequence of actions.

  • Different Triggers: Lifecycle stage changes can be triggered by various actions in the system. In this case, one change was due to an internal synchronization process (likely from deals), and the other was a direct user action.

  • Event Handling Timing: The timestamps (occurredAt) of the events are very close, suggesting that these changes happened in quick succession. Minor delays in processing or network latency can affect the order in which these events are received.

To manage such cases, youcould add logic in your webhook handling system to account for potential reordering. For example, you can:

  • Track Latest State: Keep track of the latest state of the lifecycle stage based on the occurredAt timestamp, ensuring that your system reflects the most recent change.
  • Debounce Events: Introduce a small delay before processing events to allow for any potential out-of-order deliveries to be accounted for.

Please give me a shout if I can help with anything else.


Cheers,
James - CEO @ Portant

Portant App for HubSpot: https://ecosystem.hubspot.com/marketplace/apps/sales/sales-enablement/portant-hubspot-google-docs-in...

View solution in original post

3 Replies 3
james-portant
Solution
Contributor

Webhook events received in wrond order

SOLVE

Hi @ASpyropoulos,

Yeah, that's right, when handling lifecycle stage changes in HubSpot, it is possible to receive multiple webhook events due to the different sources that can trigger property changes. Here's waht might have happened in your case:

  1. Event from DEALS: The first event (eventId: 1580172922) with changeSource: DEALS and propertyValue: salesqualifiedlead indicates that the lifecycle stage change was synchronized due to a related deal. This means that an associated deal's change in stage caused an automatic update in the company's lifecycle stage.

  2. Event from CRM_UI: The second event (eventId: 3524437215) with changeSource: CRM_UI and propertyValue: lead indicates a manual change made by an operator directly through the HubSpot UI.

The reason these events appear out of order and both were produced instead of a single consolidated event could be due to the following reasons:

  • Asynchronous Processing: HubSpot processes changes asynchronously, meaning that changes from different sources might be handled in parallel. This can result in events being dispatched in an order that does not necessarily reflect the actual sequence of actions.

  • Different Triggers: Lifecycle stage changes can be triggered by various actions in the system. In this case, one change was due to an internal synchronization process (likely from deals), and the other was a direct user action.

  • Event Handling Timing: The timestamps (occurredAt) of the events are very close, suggesting that these changes happened in quick succession. Minor delays in processing or network latency can affect the order in which these events are received.

To manage such cases, youcould add logic in your webhook handling system to account for potential reordering. For example, you can:

  • Track Latest State: Keep track of the latest state of the lifecycle stage based on the occurredAt timestamp, ensuring that your system reflects the most recent change.
  • Debounce Events: Introduce a small delay before processing events to allow for any potential out-of-order deliveries to be accounted for.

Please give me a shout if I can help with anything else.


Cheers,
James - CEO @ Portant

Portant App for HubSpot: https://ecosystem.hubspot.com/marketplace/apps/sales/sales-enablement/portant-hubspot-google-docs-in...

ASpyropoulos
Participant

Webhook events received in wrond order

SOLVE

Thanks @james-portant for this detailed answer. I have a better understandement of these events now. 

0 Upvotes
james-portant
Contributor

Webhook events received in wrond order

SOLVE

No problem @ASpyropoulos . Happy to help 🙂

0 Upvotes