If you're familiar with placeholders in Zendesk Support, then you already know something about Liquid markup. It's the templating language we use to enable them. Placeholders are used in automations, macros, targets, triggers, and widgets as containers for dynamically generated ticket and user data. What you may not know about Liquid markup is that you can also use it to customize how this data is selected and displayed as output. This is because Liquid also allows you to create simple programming logic such as case statements, if statements, for loops, and so on.
By writing simple control statements directly in the comment/description action in macros and the email user action in automations and triggers, you can accomplish in one automation, macro, or trigger what you used to have to do in multiple automations, macros, and triggers. You can also customize how comment text is presented.
You can find the Liquid documentation at Liquid for Designers. All of the elements of the language are described in detail. Here, however, is a brief introduction to how it works.
Liquid is a templating language for rendering email and HTML. Liquid is the mechanism that enables the automated placement of data in comments and email notifications using placeholders.
- Output, which is text output contained in double curly brackets.
- Tags, which contain the programming logic that determines how the data is expressed with placeholders.
If you simply equate output with placeholder, you're about half way to understanding what Liquid is and how it's used. What you may not know about Liquid output however is that in addition to expressing ticket and user data, there are also methods available to manipulate text strings and arrays. In Liquid, these methods are referred to as filters. Using a filter you can transform text to uppercase characters, for example. But that's one of the simplest examples of what filters can be used for. See the Liquid documentation for more information.
The other half of understanding of how Liquid can be used comes from knowing what tags are and how they are used. Tags provide the programming logic that you can use to select and present data.
Using Liquid tags you can create:
- if else statements
- case statements
- for loops
- cycles
- variable assignments
For more examples of how Liquid markup can be used, see the following articles:
- Using Liquid markup to support multiple languages in automations, macros, and triggers
- Modifying a ticket trigger to return a response based on business hours
- Using Liquid markup to customize the formatting and placement of text in comments and email notifications
- How can I format placeholders with liquid markup?
60 comments
Greg Katechis
Hi Tatiana! The reason you're seeing this error is because you used a single "=" sign...you'll need to use double "=" signs like this:
0
Jacob the Moderator
Hey Tatiana,
Perhaps you could sidestep the issue by comparing part of the string (contains) without the apostrophe, as in...
# string = 'hello world'
{% if string contains 'hello' %}
string includes 'hello'
{% endif %}
0
Jacob the Moderator
Have you tried to wrap the string in single quotes rather than double?
0
Walter
Hi Greg Katechis,
Is it possible that the placeholders are not rendering inside of a logic tag?
I tried a very simple liquid logic expression:
{% assign my_variable = ticket.brand.name %}
and the variable does not get assigned any value.
Therefore, I can safely assume that the following expression
{% if ticket.brand.name contains 'Jameson' %}
will result in an error because it is the same thing as
{% if NULL contains 'Jameson' %}
0
Jacob the Moderator
Hi Tatiana Ozaruk
Have you tried using case statements instead?
0
Jacob the Moderator
Hi Tatiana Ozaruk
You probably resolved this a while back, I just came across the same error message, so I wanted to add my observations here.
Placeholders have dots in them, and sometimes a composer window will interpret them as URLs, resulting in the error message "Liquid error: Unknown operator href=".
When I un-linked the placeholder text and saved the macro, the error was no more and my Liquid Markup worked.
0
Rawkers
Hello,
I wanted to know if there was a way to update a field to a certain value.
It would be quite useful for me to update it with Liquid as I need to check another field to determine to which value the second field needs to be set to.
Unfortunately, I could not find any information about such feature.
Does anyone knows if it is possible or not?
I thank you in advance and wish you all a nice day!
0
Jacob the Moderator
Hi Rawkers,
Could you please give some more context, like what field type you would want to update and would you want to use placeholders from other fields?
0
Rawkers
Hello Jacob,
Thanks for your quick answer!
Both fields are multi-select.
What I would like to do is to check the field A value and set field B to a value depending on A result. Basically, they are three choices for field B.
(and field B could I guess be switched to a drop-down type field if that is more convenient for Liquid)
0
Jacob the Moderator
Rawkers Both multi-select and drop-downs use tags, so you can create triggers per value you want to set, like:
Alternatively, you could use a trigger and webhook, and have liquid markup do the value checking for field A and setting field B based on that, but if the first option is a fit, I would go that route.
1
Rawkers
Hello Jacob,
Thanks for your message.
I was not aware that adding the tag would set the field to the corresponding value. I thought it was only the other way around so yup, I could setup everything using triggers and tags :)
All sorted now, thanks again for your help!
0
Michael Webb backup
Hi,
I'm currently attempting to assign to the ticket.tags placeholder corrected text for one of the tags via liquid implementation to webhook.
{% assign cloned_tags = ticket.tags %}
{% assign tags_without_text = cloned_tags | remove: ":clone" %}
{% assign ticket_tags = tags_without_text%}
{%assign ticket.tags=tags%}
{{tags_without_text}}
{{tags}}
{{ticket.tags}}
Barring the {{ticket.tags}} the other placeholders do correctly display all tags with all instances of :clone being removed thought it is the final one that I really want to change as that actually impacts the tickets
I understand that I need to get this all in one line for a webhook but all of my attempts have been fruitless. Does anyone know how to format this in such way that it can be properly pushed to JSON, work and alter the {{ticket.tags}} placeholder
0
Carmelo Rigatuso
Hi,
I'm having trouble with evaluating the value of a decimal field. No matter what I do, if I try to compare a value, it only evaluates on the first digit, so
I've tried a couple of ways, doesn't matter:
{% if {{ticket.ticket_field_123}} < '3000.00' %}
{{ticket.ticket_field_123}} is less than $3000.
{% endif %}
{% if {{ticket.ticket_field_123}} > '3000.00' %}
{{ticket.ticket_field_123}} is greater than $3000.
{% endif %}
Or
{% assign totalvalue=”{{ticket.ticket_field_123}}" %}
{% for totalanswer in totalvalue in %}
{% if totalanswer > '3000' %}
{{ totalanswer }} is greater than $3000.00.
{% endif %}
{% if totalanswer < '3000' %}
{{ totalanswer }} is less than $3000.00.
{% endif %}
{% endfor %}
both evaluate to > 3000 if my first digit is greater than 3.
Why?!?! How do I get around this?!?!
0
Walter
Hi Carmelo Rigatuso,
It depends on what type of custom ticket field ticket.ticket_field_123 is.
https://support.zendesk.com/hc/en-us/articles/4408838961562-About-custom-field-types
0
Carmelo Rigatuso
Hi Walter,
It's a decimal field, but I'm not sure what that has to do with comparison operations. 4 or 4.0 should never evaluate to greater than 3000.
0
Walter
Hi Carmelo,
It looks like the number is being treated as a string.
Try this instead.
{% if {{ticket.ticket_field_123}} < 3000.00 %}
{{ticket.ticket_field_123}} is less than $3000.
{% endif %}
0
Carmelo Rigatuso
Walter
When I try that, I get no errors when saving my trigger, but I get an error in the email notification:
BUT!!! double-quotes fixes it!
{% if {{ticket.ticket_field_123}} < "3000.00" %}
{{ticket.ticket_field_123}} is LESS THAN $3000.
{% endif %}
{% if {{ticket.ticket_field_123}} > "3000.00" %}
{{ticket.ticket_field_123}} is greater than $3000.
{% endif %}
Wow, that was a wild ride, thanks for the inspiration ;) I can't believe I didn't think of trying that yesterday.
1
Hannah Lucid
Hello,
Is there a way to highlight text using liquid markup? We want to highlight text in our Macros to help callout important information to our end-users (if they read nothing else, at least they'll read this). Is this possible? If so, how?
0
Mike DR
Did a thorough search on this and didn't see a liquid mark up here for highlights: Liquid for Designers.
0
Hannah Lucid
Mike DR I had a feeling that would be the case. I looked EVERYWHERE for something. Thank you for your confirmation Mike!! Have a great day.
0
Mike DR
You're most welcome and have an awesome day ahead too!
0
Oliver Atkinson
Hello,
Is it possible to change requesters based on the ticket subject using a combination of triggers and liquid markup/webhooks?
I'd use a webhook + automation combination but ideally, we'd need the requester to change immediately rather than wait the 1-hour increment.
The use case is so we don't have to manually change requesters from a no-reply address.
It's trying to create a solution to this question. Any assistance would be greatly appreciated!
0
Dainne Kiara Lucena-Laxamana
Hi Oliver!
Greg one of our developers created a workflow guide here that could serve helpful. Hope it helps!
0
Andy F.
Hi Zendesk community! I have a question about using Liquid Markup with Zendesk ticket tags. I've set up A/B testing in our instance (as described in this article: https://ro.roca.work/blog/ab-testing-in-zendesk) and so far, it's mostly been working for us. However, I just identified a scenario that I can't figure out how to solve.
To summarize, every ticket that is created gets assigned either the control or experiment tag. The problem occurs only sometimes with tickets created as followups, as it's possible for a ticket to carry over the previous tags, like control, but then get assigned the experiment tag by the webhook. How would I use liquid markup in this JSON response to tell it not to fire if a ticket already has the control or experiment tag?
{% assign randomizer = ticket.id | modulo:2 %}
{% case randomizer %}
{% when 0 %}
{“ticket”: {“additional_tags”:[“control”]}}
{% when 1 %}
{“ticket”: {“additional_tags”:[“experiment”]}}
{% endcase %}
Thanks in advance for the help!
0
Rafael Santos
Andy F. , I'd use the
PUT /api/v2/tickets/{ticket_id}/tags
endpoint instead ofPUT /api/v2/tickets/update_many
, as the latter creates a background job, which may be rate limited to 30 concurrent jobs for the entire instance.You could use the Add Tags endpoint, as mentioned above, with a payload such as the following:
As for your other question:
The following trigger conditions could help you exclude this from firing on follow-up tickets with the tags:
Of course, it'll depend on your specific use case. You could also try iterating over the
{{ticket.tags}}
placeholder and use Liquid'scontains
.2
Andy F.
Rafael Santos ah of course! I was overthinking this, believing I had to add the exclusion to the JSON when of course I can just add it to the main trigger. Thank you!
0
Dylan Tragjasi
Does anyone know if the ticket form object is accessible when using liquid markup? I'm trying to create a macro with different content depending on the current form selected on the ticket. I've tried many variations of the following but can't seem to get it to work:
Using the ticket.ticket_form placeholder doesn't seem to work either. Any advice? Thank you!
0
Jacob the Moderator
Hi Dylan Tragjasi
Aside from using the end user form name, it looks like you're missing part of the form name placeholder.
Try and see if the below works for you.
{% if ticket.ticket_form == "Form 1" %}
Hello
{% elsif ticket.ticket_form == "Form 2" %}
World
{% endif %}
1
Dylan Tragjasi
Thanks Jacob the Moderator - I had a feeling this was going to be the solution but for some reason preferred to bash my head against a wall for a while. This works great, thank you for the help!
1
Viktor Hristovski
Is it possible to use liquid markup in zendesk on the new object type (custom objects) Thank you
0