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 comments
Anita Rajkumar
Awesome resolution Ash! :)
0
Sebastian
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
Dave Dyson
0
Dean Kongslie
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
0
Eric Nelson
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
Fabio
Hi Ash,
what does the first line do?
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
Tipene Hughes
Hi Fabio,
Ash might want to jump in here to offer more clarification but from my understanding of how this is written, you're correct that the offset:0 and limit:1 specifies that only the most recent ticket comment will be evaluated against. You can increase the limit to evaluate against more comments in the ticket.public_comments array.
The next line is evaluating the actual size of the attachment, not the attachment count on that ticket comment so for you to be able to check if there are multiple attachments, you will need to implement some type of counter to track how many attachments are present on the ticket, and apply the tag depending on that.
Here's a link to the docs which might be helpful to you:
https://shopify.github.io/liquid/tags/control-flow/
I hope this helps!
Tipene
0
Alan
Ash (or anyone else who is knowledgeable) - I could use some assistance with this.
I set up my webhook and trigger according to all the comments. The trigger is firing as it should, but every ticket is getting tagged as if it has an attachment. Any idea why that may be?
0
Cheeny Aban
I created a ticket on your behalf. Don't worry! one of our colleagues will get in touch with you regarding this issue.
0
TylerE Comfort
Terry Ehrhard Ash
This was woking fine for us, but it stopped and I've been unable to get it working again. I'm using a target with a basic authenticion using token. I know that the authentication is working fine b/c I've tested it without the liquid markup and it updates the ticket (I'm using the update many endpoint).
Something is off with the code. I keep getting the unable to parse json error. I've tried copying as a single line, multiline. Not sure if Zendesk changed something.
0
Alan
Hey TylerE Comfort,
As per another suggestion here, changing ticket.comments to ticket.public_comments may work for you here. The second line would look like this:
0
Rositsa Pavlova
Hi,
Can you advise if this is an issue that anyone else is experiencing as well?
I was able to create webhook and trigger as shown above, but the issue that I am experiencing is that when a file is sent through Live chat, it seems like Zendesk doesn't consider that as ‘’attachment''. I tested that couple of times and when I check in the ‘Attachment Manager’ App, it says that there are no attachments, when a picture was uploaded via chat.
All of the chat tickets (even those with pictures in them) are being tagged with attachements_no.
Is there probably something that I am doing wrong?
Regards,
Rose
0
Tipene Hughes
Nothing immediately comes to mind that would cause this workflow to function incorrectly with live chat; the attachments should be available to the API in the same way as normal tickets.
Are you using messaging by any chance? If so, that would likely be the cause of what you're seeing.
0
Rositsa Pavlova
Hi Tipene Hughes ,
We use Agent Workspace but we haven't switched to messaging yet and we are still using the live chat option.
Here is an example of what is happening:
Regards,
Rose
0
Tipene Hughes
Can you send me through a screenshot of your webhook set up, including the JSON body containing the markup? And just to be double sure, this is working with tickets other than chat, correct?
Thanks!
Tipene
0
Rositsa Pavlova
Hi Tipene,
I ran this just for short period of time and got one email with attachment where the ticket was correctly tagged with ‘’attachments_yes''.
Here is the webhook:
And this is the attached trigger:
Regards,
Rose
0