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 atLiquid 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 equateoutputwithplaceholder, 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 asfilters. 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 notification 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?
47 Comments
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:
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 %}
Have you tried to wrap the string in single quotes rather than double?
HiGreg 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 %}
和分配的变量没有得到任何价值e.
Therefore, I can safely assume that the following expression
{% ifticket.brand.namecontains 'Jameson' %}
will result in an error because it is the same thing as
{% if NULL contains 'Jameson' %}
HiTatiana Ozaruk
Have you tried using case statements instead?
HiTatiana 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.
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!
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?
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)
RawkersBoth 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.
Hello Jacob,
Thanks for your message.
我不知道添加标签设置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!
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
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 %}
或
{% 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?!?!
HiCarmelo Rigatuso,
It depends on what type of custom ticket fieldticket.ticket_field_123is.
https://support.zendesk.com/hc/en-us/articles/4408838961562-About-custom-field-types
HiWalter,
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.
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 %}
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.
Pleasesign into leave a comment.