Using Liquid markup to support multiple languages in automations, macros, and triggers (Professional and Enterprise)

Have more questions? Submit a request

12 Comments

  • Thomas Joussot
    Comment actions Permalink

    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 ?

    1
  • Adam Reid
    Comment actions Permalink

    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?

    0
  • Adam Reid
    Comment actions Permalink

    This is currently what I'm using and it's returning only the last else.

    {% case ticket.requester.language %}

    {% when 'Japanese' %}

    Ciao {{ticket.requester.first_name}} - Japanese

    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 'Spanish' %}

    Hej {{ticket.requester.first_name}} - Spanish

    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 %}
    0
  • Brett - Community Manager
    Comment actions Permalink

    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!

    0
  • Adam Reid
    Comment actions Permalink

    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.

    0
  • Brett - Community Manager
    Comment actions Permalink

    Happy to help Adam :)

    0
  • David Seinsche
    Comment actions Permalink

    "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. 

     

    0
  • Amauri Souza
    Comment actions Permalink

    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:

    {
    "msg": "{{ticket.title}} received from {{ticket.requester.name}}",
    "comentarios": "{{ticket.comments}}",
    "anexos": [

    {% for comment in ticket.comments %}
    {% unless forloop.last %}
    "anexo": "{{comment.attachment.url}}",
    {% endunless %}
    {% if forloop.last %}

    "anexo": "{{comment.attachment.url}}"

    {% endif %}
    {% endfor %}

    ]}

    It just doesn't send the data and I can't see what errors occurs



    0
  • Andreas Schuster
    Comment actions Permalink

    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.

    0
  • Amauri Souza
    Comment actions Permalink

    Hi, thank you for your reply!

    I solved the problem with the following code:

    {
    "msg": "{{ticket.title}} received from {{ticket.requester.name}}",
    "comentarios": [
    {% for comment in ticket.comments %}
    {% unless forloop.last %}
    {
    "authorName": "{{comment.authorName}}",
    "value": "{{comment.value}}",
    "anexos": [
    {% for attachment in comment.attachments %}
    {% unless forloop.last %}
    {
    "url": "{{attachment.url}}",
    "fileName": "{{attachment.filename}}"
    },
    {% endunless %}
    {% if forloop.last %}
    {
    "url": "{{attachment.url}}",
    "fileName": "{{attachment.filename}}"
    }
    {% endif %}
    {% endfor %}
    ]
    },
    {% endunless %}
    {% if forloop.last %}
    {
    "authorName": "{{comment.authorName}}",
    "value": "{{comment.value}}",
    "anexos": [
    {% for attachment in comment.attachments %}
    {% unless forloop.last %}
    {
    "url": "{{attachment.url}}",
    "fileName": "{{attachment.filename}}"
    },
    {% endunless %}
    {% if forloop.last %}
    {
    "url": "{{attachment.url}}",
    "fileName": "{{attachment.filename}}"
    }
    {% endif %}
    {% endfor %}
    ]
    }
    {% endif %}
    {% endfor %}
    ]
    }
    1
  • Dan Cooper
    Comment actions Permalink

    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: 

    {
    "msg": "{{ticket.title}} received from {{ticket.requester.name}}",
    "comentarios": "{{ticket.latest_comment}}",
    "anexos": [

    {% for comment in ticket.comments %}
    {% for attachment in comment.attachments %}
    {% unless forloop.last %}
    "anexo": "{{attachment.url}}",
    {% endunless %}
    {% if forloop.last %}
    "anexo": "{{attachment.url}}"
    {% endif %}
    {% endfor %}
    {% endfor %}
    ]}

    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. 

    1
  • Amauri Souza
    Comment actions Permalink

    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.

    0

Please sign in to leave a comment.

Powered by Zendesk