• Live group demo of Marketing Hub + Data Agent

    Standardize reporting, reduce manual work, and introduce AI without cleanup

    Join us on March 12
  • Ready to build your local HubSpot community?

    HUG leaders host events, spark connections, and create spaces where people learn and grow together.

    Become a HUG Leader

Crash web hooks

VVarelaAlzate
Participant

Hy everyone

Is that I have a developer account in which I implement webhooks for the creation and manipulation of contacts and tickets. This with the objective of receiving them in an internal database and keep and update the information. But I noticed a detail when creating the ticket, when a ticket is created and a contact is associated to it (in the same creation) there are occasions in which the webhook of association arrives first before the one of creation, for the same reason it is not associating in data base since when the one of association arrives because the ticket to which the contact is associated does not exist.

0 Upvotes
1 Accepted solution
Jaycee_Lewis
Solution
Thought Leader

Hey, @VVarelaAlzate 👋 Thanks for your post.

 

You've highlighted an interesting challenge with webhooks. Webhook delivery order can't be guaranteed due to the asynchronous nature of webhooks and network latency. 

 

There are a couple of strategies you can consider:

  • Implement a retry mechanism in your webhook listener. If a webhook arrives referencing a ticket that doesn't yet exist in your database, you can queue it for a retry after a short delay

  • Try a Two-Step Process. First, only create the ticket. Once the ticket creation webhook has been processed and the ticket is stored in your database, then you can update the ticket to associate it with the contact. This should ensure that the ticket exists in your database before the association webhook arrives

  • If an association webhook arrives and the ticket doesn't exist in your database, you could use the HubSpot Ticket API endpoints to fetch the ticket directly from HubSpot

Have fun building! — Jaycee





loop


Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.

Learn More




View solution in original post

2 Replies 2
VVarelaAlzate
Participant

@Jaycee_Lewis 

What I did was that when the ticket creation webhook arrives, before saving it in the database call the ticket api to see if it had an associated contact and save it in the ticket record.

Thank you very much for the help!! 🙂

Jaycee_Lewis
Solution
Thought Leader

Hey, @VVarelaAlzate 👋 Thanks for your post.

 

You've highlighted an interesting challenge with webhooks. Webhook delivery order can't be guaranteed due to the asynchronous nature of webhooks and network latency. 

 

There are a couple of strategies you can consider:

  • Implement a retry mechanism in your webhook listener. If a webhook arrives referencing a ticket that doesn't yet exist in your database, you can queue it for a retry after a short delay

  • Try a Two-Step Process. First, only create the ticket. Once the ticket creation webhook has been processed and the ticket is stored in your database, then you can update the ticket to associate it with the contact. This should ensure that the ticket exists in your database before the association webhook arrives

  • If an association webhook arrives and the ticket doesn't exist in your database, you could use the HubSpot Ticket API endpoints to fetch the ticket directly from HubSpot

Have fun building! — Jaycee





loop


Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.

Learn More