Recent searches


No recent searches

Add a Tag to a New ticket if attachment is present



Posted Dec 02, 2020

To tag new tickets with a tags when they have attachments.

Use Case :

You can then use this tag to filter tickets with attachments to one view while other with no attachments to another view.

There can be other use cases too. 

Steps:

1. Enable API access type (see screenshot)

Password Access item 3 on the screenshot above - if you want to use username and password for your API auth only.

For token select item 4 on the screenshot - if you are going to generate API token in zendesk and use that.

You don't have to enable both but one will do.

2.Create target extension > HTTP
Title : Update Tags

URL : https://domain.zendesk.com/api/v2/tickets/update_many.json?ids={{ticket.id}}
Method PUT
Content Type JSON

Make sure your external target uses Basic auth. either via API token or admin credentials.

 

3.Create Trigger
SET-Check for Attachments
Condition - Ticket is created
Action - Notify Target : Update Tags
JSON Body : 

{"ticket":
{% for comment in ticket.public_comments offset:0 limit:1 %}
{% if comment.attachments.size > 0 %}
{"additional_tags":["attachments_yes"]}
{% else %}
{"additional_tags":["attachments_no"]}
{% endif %}
{% endfor %}
}

above code checks the comment for attachments, if attachments more than 0 than it tags the ticket with "attachments_yes"

or else it will tag as "attachment_no"

NOTE: You will see the following error-

You can ignore that error message, the JSON target is trying to validate your code as JavaScript rather than Liquid.

I tested this and it works for all new tickets

If this was helpful please upvote this and feel free to drop me a line on Linkedin.


1

46

46 comments

Please sign in to leave a comment.

Didn't find what you're looking for?

New post