Articles in this section
Category / Section

How to Use Liquid in BoldDesk to Build Dynamic Conditional Content

Published:
New

BoldDesk offers Liquid support for generating dynamic content in email notification templates, canned responses, and webhook request bodies.

Liquid is a popular template language that is widely used in web development. It provides flexibility for creating custom content. The key feature of Liquid, is its ability to handle conditional logic and looping, making it an excellent choice for building dynamic content. In addition, it offers a wide range of filters for manipulating data and formatting outputs.

Getting Started

To get started with Liquid, users should familiarize themselves with the syntax, including tags and filters that are used to create dynamic content. Here are some basic tags and filters:

Output expressions (aka) Placeholders

Variables are denoted by curly braces and are used to insert dynamic content into templates.
For example, {{contact.name}} would insert the name of the customer.

Control Structures

Control structures are used to control the flow of content in templates. Some basic control structures include:

If statements

Use the If statement(s) to conditionally include content in a template.

{% if contact.name == "Jack" %}
 Hey Jack!
{% else %}
 Hi Stranger!
{% endif %}

Unless statements

Use the Unless statement(s) to conditionally exclude content in a template.

{% unless ticket.title == "An Average day" %}
 Hey!!! Its, an awesome day.
{% endunless %}

Case statements

Use the Case statement(s) to compare a variable to a set of values and output different content based on the match.

{% case helpdesk.brand.name %}
 {% when "Brand 1" %}
   Regards from Brand 1.
 {% when "Brand 2" %}
   Regards from Brand 2.
 {% else %}
   Regards from Organization
{% endcase %} 

Loops

Use loops to repeat content in templates. Some basic loops include:

{% for i in (1..5) %}
 Hey!!! its number - {{ i }}
{% endfor %}

Filters

Use filters to modify variables in templates. Some basic filters include:

Capitalize

Use the Capitalize filter to capitalize the first letter of a string.

{{ ticket.title | capitalize }}

Downcase

Convert a string to lowercase using the Downcase filter.

{{ ticket.title | downcase }}

Upcase

Convert a string to uppercase using the Upcase filter.

{{ ticket.title | upcase }}

FAQ

  1. How do you use the error line number details mentioned in the error message?

    1. Copy and paste the source html in a text editor.
    2. Track the error location mentioned in the error message.
  2. Why am I still getting an error message despite the content and syntax looking correct?

    1. Check on whether all opening and closing brackets and sequences are properly added.
    2. Check whether the syntax is correct.
    3. Remove any multiple spaces used in Liquid syntax. Note, you are only allowed to use one space.

Note:
We are yet to support Liquid tag (a specific tag in Liquid) in BoldDesk.

{% liquid
   case helpdesk.brand.name
   when "Brand 1"
       Regards from Brand 1.
   when "Brand 2"
       Regards from Brand 2.
   else
       Regards from Organization
   endcase 
%}

Reference

Liquid template language (shopify.github.io)

Sample usage of liquid template in BoldDesk using ticket category

In the below “Ticket Replied” email template, if the ticket’s category is “Website”, the first content will be sent in the email else the second content will be sent in the email.

liquid_template.png

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied