Trello API: how to disregard webhook updates when the update is provoked by my own system?
Asked by Robert Naud:

Let's say I have a system with database records matching cards on a board. The system listens to updates on the board webhook and when cards are renamed on the board, the system updates the corresponding database record to update the data the record has with the new card name.

The same system also pushes edits to the Trello board, renaming a card when a user edits the matching database record. This is done via the API. The API does not give back an action ID as part of the result of the API call used to perform the update.

Here is my question: How can my system, after updating a card's name, disregard the incoming update coming via the webhook and not initiate its procedure to write to the database (since the information is already there, the edit came from the database)?

Thanks for your input.


Answers:
author: Oscar Triscon
body: Unfortunately, there isn't an easy way to do this. You need to keep track of every action you perform and what is the expected result, then match the webhooks you receive with the actions you performed.

Alternatively, you can create a separate user just for the purpose of performing the automation, and use the idMemberCreator on the action to filter out actions performed by your fake user.

comments: author: Robert Naud
body: Hi [@Oscar Triscon](/t5/user/viewprofilepage/user-id/1124366), Trello Support confirms your answer. I think it would be nice to have Trello reply to my API call with a requestID it would assign to my call. Then in the webhooks, I could scan for any requestIDs that were already given back to me when making the initial call. Can anyone from Trello chime in to mention if this scenario is similar to what they plan on implementing?

Trello Support answered me "...We know this is a challenge for developers using webhooks and are planning to add some sort of functionality to better handle this issue. Though I don't have a timeline on when we'll ship that yet."

Since I'm mostly concerned by webhooks relaying actions about cards, I guess I could create a "disregard" label I would add to the card before making my edit and remove it immediately after. I know another user could submit an edit while my label is on the card, but it seems unlikely. I just saddens me that given this scenario, for one edit I would get 3 webhooks (adding the label, updating the card, removing the label), and I would need to make 3 api calls instead of just one.

Using a bot user looses who made those edits and it not a path I am comfortable with (but I have to admit it yields a stronger criteria to disregard the webhook).

Please let me know what you think.

Regards,

Robert Naud


author: Oscar Triscon
body: Hi Robert,

Sorry for not coming back to you sooner. I don't seem to have received a notification for your message.

Adding a label prior and removing it after has several drawbacks, including the ones you mention, but also the fact that the labels are not going to be included in the other webhooks, so every time you receive a webhook you'll need to fetch the card just to check if the card has the label or not. It'll adds a lot of overhead, increasing the chance of hitting rate limits, and make your system slower. A better system would be for you to store in a database table which cards are to be ignored.


Tags: api