Liquid filters are a secure, customer-facing template language for flexible web applications that allow users to edit the appearance of an application without running insecure code on your server. Liquid uses a combination of tags, objects, and filters inside Liquid template files, to load dynamic content. 

Liquid Filters in Freshservice

With liquid filters in Freshservice, you can customize placeholder values in the workflow automator such as notes, webhooks, app actions, emails, etc. as per the requirements of the third-party web applications used. 

This allows you to perform a number of String, Numerical and Date operations on the placeholder values. 

An exhaustive list of Liquid Filters can be found here.

Here are few more examples of some of the popular Liquid filters in action:

Example 1: Substrings

1.1 Create User 'Vishal Abraham' as '' in Azure AD - You can use the liquid filter

{{ticket.ri_49_cf_employee_first_name | first}} {{ticket.ri_49_cf_employee_last_name }}

1.2 To extract the first 3 letters from a string using the truncate filter

{{ticket.ri_49_cf_employee_first_name | truncate:3 ,''}}

Example 2: 
Create a Slack Channel with the Ticket ID for example as inc-123. 

The challenge here is that Slack only accepts lowercase formats for channel names so the Ticket ID will need to be converted using the downcase liquid filter

{{ | downcase}}

Example 3: 

Perform a simple multiplication of a Cost and Quantity using the times filter.

{{ticket.quantity | times: ticket.cost}}

Example 4: 

Extract the nth term from a blob of text using the split filter. 

{% assign value = {{A2.meta.system_message}} | split: ' ' %}{{value[n-1]}}

Example 5

Extract the nth term from a comma-separated list of values using the split filter

{% assign value = {{ticket.associated_asset_names}} | split: ',' %}{{value[n-1]}}

Example 6: 

Create an event for Google Calendar

For this event creation, the date-time format has to be changed to an RFC 3339 compliant format i.e, 2021-02-01T09:00:00.

This can be done using the date liquid filter

{{change.planned_start_date | date: '%Y-%m-%dT%H:%M:%S'}}

Example 7

Sanitize HTML content using sanitize_html Liquid Placeholder

Use the sanitize_html liquid filter to treat HTML placeholders so that they can be used within the body of an API request without an invalid JSON error being thrown.

For example:

{{ticket.description}}  returns

"<div style='font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif;'>\n<div>This is test.</div>\n</div>"

{{ticket.description | sanitize_html}}  returns

"<div style='font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, \\\"Segoe UI\\\", Roboto, \\\"Helvetica Neue\\\", Arial, sans-serif;'>\\n<div>This is test.</div>\\n</div>"

And thus can be used within the body of an API request.