Preventing loops when using Zendesk API and webhooks together.
Posted Mar 22, 2022
Hi,
Here is my following use-case. In my website -
- I'm using Zendesk APIs to create tickets or add comments to an existing ticket.
- I'm using Zendesk webhooks to listen to new comments added to that ticket, and call my website url.
One thing I noticed was that, when I create a ticket, it automatically triggers the webhook (which it is supposed to). This causes loops between my website and Zendesk.
Q1. Is there some way that I can filter it out? Is there a trigger condition I'm missing? I want exclude all webhook calls whose source is my API (there can be other APIs integrated in that account, and if they add a comment in the ticket, I want the webhook to hit my website).
Q2. If it is not possible to prevent the webhook from being called, that's fine. I'll need to update the logic on my website. So, I was thinking of adding an external-id to every comment created from my API, so that if the webhook sends me a comment with that external-id I can drop processing that webhook. But it looks like I can add external-ids to only tickets and not comments. Is there anything I can do about that?
1
1 comment
Zach Anthony
Hey there,
It sounds like you have an interesting use case! When you are calling the Zendesk REST API to add comments to a ticket, are you using a unique user? Or do you use the same credentials to authenticate to the API to update comments for other purposes?
While you may not be able to filter out ticket updates with a trigger condition for your use case, if you're using a unique user for this use case, you may be able to use a combination of adding a trigger condition of:
Update via Is Web service (API)
and adding {{ticket.latest_comment.author.name}} to the body of the webhook request.
In relation to your second question, if this doesn't work for you because you aren't using unique user credentials to call the Zendesk API - you are right in that you cannot add an external id to a ticket comment unfortunately.
Thanks for sharing your use case, I hope this helps!
0
Sign in to leave a comment.