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.
4 Comments
This was incredibly helpful! Thank you!
Hi there, Aimee Spanier
Is there a way to clean up this markup
{% 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 %}
to only include the URL's for all the attachments in public comments but not the comments? The above returns all comments without an attachment as well and I'm having trouble editing it.
Thanks!
Fyi, if you're looking for information about how to do visual formatting / styles with Liquid markup, it's just plain html.
To bold something: <b>bold</b>
To make something into a heading: <h1>heading</h1>
Here is a related article that might also be relevant: Setting up an unformatted email template
Thank you Aimee!
Please sign in to leave a comment.