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:
100 Comments
Hi Raman Kalia,
Sorry I missed to respond on your comment.
I just have follow up question on that.
How can I copy the value of that field to another field without me manually typing the value?
Like {{ticket.field1}} = {{ticket.field2}}
Hey Donald,
I believe you could also set this up by using a URL Target if you're unable to get this through liquid markup.
You would first need to grab your custom field ID's, then create a target using the following URL: https://yoursubdomain.zendesk.com/api/v2/tickets/{{ticket.id}}.json?ticket[custom_fields[fieldID2={{ticket.ticket_field_fieldID1}}.
FieldID2 is the field you're copying to.
FieldID1 is the field you're copying from.
Set the method to PUT as shown in my screenshot below:
You can then set up a trigger to look similar to the following:
I tested this on my account and it does copy the data from my custom text field to another custom text field.
I hope this gets you what you're looking for!
Hi Brett I am using two custom fields, the source is a dropdown while the destination is a text.
Here's my target url: https://mydomain.zendesk.com/api/v2/tickets/{{ticket.id}}.json?{{ticket.ticket_field_900005248766}}={{ticket.ticket_field_option_title_360027440631}}.
I have followed your steps, but the target doesn't fire for me.
Hey Donald,
Could you try using this target URL instead?
https://mydomain.zendesk.com/api/v2/tickets/5642019.json?ticket[custom_fields[900005248766={{ticket.ticket_field_option_title_360027440631}}
It looks like the above worked on my account.
Let me know if you run into any issues.
Thanks!
Hi there. I'm using Liquid in my macro, but I can't figure out how to check if a chekbox is checked.
I tried things like fieldID[checked] or fieldID.checked : {% if ticket.ticket_field_360016124819[checked] %}
Thanks in advance for your help !
Hey Anais,
As far as I know, Liquid can't check field states that way. In this case, try making sure your checkbox field applies a tag when checked and then test for the presence of that tag. If it's there, the field is checked, otherwise it's not.
Something like this might help get you started.
Dan Ross
Thank you so much Dan for your prompt assistance.
Indeed, it works with the tag.
You saved my day !
This should also work, because a checkbox is true if it is checked.
Hi Daniel !
Thanks for your suggestion.
I gave it a try but I couldn't make it work.
Have you ever used it ?
My understanding is that unlike a client side language like javascript, Liquid retreives server side information but does not access to DOM element and this would explain why it can't tell if a checkbox is checked or not.
I hope someone could confirm this.
Using a tag as Dan Ross suggested is the standard supported way.
Please sign in to leave a comment.