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, 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 ticket 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. This isn't supported for messaging triggers.
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?
65 comments
Hannah Lucid
Hi! Thank you so much!! I'm still having a bit of trouble so I'm going to share the full code I've been using. The code below doesn't populate anything but a “-”. I'm sure it has something to do with the {% when nil %} line, but when I try changing the statement to {% if ticket.ticket_field_option_title_XXXX = blank/nil/null/empty %} it doesn't do anything.
Any feedback/suggestions are appreciated.
0
Daniël Nieuwendijk
Can you try it with lowercase “null”:
0
Jacob the Moderator
5174506379034
Possibly…
{% if field_name != blank %}
0
Walter
Hi 5174506379034 ,
Try “nil” or “empty” instead of “NULL”
0
Hannah Lucid
Hey There,
It's me again! I was wondering if anyone knows how to use liquid markup when a text field is blank. I've tried using statements like != ‘-’ or != NULL , etc. but I'm struggling to figure it out. Is this possible? If so, how would I achieve this?
Basically, we are using webhooks to update subject lines when a specific topic is selected. I wanted to keep the double dash (TOPIC NAME - -) when the text field is blank so it will look cleaner, like (TOPIC NAME).
Thank you so much!
0
Viktor Hristovski
Is it possible to use liquid markup in zendesk on the new object type (custom objects) Thank you
0
Dylan Tragjasi
Thanks 1263169425010 - 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
Jacob the Moderator
Hi 4821761052186
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
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
Andy F.
4453309851418 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
Sign in to leave a comment.