The content for Task Reminder emails is written with HTML and the Velocity templating language. This language provides a few simple language constructs like loops (#foreach) and conditionals (#if/#elseif/#else) that should be sufficient to write any kind of email body. Additional to the generic Velocity language functionality, we offer a templating API for Task Reminder.
The following variables are available in email content templates:
$user (Object) - object for the user receiving this email
- $user.fullName - The full name of the user
- $user.email - The email address of the user
- $user.name - The Confluence user name of the user
- $dateTool (Object) - an instance of the Velocity DateTool that provides you a set of tools for dealing with dates
- $baseUrl (String) - the base URL of your Confluence instance. For example, if you view pages with URLs like https://your.domain.com/pages/viewpage.action?pageId=10000000, the base URL will be https://your.domain.com/
- $whatIsSoonInDays (Number) - this will be the numeric value you configured in General Settings for tasks to be categorized as expiring soon.
- $tasks (Structure) - this is the main data structure containing a list of tasks for the categories Expired, Expiring Soon, Expiring Later, and Tasks without due date. Each of these lists has a boolean field activated that is true if the category is currently enabled in the general settings (with the respective toggle button). Furthermore, the amount of tasks in each list can be retrieved by calling $list.size().
- $tasks.expired - list of open expired tasks for the user
- $tasks.expired.activated - true if these should be included in emails
- $tasks.expiringSoon - list of open tasks expiring soon (i.e. within the date range configured in settings)
- $tasks.expiringSoon.activated - true if these should be included in emails
- $tasks.expiringLater - list of open tasks expiring later (i.e. later than the date range configured in settings)
- $tasks.expiringLater.activated - true if these should be included in emails
- $tasks.withoutDueDate - list of open tasks that don't have a due date
- $tasks.withoutDueDate.activated - true if these should be included in emails
Each task in one of the list of tasks described above will be an object with the following fields:
- $task.pageId (Number) - the ID of the page where the task is on
$task.body (String) - the task content (i.e. what's written next to the task as the actual TODO)
- $task.dueDate (Date) - the due date of the task (null if task has no due date)
- Note: this can be used in combination with the $TR.formatDate helper method described below!
- $task.pageTitle (String) - the title of the page where the task lives
The Task Reminder Helper
There is a helper object with utility methods that you can access in your template with the $TR key. Currently the following methods are available:
- $TR.getText(propertyKey: String) - retrieve a translated property using the user's configured language (see Task Reminder Email Translations (i18n properties))
- Example: $TR.getText("my.property.key")
- $TR.formatDate(dateFormat: String, date: Date) - format a given date with the given date format string
- Example: $TR.formatDate("yyyy/MM/dd", $task.dueDate) - e.g. 2019/10/31
Note: these are only the methods we have implemented so far because we needed them for the default template. Please let us know if you would like another method by raising a feature request!
The Default Template
The default template currently looks as follows. Once again, check the Velocity docs to find out how to write templates in this language.