Liquid Markup: An overview of common uses in Zendesk.

If you've encountered placeholders in Zendesk Support, you've already had a brush with Liquid markup. This templating language is what makes placeholders in Zendesk functional, acting as dynamic containers for ticket and user information across automations, macros, targets, triggers, and SweetHawk apps. Beyond simple data insertion, Liquid markup offers the flexibility to tailor data presentation and selection with basic programming constructs like case and if statements, as well as for loops, enhancing your customization capabilities.

Below we've listed out examples of common things you may find yourself needing to do in Zendesk. 

Changing date format

Math functions

Conditionality (if statements)

Splitting

Looping

 

 

Did you know...

You can find and test out any liquid that you produce in real time using the free Liquid Placeholders app that you can install here

Liquid markup can be used to build flexible workflows using a multitude of SweetHawk apps including Tasks and sub-tickets, Approve, Timers, Calendar, Notify and more!

 

Changing a date format:

There are many reasons why you might need to change the format of a date in Zendesk. Perhaps you're needing to sort a view by date, or you're wanting to communicate a date to a customer in a readable manner.

To modify a date you can use filters to modify the output of a placeholder. Using a filter entails placing in the pipe before the end of the placeholder and then stating the date format you want to see it in like this:

{{ ticket.updated_at | date: "%B %d, %Y" }}

Output: February 28, 2023

This will display the tickets' updated date in the format of "Month Day, Year". For more on what liquid can do with dates see this article: Liquid markup for date and ticket

 

Math functions:

Liquid Markup allows you to manipulate data in Zendesk placeholders to display information in a specific format or combine the data using basic math functions like addition, subtraction, multiplication, and division. For example, you might use Liquid Markup to calculate the total cost of a support request based on the quantity and price of a product.

An example of what this might look like is:

{{ticket.ticket_field_001 | times: ticket.ticket_field_002}}

...whereby times = multiplied by and ticket field 001 contains the quantity number, and ticket field 002 contains the price. 

Other math functions on the same data would be:

Addition:

{{ticket.ticket_field_001 | plus: ticket.ticket_field_002}}

Subtraction:

{{ticket.ticket_field_001 | minus: ticket.ticket_field_002}}

Divided by:

{{ticket.ticket_field_001 | divided_by: ticket.ticket_field_002}}

 

Conditionality:

You can also use Liquid Markup to conditionally display data. This is useful when you want to display different information depending on the value of a ticket field or user attribute. The if statement allows you to specify a condition that must be met before displaying the content inside the block. For example:

{% if ticket.status == 'open' %}
  This ticket is open.
{% else %}
  This ticket is not open.
{% endif %}

This will display "This ticket is open" if the ticket status is "open", and "This ticket is not open" if the ticket status is anything else. For more details on if statements see this article: Liquid Markup if statements for Zendesk.

 

Splitting:

Splitting allows you to take a series of information and make it appear differently. For example, you might have a text field that contains a series of things separated by a comma. The SweetHawk Tasks app does this behind the scenes to track the remaining tasks you have on a ticket. Rather than updating the customer with a list of remaining tasks that looks like this:

Ticket__Basic_support_implementation_for____SweetHawk____Zendesk.png

You could use the following liquid to split out the comma separated values into dot points. The liquid would look like this:

{% assign tasksremaining = ticket.ticket_field_81189288 | split: "," %}
{% for task in tasksremaining %} • {{task}}
{% endfor %}

And the customer would see this instead: 

Ticket__Basic_support_implementation_for____SweetHawk____Zendesk.png

 

Looping:

You can also use Liquid Markup to loop through lists of data, such as comments or custom fields. The for loop allows you to iterate over a list and perform an action on each item. For example:

{% for comment in ticket.comments %}
  {{ comment.author.name }} said: {{ comment.value }}
{% endfor %}

This will display each comment author's name and their comment text.

 

For a general overview of how placeholders work in with liquid markup, watch this video: 

 

 

Much more:

In addition to these examples, there are many other ways to manipulate data in Zendesk placeholders using Liquid Markup. You can find out more in this comprehensive reference. By understanding the syntax and available filters, you can customize your Zendesk tickets and views to display the information you need in the format you want.

Additionally, here's an explanation of Liquid markup on the Zendesk knowledge base


Was this article helpful?
1 out of 1 found this helpful

Comments

0 comments

Please sign in to leave a comment.