Send out different notification messages using liquid Follow

Comments

12 comments

  • Avatar
    Serge Payette

    Thanks for sharing @Andrey.

  • Avatar
    Terry Knox

    Love this, but getting unwanted carriage returns at the beginning and end of messages when used in a Macro. Anyone have any idea what I may be missing? 

  • Avatar
    Terry Knox (Edited )

    Pretty sure I've sorted this out now - just removed all carriage returns and spaces in the Liquid Markup and it seems to work. 

  • Avatar
    Jessie Schutz

    Great, Terry! I'm glad you were able to get it sorted out, and thanks for sharing the solution. :)

  • Avatar
    Sam Tilin

    Hey, this is a great post! What I'm wondering is if I can use Liquid markup to change a custom field on the ticket, rather than show/hide text in the email notification. 

    In other words, I'd like to use the modulo: 3 logic to set a checkbox to TRUE for a randomized 1/3 of my tickets. Is this possible? 

  • Avatar
    Andrey Sarapulov

    hi Sam,

    By idea Liquid can't change anything. It's templating language which can only show some text or HTML.

    If you want to randomly set ticket dropdown I would suggest to use triggers/automations for that. I haven't tried to to achieve something similar using business rules yet, so can't really point to right direction yet.

     

  • Avatar
    Sam Tilin

    @Andrey Thanks! I'll work on that

  • Avatar
    Andreas Schuster

    Thanks for sharing this tip, Andrey.

    I went even one step further and improved the randomizer, cause sometimes the "random" answer did not fit each ticket so much. The problem with the implementation above is that it's not random for each macro usage when you replace ticket id with the current time, it will be :)

    {% assign current_time = 'now' | date: "%L" %}
    {% assign r = current_time | modulo:4 %}
    {% case r %}
    {% when 0 %}
    Thank you for reaching out to us,
    {% when 1 %}
    Thank you for contacting us,
    {% when 2 %}
    Thank you for writing us,
    {% when 3 %}
    Thank you for dropping us a message,
    {% endcase %}

    The placeholder %L gives you the current milliseconds of the UNIX timestamp, e.g. 674.

  • Avatar
    Christopher Rehn

    Hello all!

    We run an automation and for the signature of the user, we want to use a randomiser so that this automation appears like one of many different users instead of always replying with the same name. So, for the signature I have pasted a dynamic content template. The content itself looks like this:

     

    {% assign randomizer_automation_name = ticket.id | modulo:9 %}{% case randomizer_automation_name %}{% when 0 %}**Name 1**{% when 1 %}**Name 2**{% when 2 %}**Name 3**{% when 3 %}**Name 4**{% when 4 %}**Name 5**{% when 5 %}**Name 6**{% when 6 %}**Name 7**{% when 7 %}**Name 8**{% when 8 %}**Name 9**{% when 9 %}**Name 10**{% else %}**Name 10**{% endcase %}

     

    For some reason, it always returns "Name 1" when used. What can be the cause for this? Is the reason it returns 0 because the ticket ID is not checkable when using this in a Signature?

  • Avatar
    Andrey Sarapulov

    @Andreas,

    thanks for sharing. Using date makes much more sense. At the time of writing this article I was not that pro in liquid. These days I would also consider the date/timestamp. Glad you've shared it!

    @Christofer,

    >Is the reason it returns 0 because the ticket ID is not checkable when using this in a Signature?

    That is correct. Luckly enough earlier this year I wrote an app which allows injecting HTML, complex liquid etc into signatures. This is Labs app, so has limited support, but it received many positive feedbacks so far. Check this out:

    https://www.zendesk.com/apps/support/zignatures

  • Avatar
    Andreas Schuster

    @Andrey

    Do you maybe know a way to get 2 different random values in a macro?
    I had a use case where i wanted to fully automate the greeting forms in my tickets.
    The problem is that when i am accessing "now" a second time, the return value is still the same, probably due to the fact that it happens in the same milisecond. There's also now wait/sleep function in liquid to prevent that from happening 😕

  • Avatar
    Andrey Sarapulov

    @Andreas,

    Let me make sure I understood your use case here:

    You want to apply a macro once on ticket X => the outcome should display VALUE1

    Then, say, 2 mins later, you want to apply the same macro again, but on ticket Y => the outcome should display VALUE2

    Is this accurate description ^ ?

Please sign in to leave a comment.

Powered by Zendesk