Liquid markup is commonly used in business rules to customize comments and email notifications. Many companies and organizations support end-users who speak languages other than English and there are a number of ways to manage this.
To set up multiple language support, see Adding multiple languages to Zendesk Support.
In the example below, a case statement is used to determine what response is sent to the end-user based on their language setting. The email body of the Notify requester of received request trigger contains the following Liquid markup:
{% case ticket.requester.language %} {% when 'Italiano' %} Ciao {{ticket.requester.first_name}} La tua richiesta (#{{ticket.id}}) è stata ricevuta, è stato esaminato dal nostro staff di assistenza. Per esaminare lo stato della richiesta e aggiungere ulteriori commenti, segui il link qui sotto: http://{{ticket.url}} {% when 'Danish' %} Hej {{ticket.requester.first_name}} Din anmodning (# {{ticket.id}}) er blevet modtaget og bliver gennemgået af vores supportmedarbejdere. At gennemgå status for anmodningen og tilføje yderligere kommentarer, skal du følge nedenstående link: http:// {{ticket.url}} {% else %} Hello {{ticket.requester.first_name}} Your request (#{{ticket.id}}) has been received, and is being reviewed by our support staff. To review the status of the request and add additional comments, follow the link below: http://{{ticket.url}} {% endcase %}
The language preference is set in the user's profile. Language support is defined by an administrator (on the Localization tab of the Account page). See Language codes for Zendesk supported languages to get the corresponding language property value for each of the languages available on that page.
In this example, we could have also explicitly declared the English text like the others ({% when 'English' %}). However, if the default language is English it's not necessary. The English text will be displayed to all users who have not otherwise chosen a language setting.
As you can imagine, you can use something like this for any number of reasons, not just to support multiple languages. For example, maybe you want custom responses for users in different organizations for some reason. If so, you use ticket.organization.name in a case statement like this.
For more information on how Liquid markup can be used, see Understanding Liquid markup and Zendesk Support.
18 Comments
This might sound like a dummy question but is there any advantage using Liquid markup in such a case instead of Dynamic Content when dealing with multiple langages ?
Hi Aimee,
Thanks for this wonderful example with Liquid markup. I've tried using your example but it always defaults to the last else statement.
Are you using the short or long versions of the language codes?
This is currently what I'm using and it's returning only the last else.
Hey Adam,
It looks like when specifying the locale name you need to do so in the local language. For example, Danish would be Dansk. If you take a look at the following comment by one of our community members it looks like you can capture this information using the API: Understanding Liquid markup and Zendesk Support
Additionally, you may want to look into using Dynamic Content to provide multiple language support. This wouldn't require you to set up multilingual support via Liquid Markup and may save you a bit of a headache down the road.
Hope this helps!
Hey Brett,
Thanks for your reply. That example worked perfectly. After running the API call I got these outputs and was able to grab the exact keyword to match.
Happy to help Adam :)
"It looks like when specifying the locale name you need to do so in the local language." -> This should be included in the example written by Aimee Spanier to avoid confusion and frustration.
Hi,
how can I use liquid to build a json with a ticket data, such as attachments and URL?
I tried to do so with the following code, but it did not work:
It just doesn't send the data and I can't see what errors occurs
Hi Amauri Souza,
You could embed the code into a macro, which will execute it.
After that please share the content so that we can see if it's valid JSON.
Hi, thank you for your reply!
I solved the problem with the following code:
Edit: You beat me to it. Congrats on finding a solution and thanks for sharing!
It appears that you are trying to iterate through your comment and display all of the article attachments as part of the body. This article shows how you could parse out individual attachments from a comment to clean up your liquid markup logic.
I took a stab at making this work but made an assumption about only sending the last comment as everything was blending together without spacing when I used your original ticket.comments placeholder. You might need to adapt the logic here:
I didn't quite get this fully working before running out of time to dive into this, but one thing I noticed is that the logic I'm working through is parsing through attachments on all comments, so the unless statements aren't working right here to apply the commas in the right place because I'm still iterating through each comment so the for loop is resetting each time. So that will have to be shored up, but I can get all of the urls this way. It needs a bit more work, but I'm seeing these expand in a JSON body trigger to target test so I think it might give you some ideas on how to proceed with liquid and placeholder adjustments.
Thank you anyway, it's great to know that I can count on guys like you and Andreas that helped with great information. I will probably have more doubts future.
Amauri Souza Just adding a couple of things.
First, you can avoid some duplication of code by wrapping an "unless" block around only the commas inside the "for" loops:
Second, "comment.authorName" isn't a valid placeholder, but the "comment.author" is a full user object so you have access to all the user properties. That means you can use "comment.author.name", as well as other properties like "first_name", "last_name", "email", "id", etc.
According to the Liquid documentation, there are these filters:
Unfortunately, none of them seems to work within Zendesk, what are we missing here?
Kind regards,
Oliver
Oliver Tietze
Were you able to find an answer to the missing filters using Liquid?
Hi all! At Zendesk, we are accessing the open source Liquid project that Shopify has graciously provided to the community. If you check the link that I provided, the filters that you're accessing are not available through the open source project and thus we do not have access to them. The link that shows the properties is directly connected to the Shopify API, which clearly has a more robust feature set.
You could make a request on their Github repo to add that functionality into the open source project, but that is the reason that it currently does not work here.
Greg - Community Manager
Thanks for letting us know.
I have requested that they bring some of their more useful filters over to the main language.
https://github.com/Shopify/liquid/issues/1253#issue-622785461
Great, thanks for doing that!
Greg Katechis | Developer Support and Enablement Engineer
Please sign in to leave a comment.