Recent searches
No recent searches
Macros: Giving different responses based on ticket content
Posted Oct 14, 2019
Using liquid markup, a macro can give different responses based on the content of your ticket.
Ticket tags
The placeholder {{ticket.tags}} lists the ticket tags as a string with each tag separated by a space. The following macro will give a different response based on the tags on the ticket.
{% assign myTags = ticket.tags | split: ' ' %}
{% for tag in myTags%}
{% case {tag} %}
{% when 'tag1' %}
You have tag1
{% when 'tag2' %}
You have tag2
{% endcase %}
{% endfor %}
Custom Fields
To base macros on custom ticket fields, first find its field ID from Admin>Ticket Fields.
Your macro can then say:
{% case ticket.ticket_field_360000034029%}
{% when 'My Value' %}
Your selected My Value
{% when 'My Value2' %}
Your selected My Value2
{% endcase %}
...as long as your replace 360000034029 with the ticket ID of your custom field.
If using a drop-down field, use the tag values for each option.
Note that the values in the case statement are case sensitive.
You can find out more on custom field placeholders here.
0
4 comments
Jennifer Rowe
Good one! Thanks, Graeme!
0
Riah Lao
Hi,
1. Is there a way to "escape" or what to replace single quote ' within the if else condition?
For example:
{% if ticket.brand.name == 'XYZ's' %}
2. Does "else if" work?
Thanks,
Riah
0
Greg Katechis
Hi Riah! Liquid markup is something that we provide as part of the function of our placeholders, however we don't have a lot of expertise on here at Zendesk. The documentation listed here goes over a few options for if/else workflows, so take a look at that and see if something there helps out. If not, I'd be happy to see what I can do, I just need some clarification around your questions. Could you let me know exactly what you're trying to accomplish so that I can see if I can find some options for you?
0
Per Näslund
Another way to trigger specific response macros based on ticket content is to use our AI Ticket Tagger to tag the ticket with what type of request it contains (works in all languages and is not dependent on specific words), and then trigger the macro based on what tag that was chosen. This feature is in beta, so make sure to write to us in the chat in order to get access.
https://www.zendesk.com/marketplace/apps/support/513754/ai-ticket-tagger-by-labelf
0