Understanding Liquid markup and Zendesk Support

Return to top

41 Comments

  • Support Department

    I have added links to KB articles in automated replies to customers. But I never know if the requester clicked the link.

    Is there any way or trick with liquid to find out whether this link has been clicked (viewed) by the customer?

    0
  • Austin Killey
    Zendesk Customer Care

    Hey there@...,

    Really great question about using Liquid to track article link views. Sadly, Liquid markup tends to work best mostly as a visual language that'll change text appearance based on certain conditions, so we may be out of options for tracking link activity that way,but:

    For tracking link views, using something likeAnswer Botwould be perfect, as articles suggested by Answer Bot are able to have their activity tracked, including link views. When Answer Bot suggests articles to the ticket requester, ticket events will be generated to let you and your agents know that the requester has actually viewed those articles, where the requester may have also marked if those articles were helpful or not:

    Otherwise if you'd prefer to track only specific article links that you've embedded in your automatic replies rather than go off of suggested Answer Bot articles,enabling and integrating Google Analyticslooks to be pretty promising, where you could possibly add some event listeners in your help center to track a visitor's "referrer URL" and get a better picture of where your KB article views are being redirected/referred from.

    Hope this helps!

    0
  • Support Department

    Hi Austin,

    Thank you for the answer. In our case we have some specific article links embedded and which show up when typical keywords are in the request (used liquid for that).

    Haven't tried Google Analytics yet, but will do so. Is this the only option?

    Would there also be a HTML option (e.g. an embedded button which 'fires' some actions when clicked by the requester)?

    0
  • Allen Lai | Head of CX, Otter.ai

    Sometimes we may solve a ticket without assigning it to an actual agent. In that case, we don't want to insert a blank name in our c-sat trigger. If I understand liquid, I would insert this into the email body within the automation:

    {% if ticket.assignee.first_name == nil %}

    our team

    {% else %}

    {{ticket.assignee.first_name}}

    {% endif %}

    Hi {{ticket.requester.first_name}},

    We care about your experience with our Customer Support team. We'd love to hear your thoughts about your experience with {{ticket.assignee.first_name}} in helping you with your request. Please take a moment to answer one simple question by clicking either link below:

    {{satisfaction.rating_section}}

    0
  • Dean Kongslie
    Community Moderator

    Hey Team!

    We have a trigger that we are using to set the subject of a ticket. I have 3 custom fields that we evaluate and depending on null / not null values in each field we have a slightly different subject.

    Can anyone evaluate my Liquid code as it does not actually update the subject even though the trigger is firing.

    {"ticket":
    {"subject": "{% if ticket.ticket_field_360041372052 != null and ticket.ticket_field_360044340271 != null and ticket.ticket_field_360041327151 != null %}Order Follow Up - {{ticket.ticket_field_360041372052}} - {{ticket.ticket_field_360044340271}} - {{ticket.ticket_field_360041327151}}}{% endif %}
    {% if ticket.ticket_field_360041372052 != null and ticket.ticket_field_360044340271 != null and ticket.ticket_field_360041327151 == null %}Order Follow Up - {{ticket.ticket_field_360041372052}} - {{ticket.ticket_field_360044340271}}}{% endif %}
    {% if ticket.ticket_field_360041372052 != null and ticket.ticket_field_360044340271 == null and ticket.ticket_field_360041327151 == null %}Order Follow Up - {{ticket.ticket_field_360041372052}}}{% endif %}
    {% if ticket.ticket_field_360041372052 != null and ticket.ticket_field_360044340271 == null and ticket.ticket_field_360041327151 != null %}Order Follow Up - {{ticket.ticket_field_360041372052}} - {{ticket.ticket_field_360041327151}}{% endif %}
    {% if ticket.ticket_field_360041372052 == null and ticket.ticket_field_360044340271 == null and ticket.ticket_field_360041327151 != null %}Order Follow Up - {{ticket.ticket_field_360041327151}}{% endif %}
    {% if ticket.ticket_field_360041372052 == null and ticket.ticket_field_360044340271 != null and ticket.ticket_field_360041327151 != null %}Order Follow Up - {{ticket.ticket_field_360044340271}} - {{ticket.ticket_field_360041327151}}{% endif %}
    {% if ticket.ticket_field_360041372052 == null and ticket.ticket_field_360044340271 != null and ticket.ticket_field_360041327151 == null %}Order Follow Up - {{ticket.ticket_field_360044340271}}{% endif %}"
    }
    }
    1
  • Austin Killey
    Zendesk Customer Care

    Hey thereDean Kongslie!

    Super solid chunk of Liquid there - thanks so much for sharing. The syntax & formatting seems solid so far from what I can see..

    With the trigger firing, do you happen to see any target failures showing up for your ticket-focused target inyour Target Failures tab here?

    Triggers can still run and notify their targets, but you and I will just need to make sure these subject payloads are being accepted by our API. If yousee any failures for your target or if you do but aren't sure what the target failures mean, let me know and I can spin up a ticket to work on this more closely together.

    Thanks again Dean - let us know if you need anything else!

    0
  • Dean Kongslie
    Community Moderator

    Austin KilleyI was actually able to figure this one out a moment ago. I realized that it was because I had page breaks to make for clean code. I needed to have the entire subject code on a single line so the JSON would push correctly.

    I do have another question though. On a related trigger I have I am hitting the same webhook which is a PUT to the endpoint /api/v2/tickets/{{ticket.id}}.json and sending some liquid code through. The custom field is a checkbox and I want to evaluate if it is true or false. The issue is when I input {% if ticket.ticket_field_4412877472404 %} it always evaluates to true. Is there something with checkboxes I need to know about?

    0
  • Austin Killey
    Zendesk Customer Care

    Dean Kongslie- that's awesome! Good catch on the line breaks throwing off the Liquid output.

    Really good question as well: With thatIFcondition, we'd be evaluating whether or not there's any value present for your checkbox field. With checkboxes that are active and applied to a ticket, they can only be true or false (1 or 0), so with either of those values present at all times, yourIFstatement will always return true.

    With that in mind, feel free to copy this if/else condition below and use as you see fit! Quick heads up that this snippet also has line breaks to make it look nice and neat, so when you're ready to use this in your payload, you can combine this all into a single line just like your ticket subject markup.

    {% if ticket.ticket_field_contains 0 %}
    checkbox is unchecked {% else %} checkbox is checked {% endif %}
    0
  • Dean Kongslie
    Community Moderator

    Austin Killeythank you very much. I had tried something similar, but I didn't realize I needed to do contains 1 or 0 since the JSON reads true or false.

    I appreciate your help.

    0
  • William Grote

    Dean Kongslie

    I'm trying to figure out a way to have a trigger change the subject line of a ticket right after it has been submitted so that is updates to a standard format with the selected values from 3 different custom fields, can you share the trigger you references in your post - I can't see how to use a trigger to set the subject line

    0
  • Dean Kongslie
    Community Moderator

    William Grote

    As part of your trigger actions you need to include "Notify Active Webhook". Then select the webhook you want to use (more on this later) and paste the JSON that will be sent through the webhook to update your ticket subject. Here is an example:

    {"ticket":
    {"subject": "This is the Subject | Field 1: ticket.ticket_field_1 | Field 2: ticket.ticket_field_2 | Field 3: ticket.ticket_field_3"
    }
    }

    Replace the 1, 2 & 3 at the end of the ticket.ticket_field with the appropriate field id.

    Here is a link to create webhooks. You will want to create a ticket PUT webhook for this feature:https://support.zendesk.com/hc/en-us/articles/4408839108378-Creating-webhooks-in-Admin-Center

    0
  • Riah Lao

    Hi,

    1. Is there a way to "escape" or what to replace single quote ' within the if else condition?

    For example:

    {% if ticket.brand.name == 'XYZ's' %}

    2. Does "else if" work?

    Thanks,

    Riah

    0
  • Dean Kongslie
    Community Moderator

    Riah LaoI am not positive as I haven't had to do this in Liquid yet, but in SQL for example you would add a 2nd quote. So your if statement would look like this:

    {% if ticket.brand.name == 'XYZ''s' %}
    0
  • Rafael Santos
    User Group Leader

    Riah Laoyes, you can use double quotes there, and Else If works too.

    {% if ticket.brand == "XYZ's" %}
    Action A
    {% elsif ticket.brand == "IJK" %}
    Action B
    {% else %}
    Action C
    {% endif %}

    You'll find more info on the液体文档>控制流

    0
  • John DiGregorio

    We had a trigger in place to translate language and it all of a sudden stopped working translating to French for French users. We tried creating this in a Marco and still the end user received the body of the email in English but the subject of the email in French. Any help would be greatly appreciated.

    % case ticket.requester.language %}

    {% when 'French'%}

    Cher(e) {{ticket.requester.name}},

    Vous nous avez sollicités pour vous aider sur le sujet suivant "{{ticket.title}}" #{{ticket.id}} :

    Nous vous remercions pour cette suggestion. Nous transmettons le sujet à notre équipe Produit et fermons le ticket. Pour le suivi et avoir plus d'informations sur ce sujet, n'hésitez pas à vous adresser à votre CSM.

    Cordialement,

    Votre équipe support

    {% else %}

    Dear {{ticket.requester.name}},

    You have asked us to help you on the following subject "{{ticket.title}}" #{{ticket.id}}:

    Thank you for this suggestion. We will forward the issue to our Product Team and close the ticket. For follow-up and more information on this topic, please contact your CSM.

    Sincerely,

    Your support team

    {% endcase %}

    0
  • Jacob the Moderator
    Community Moderator

    Hey John,

    Looks like you are missing the the opening curly bracket {

    In
    % case ticket.requester.language %}

    It should be:
    {% case ticket.requester.language %}

    See if that helps.

    0
  • John DiGregorio

    Jacob the Moderator- I missed it in the cut and past into this thread - we have tested the triggers and Macros and nothing seems to work.

    0
  • John DiGregorio

    Jacob the Moderator

    I was curious to know as it is being passed as a ticket field "Requester.Language" if it would show up on a report and it doesn't. What does show up on a report is Requester.Locale - if you change the code to the New Code below it works like a champ - just tested. Not sure why it doesn't work with Language - it worked fine when we set it up a year ago

    Old Code

    {% case ticket.requester.language %}

    {% when 'French' %}

    New Code

    {% case ticket.requester.locale %}

    {% when 'fr' %}

    0
  • Jacob the Moderator
    Community Moderator

    That's a great solution!
    I still don't know why the language wouldn't work, I've used it on the past. But locale should work just fine.

    0
  • John DiGregorio

    Jacob the Moderator- we have a ticket into support - I am wondering if they deprecated language as it isn't on the ticket reports like Locale

    0
  • Jacob the Moderator
    Community Moderator

    Please let me know what they find.

    I don't believe it has been deprecated, more likely I think it has to do with the language that the string denoting the language - I recall having a similar issue years back.
    In this article both English and Italian is used to specify language, which is confusing:
    https://support.zendesk.com/hc/en-us/articles/4408842967578-Using-Liquid-markup-to-support-multiple-languages-in-automations-macros-and-triggers

    0
  • Rafael Santos
    User Group Leader

    Jacob the ModeratorandJohn DiGregorioLanguage still works as expected, though not as described above.

    In your example:

    {% case ticket.requester.language %}

    The language is translated to the receiving user's profile language settings.

    Therefore it would render as "French" for an English user, but "Français" for a French user. (Example: sending a notification to an English agent and French customer)

    Locale is as you've described the safe approach when customizing these.

    0
  • Adam

    Austin KilleyI'm currently trying to use the Liquid Markup with a checkbox on an organization custom field. But regardless if the checkbox is checked or not it always defaults to "No".

    I'm not sure why this is happening. Which I pulled information on this snippet fromhttps://support.zendesk.com/hc/en-us/articles/4408887218330-Using-placeholders#topic_nfn_yxq_j2b

    {% if ticket.organization.custom_fields.7653625709581 contains 1 %}Yes{% else %}No{% endif %}
    0
  • Dave Dyson
    Hi Adam -

    Adjusting your Liquid to this should work:

    {% if ticket.organization.custom_fields.7653625709581 == '1' %}Yes{% else %}No{% endif %}
    0
  • Adam

    Hey@...

    I've made the change you've suggested, but unfortunately we are still seeing the same result, it's always defaulting to no. So when the checkbox is selected it does not satisfy the first if statement.

    Working with Zendesk support I've also tried this with similar results.

    {% if ticket.organization.custom_fields.key_account_cse == '1' %}Yes{% else %}No{% endif %}
    0
  • Dave Dyson
    Shoot, I'm sorry Adam! I'll do some more experimentation on my end and see if I can figure it out.
    0
  • Rafael Santos
    User Group Leader

    HeyAdamand@...,我摆弄那些发现其溶解tion (proof below). The following will work for your example:

    {% if ticket.organization.custom_fields.key_account_cse == true %}Yes{% elsif ticket.organization.custom_fields.key_account_cse == false %}No{% endif %}

    为了测试这些,我已经创建了2 Org复选框字段:

    • True Boolean (key: true_boolean)
    • 虚假的布尔(关键:false_boolean)

    Setting my Test ticket's Org's "True Boolean" to Checked, and leaving "False Boolean" as Unchecked.

    I've used the following in a test macro:

    Which returns this Macro Preview on the aforementioned test ticket, confirming that these work as expected:

    0
  • Dave Dyson
    That's awesome, thanks so much Rafael!
    0
  • Adam

    I can confirm this worked perfectly. Thank you both for helping on on this one.

    0
  • Dave Dyson
    Hi Tatiana,

    The only brand placeholder that should work isticket.brand.name; there are no placeholders for the brand id -- seeZendesk Support placeholders reference.
    0

Pleasesign into leave a comment.

Powered by Zendesk