Auto-Delete a Ticket with a Trigger

21 Comments

  • McCabe Tonna
    Comment actions Permalink

    Adam,

    Although I have not checked recently - I doubt there is anyway to automatically delete tickets without manual intervention or API. 

    Ticket deletion typically is something that should be rare. Have you considered auto closing and adding a tag to not include in reporting or marking as spam.

    0
  • Colin Piper
    Comment actions Permalink

    McCabe is right, you cannot delete via a trigger. However if the ticket was actually closed then it cannot come back. Therefore it never actually closed.  You need to look at the events to see what actually happens. 

    0
  • Andrew Bowman
    Comment actions Permalink

    Hey Adam,

    Saw your question (which was the same as mine, and I came up with a solution via the API) Here's how you can delete a ticket via a trigger:

     

    1) Go to Settings > Extensions

    2) Create new URL target

    3) Use the following URL replacing example.zendesk.com with your zendesk domain: https://example.zendesk.com/api/v2/tickets/{{ticket.id}}.json?ticket[status]=deleted

    4) Method: PUT

    5) Attribute Name: ticket[status]

    6) Enter your login credentials and then Save (you most likely don't want to test target here, since you're not sure what it might do)

    7) You can then add this to any trigger/automation by selecting Notify Target, and then selecting this extension. For the value set this as deleted

    4
  • Jennifer Rowe
    Comment actions Permalink

    Hey Andrew, I know this was a couple of weeks ago, but I wanted to say thanks for sharing your solution! Hopefully it helped.

    1
  • Craig Willis
    Comment actions Permalink

    Thank you for this tip, this is working perfectly for our needs.

    Craig

    0
  • Craig Willis
    Comment actions Permalink

    After using the above suggestion for a while it started failing.  Working with the great Zendesk Support Team I was able to get this working as follows:-

    1) Go to Settings > Extensions

    2) Create new HTTP target

    3) Use the following URL replacing example.zendesk.com with your zendesk domain: https://example.zendesk.com/api/v2/tickets/{{ticket.id}}.json

    4) Method: DELETE

    5) Content Type: JSON

    6) Enter your login credentials and then Save (don't test this via the test option, it will delete a random case)

     

    6
  • Jonathan Santoya
    Comment actions Permalink

    I tried Craig's way of deleting tickets and it hasn't deleted the tickets I wanted.  Can you attach screenshot of your target setup and then your trigger too?

     

    This will help a lot and thank you!

    0
  • Joel Madden
    Comment actions Permalink

    After attempting to apply this extension, I'm prompted for a JSON body. I don't know what to put in the body. Nothing gets a message :

    HTTP/1.1 422 Unprocessable Entity

    Any thoughts on what is supposed to go in that body?

    0
  • Jono Hayes
    Comment actions Permalink

    We use Google for login credentials can I setup this HTTP Target without any authentication? Also are these the correct setting in the trigger?

    0
  • Antonina Obraz
    Comment actions Permalink

    @craig can you post the JSON body of the trigger. Following the steps from above fired up the trigger but did not actually delete the ticket. I used JSON body deleted, but I'm assuming you have to put in the status somewhere in there. I'm very unfamiliar with JSON , so this would be super helpful!

    0
  • Craig Willis
    Comment actions Permalink

    @antonina, Unfortunately  it stopped working so we have to go back to simply Closing the the case.

    This has it's advantages and disadvantages!

    Craig

    0
  • Arttu Hanska
    Comment actions Permalink

    @craig's approach works for me. @antonina: Just leave JSON body empty or pass empty object {}.

    Arttu

    0
  • Martijn Verburg
    Comment actions Permalink

    Hi Arttu,

    Is it still working for you?  Our trigger fires successfully (new ticket creation by Bot org is the trigger) but then the extension doesn't appear to get called.

    0
  • Dan Cooper
    Comment actions Permalink

    Another solution that may work in scenarios like the original post could be to blacklist certain email domains. If you look under Admin > Customers if you have Anybody can submit tickets enabled, you have the option to apply domains to a whitelist of blacklist.  If you have an organization domain, you can add that domain to the whitelist and add an * to the blacklist to block everyone else.  This will suspend tickets instead of deleting them, but it might be a better option for some than fully deleting a ticket. 

    As for using the HTTP target to update.  I think you’ll need to make sure that your HTTP target is authenticated using an API token, or a user email/password combo. 

    0
  • Arttu Hanska
    Comment actions Permalink

    @Martijn: Works for me with the old settings.

    0
  • Scott Boyce
    Comment actions Permalink

    @craig's solution is working for me.  Much appreciated!

    0
  • Ben Rouncefield-Swales
    Comment actions Permalink

    Hello, is there a way to use this method to delete tickets with a certain tag? I've set an automation to assign a tag to a ticket after it has been closed for a certain period of time (statute of limitation). I figured the next step would be to set a trigger to delete a ticket assigned that tag? While I'm typing this I'm wondering whether it's possible to set an automation to just delete the ticket instead of adding a tag...? Any help appreciated.

    0
  • Jessie Schutz
    Comment actions Permalink

    Hi Ben! Welcome to the Community!

    So I have a quick point of clarification to start...are you adding a tag to a ticket that's been Solved, or Closed? I ask because once a ticket has been moved to Closed status it can no longer be updated so that tag will never be added. You'll want to make sure that you add the tag while the ticket is still in Solved status.

    Beyond that, it's not possible to delete tickets using triggers or automations. However, you should be able to set something up using our API to delete these tickets when you need to. 

    0
  • Andy Pearce
    Comment actions Permalink

    I wish I could get this to work.... the trigger is firing, but the extension isn't sending.

    Perhaps because we use Google to log into our Zendesk and the HTTP target can't auth with this?

     

    Can anyone offer their experience or advice here please?

     

    Thanks!

    0
  • Andy Pearce
    Comment actions Permalink

    Seems I'm getting the same error mentioned here: https://support.zendesk.com/hc/en-us/community/posts/203723688/comments/241105888

    HTTP/1.1 422 Unprocessable Entity

    0
  • Guy Dee
    Comment actions Permalink

    Hi Andy!

    Typically a 422 response from the Delete Ticket endpoint of our API indicates that you're sending a JSON body that's not valid. The DELETE request shouldn't have any content, so try sending an empty object {} instead of a blank body or any content within the body.

    1

Please sign in to leave a comment.

Powered by Zendesk