APIs & Integrations

VVarelaAlzate
Participant

Crash web hooks

SOLVE

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
Community Manager
Community Manager

Crash web hooks

SOLVE

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


HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates.
Learn More.


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !

View solution in original post

2 Replies 2
VVarelaAlzate
Participant

Crash web hooks

SOLVE

@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
Community Manager
Community Manager

Crash web hooks

SOLVE

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


HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates.
Learn More.


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !