How to Use Liquid in BoldDesk to Build Dynamic Conditional Content
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!!! It's 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!!! It's 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 }}
Adding Tomorrow’s Date
Adds tomorrow’s date in the canned response.
{{ 'now' | date: '%s' | plus: 86400 | date: '%d.%m.%Y' }}
{{ticket.source}}
BoldDesk supports Liquid templating, allowing the use of operators like contains to perform substring checks within templates. You can use it in conditions like:
{% if ticket.title contains "Onboarding" %}
...
{% endif %}
This can be used to dynamically control content or actions based on ticket data (for instance, checking if a ticket title includes a specific keyword). Ensure proper Liquid syntax and spacing to avoid errors during template execution.
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.
We are yet to support Liquid tag (a specific tag in Liquid) in BoldDesk. Explore Liquid template language (shopify.github.io).
{% liquid
case helpdesk.brand.name
when "Brand 1"
Regards from Brand 1.
when "Brand 2"
Regards from Brand 2.
else
Regards from Organization
endcase
%}
Troubleshooting Liquid Template Errors
Use the error line number
If BoldDesk shows an error with a line number:
- Copy the full template source (for example, the HTML).
- Paste it into a text editor.
- Go to the referenced line number to locate the invalid Liquid expression or tag.
Errors even when the syntax looks correct
- Verify every
{% if %}has a matching{% endif %}, every{% case %}has{% endcase %}, and every{% for %}has{% endfor %}. - Confirm the Liquid syntax is valid.
- Remove extra spaces inside Liquid syntax. Only one space is allowed.
Frequently Asked Questions
-
Where can I use Liquid in BoldDesk?
Liquid is supported in email notification templates, canned responses, and webhook request bodies. -
Can I use conditions like “contains”?
Yes. BoldDesk supports operators likecontainsin Liquid conditions. -
Why does BoldDesk show a line-number error?
The error line number points to where Liquid parsing failed. Paste the template into a text editor and navigate to that line to find the invalid tag, filter, or expression. -
Why am I getting an error even though the Liquid looks correct?
Common causes are missing closing tags (like{% endif %}), invalid syntax, or extra spaces inside Liquid syntax. -
Is the
{% liquid %}tag supported?
No. BoldDesk does not support the Shopify{% liquid %}tag. Use standard Liquid tags (if,case,for, etc.).