By default, many business rules use the {{ticket.comments_formatted}} placeholder to include comments into email notifications. If you want more control over how the comments are presented to requesters, you can access more details about comments and their attachments using Liquid markup.
A comment is an element within a ticket and there are a number of placeholders available that you can use to include comments in email notifications. For example, you can include all comments, public comments, the last comment, etc (see Comment data).
If you want more control over how comments are displayed in email notifications, you can use Liquid markup and a for loop, as in this example:
{% for comment in ticket.comments %} Comment: {{comment.created_at}} {{comment.created_at_with_time}} {{comment.author.name}} {{comment.value}} Attachment: {% for attachment in comment.attachments %} {{attachment.filename}} {{attachment.url}} {% endfor %} {% endfor %}
This returns the items in both arrays (ticket.comments and comment.attachments). In other words, the properties for every comment and attachment contained in the ticket.
{% for comment in ticket.comments limit:1 offset:0 %}You can do a lot with arrays in for loops. Refer to the Liquid documentation (Liquid for Designers) for more details.
For more information on how Liquid markup can be used, see Understanding Liquid markup and Zendesk Support.
6 Comments
Huh, this article helped me a lot! Thank you, Aimee!
can this be used in a Trigger to extract a comment.id, then send that ID to an external target, using the Notify Target functionality?
Thanks!
Hi, is it possible to use liquid in the master email template?
Aimee, I am trying to surface the attachment name and link in the body of a macro. From https://support.zendesk.com/hc/en-us/articles/203662156-Zendesk-placeholders-reference, it's my understanding that I have to do this with Liquid Markup rather than a simple placeholder. Basically, I don't want my agents to have to retype and link the attachment name. I tried this:
But that doesn't seem to work for what I want. Do you have a suggestion for how to do this?
Hey Dan Ross,
With some iterative attempts, I figured out how to extract the comment ID. The syntax shown at https://support.zendesk.com/hc/en-us/articles/203662156-Zendesk-placeholders-reference#topic_jkz_opl_rc isn't exactly clear on the fact that the "comment" part of "comment.id" is the name the iterator for the collection. That's probably as clear as mud so here's how to extract the ID in a modification of the article code.
You don't have to iterate over all of the comments. If you want to get the ID of the latest comment, the Liquid syntax is {{ticket.latest_comment.id}} or if you're after the latest public comment, it's {{ticket.latest_public_comment.id}}. You can use this to fire off to an external target.
KF
Is there any way to get the author's avatar (i.e., comment.author.avatar)?
Please sign in to leave a comment.