Skip to end of metadata
Go to start of metadata

Mail templates are written in the Velocity Template Language, or VTL (official documentation). It is basically HTML with some (simple) logic possibilities and enables the user to create custom templates based on its needs.

Introduction

An example:

An excerpt from the default template
#if($bookings.size() ne 1)
#set ($bookingQ = "These bookings match")
#else
#set ($bookingQ = "This booking matches")
#end
<p>${bookingQ}:</p>
<table>
#foreach($booking in $bookings)
	<tr>
		<td>$booking.campaignId</td>
		<td><a href="${origin}#campaignDetail/bookingDetail/${booking.Id}/${booking.campaignId}"> ${booking.Id} </a></td>
	</tr>
#end
</table>

The above example can translate to the following result that shows which bookings match the alert:

Possibilities

You can add internal info to the template as well as some logic.

Parameters are prefixed with $, and commands with #.

Setting parameters

The basic syntax for setting a parameter is:

#set ($parameter = "value")

The value of the parameter can be a simple string, integer, calculation or concatenation. More info in the following Documentation

If-else constructs

The syntax for an if-else statement is:

#if(condition)
  >run if true<
#elseif(second condition)
  >run if first condition if false and second true<
...
#else
  >run if no previous conditions is true<
#end

More info in the following Documentation.

Looping over lists

The syntax is:

#foreach($element in $collection)
  >do something<
#end

More info in the following Documentation.

Available parameters

The following parameters are set in the context, meaning they are available to use in every template you write.

Bookings

A list containing all the bookings that match the alert on the moment the alert is checked (based on your configuration of the alert).

Being a list, the only useful parameters/operations apart from looping over it in a for-loop are:

Parameter nameMeaning
$bookings.size()The amount of bookings that match the alert.
$booking.get(i)Fetch the i-th booking from the list.

Booking

On iterating over the list, or when fetching a specific booking, you can use the following parameters. The list assumes that you are iterating over the list like in the example above (#foreach($booking in $bookings)), or fetched a booking using #set($booking = $bookings.get(0)).

Parameter nameMeaning
$booking.idAn integer representing the booking ID
$booking.campaignidAn integer representing the booking campaign ID
$booking.nameA string representing the booking name
$booking.descriptionA string representing the booking description
$booking.toReachVolumeAn integer representing the booking to reach volume
$booking.startDateA date representing the booking start date
$booking.endDateA date representing the booking end date
$booking.startTimeA LocalTime representing the booking start time
$booking.endTimeA LocalTime representing the booking end date
$booking.daysOfTheWeekOnlineAn integer set representing the days of the week online (monday -> 1, tuesday -> 2, ..., sunday -> 7)
$booking.deliveryMethod.value()A string object representing the booking delivery method: auto, sov or rotation
$booking.deliveryMultiples.value()A string representing the booking delivery multiples: all-together, one-at-a-time or free
$booking.creationA date representing the booking creation date
$booking.lastModifiedA date representing the date of the last booking modification
$booking.slot.idAn integer representing the booking slot ID
$booking.slot.nameA string representing the booking slot name
$booking.waveIdAn integer representing the booking wave ID
$booking.pricingCodeA string representing the booking pricing code: cpm, cpc, cpp, adm or cpl

Alert

This contains all the information about the alert fired:

Parameter nameMeaning
$alert.pk.idAn integer representing the alert ID
$alert.nameA string representing the alert name
$alert.hourA LocalTime representing the hour the alert is checked if the alert is configured that way, otherwise null
$alert.publicationIdsA set of integers with the selected publication IDs
$alert.templateIdsA set of integers with the selected format IDs
$alert.productIdsA set of integers with the selected location IDs
$alert.deliveryRateA string representing the requested delivery rate, in formatted like [<|=|>]# (e.g. <0,6)
$alert.clickRateA string representing the requested click rate, in formatted like [<|=|>]# (e.g. <0,6)
$alert.priceA string representing the requested price, in formatted like [<|=|>]# (e.g. <0,6)
$alert.impressionsA string representing the requested impressions, in formatted like [<|=|>]# (e.g. >100000)
$alert.mailTemplateIdAn integer representing the ID of the mail template used.
$alert.creationA date representing the alert creation date
$alert.modifiedA date representing the date of the last alert modification

Actions on objects

All objects represent their Java counterparts, which means that you can use any Java method supported by that object.

e.g. a string
<p>This is a
#if ($alert.name.substring(0,1) == "!")
	high
#elseif ($alert.name.substring(0,1) == "-")
    low
#else
    medium
#end
priority alert.</p>