Add a Tag to a New ticket if attachment is present



Data ultimo post: 02 dic 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 commenti

Hi ASHISH DIVAY,

what does the first line do? 

{% for comment in ticket.public_comments offset:0 limit:1 %}

I'm curious if this 'offset' and 'limit' stuff only checks the latest comment? But I have no idea how it works. ;-) 

I'm asking because let's say I want to see if there's a way to check if there is more than one attachment in the whole ticket conversation. I assume I would need to adjust the line mentioned above and also include some kind of counter instead of this '> 0 %' thing in line 2? 

0


Hey Dean,

Do you mind opening up a ticket so that our team can take a look at your account? When opening that ticket, if you could provide some examples where this is happening - it'd be apprecitated.

Thanks so much!

 

0


I have a question. I am using a webhook to set the subject of a ticket depending on various data in the form's fields. The subject does get updated using this trigger, but I want the subject to update before the email goes out on a newly created ticket. When I run the following webhook as the very first trigger on our instance (ahead of the notify requester of new proactive ticket) the email still goes out with the subject as it was when I submitted the ticket originally, not as is since being updated by this webhook.

What am I doing wrong?

The endpoint that this webhook is looking at is a PUT and domain/api/v2/tickets/{{ticket.id}}.json

{"ticket":
{"subject": "{% if ticket.ticket_field_360041372052 != null and ticket.ticket_field_360041372052 != '' and ticket.ticket_field_360044340271 != null and ticket.ticket_field_360044340271 != '' and ticket.ticket_field_360041327151 != null and ticket.ticket_field_360041327151 != '' %}TSG Reporting – Order Follow Up - {{ticket.ticket_field_360041372052}} - {{ticket.ticket_field_360044340271}} - {{ticket.ticket_field_360041327151}}{% elsif ticket.ticket_field_360041372052 != null and ticket.ticket_field_360041372052 != '' and ticket.ticket_field_360044340271 != null and ticket.ticket_field_360044340271 != '' and (ticket.ticket_field_360041327151 == null or ticket.ticket_field_360041327151 == '') %}TSG Reporting – Order Follow Up - {{ticket.ticket_field_360041372052}} - {{ticket.ticket_field_360044340271}}{% elsif ticket.ticket_field_360041372052 != null and ticket.ticket_field_360041372052 != '' and (ticket.ticket_field_360044340271 == null or ticket.ticket_field_360044340271 == '') and (ticket.ticket_field_360041327151 == null or ticket.ticket_field_360041327151 == '') %}TSG Reporting – Order Follow Up - {{ticket.ticket_field_360041372052}}{% elsif ticket.ticket_field_360041372052 != null and ticket.ticket_field_360041372052 != '' and (ticket.ticket_field_360044340271 == null or ticket.ticket_field_360044340271 == '') and ticket.ticket_field_360041327151 != null and ticket.ticket_field_360041327151 != '' %}TSG Reporting – Order Follow Up - {{ticket.ticket_field_360041372052}} - {{ticket.ticket_field_360041327151}}{% elsif (ticket.ticket_field_360041372052 == null or ticket.ticket_field_360041372052 == '') and (ticket.ticket_field_360044340271 == null or ticket.ticket_field_360044340271 == '') and ticket.ticket_field_360041327151 != null and ticket.ticket_field_360041327151 != '' %}TSG Reporting – Order Follow Up - {{ticket.ticket_field_360041327151}}{% elsif (ticket.ticket_field_360041372052 == null or ticket.ticket_field_360041372052 == '') and ticket.ticket_field_360044340271 != null and ticket.ticket_field_360044340271 != '' and ticket.ticket_field_360041327151 != null and ticket.ticket_field_360041327151 != '' %}TSG Reporting – Order Follow Up - {{ticket.ticket_field_360044340271}} - {{ticket.ticket_field_360041327151}}{% elsif (ticket.ticket_field_360041372052 == null or ticket.ticket_field_360041372052 == '') and ticket.ticket_field_360044340271 != null and ticket.ticket_field_360044340271 != '' and (ticket.ticket_field_360041327151 == null or ticket.ticket_field_360041327151 == '') %}TSG Reporting – Order Follow Up - {{ticket.ticket_field_360044340271}}{% endif %}"}
}

0


I'm not sure there's a way to do that, but since it seems adding options to the creation of views might obviate the need for these solutions, and since the method of updating a ticket via a trigger and target is not supported and can be unreliable, and since HTTP targets are being deprecated soon in favor of Webhooks, I think it might be helpful to our product team if one of you could post your use case to our Feedback - Ticketing System (Support) topic, using our Product Feedback Post Template to format your feedback. Our product team watches that space, and the more we can learn about your needs, the better. Thanks!
 

0


Thanks Ashish and Terry!

Did anyone yet check how to also trigger images pasted directly in the email text? The trigger in itself works fine but it seems images pasted into the text are not stored as attachments in the ticket JSON. Anyone checked out already how to catch those images as well?

0


Awesome resolution Ash! :)

0


Hi Terry Ehrhard,

Thanks for confirming. I feel strongly about information and love learning more on this. If possible, can you please help me in building that markup to achieve my goal.

Edit: I think we need to use “tickets/update_many” endpoint here.

I'm afraid as I have minimum knowledge of markup, so not sure how the correct code/request should look like.

I truly appreciate your valuable support!!

Regards.

Kuldeep

0


Hi Kuldeep - This would give you a count of any/all replies by agents both to customer and to internal agents.  See this article https://support.zendesk.com/hc/en-us/articles/115015611647-Trigger-conditions-and-actions-reference

If you only wanted to determine internal comments I suppose you could use markup to count the number of internal comments and add a tag when the count exceeds your preset limit.  

0


Hi Terry Ehrhard,

Thanks for sharing the great workaround! This looks very much similar to what I thought, but I would like to know if 'Agent Replies' condition will address the 'Internal comments' or not?

Since we're using an escalation mechanism to compete with those request and with the increase in back and forth between the teams, we're getting a lots of internal comments in the ticket and therefore want to apply a tag that could be routed to a separate queue if feasible. Or if there is any other workaround, please let me know.

Thanks again!

Kuldeep

0


Hi 1262731691290 - This is easily accomplished within a trigger.  We have one in place that elevates to high priority when 8 replies are exceeded

0


Accedi per aggiungere un commento.

Non hai trovato quello che cerchi?

Nuovo post