Mail templates are written in the Velocity Template Language, or VTL (official documentation). It is HTML with some (simple) logic possibilities and enables the user to create custom templates based on its needs.
The above example can translate to the following result that shows which bookings match the alert:
You can add internal info to the template as well as some logic.
Parameters are prefixed with $, and commands with #.
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.
The syntax for an if-else statement is:
More info in the following Documentation.
Looping over lists
The syntax is:
More info in the following Documentation.
The following parameters are set in the context, meaning they are available to use in every template you write.
A list containing all the bookings that match the alert 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:
|$bookings.size()||The number of bookings that match the alert.|
|$booking.get(i)||Fetch the i-th booking from the list.|
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)).
|$booking.id||An integer representing the booking ID|
|$booking.campaignid||An integer representing the booking campaign ID|
|$booking.name||A string representing the booking name|
|$booking.description||A string representing the booking description|
|$booking.toReachVolume||An integer representing the booking to reach volume|
|$booking.startDate||A date representing the booking start date|
|$booking.endDate||A date representing the booking end date|
|$booking.startTime||A LocalTime representing the booking start time|
|$booking.endTime||A LocalTime representing the booking end date|
|$booking.daysOfTheWeekOnline||An 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.creation||A date representing the booking creation date|
|$booking.lastModified||A date representing the date of the last booking modification|
|$booking.slot.id||An integer representing the booking slot ID|
|$booking.slot.name||A string representing the booking slot name|
|$booking.waveId||An integer representing the booking wave ID|
|$booking.pricingCode||A string representing the booking pricing code: CPM, CPC, CPP, ADM or CPL|
This contains all the information about the alert fired:
|$alert.pk.id||An integer representing the alert ID|
|$alert.name||A string representing the alert name|
|$alert.hour||A LocalTime representing the hour the alert is checked if the alert is configured that way, otherwise null|
|$alert.publicationIds||A set of integers with the selected publication IDs|
|$alert.templateIds||A set of integers with the selected format IDs|
|$alert.productIds||A set of integers with the selected location IDs|
|$alert.deliveryRate||A string representing the requested delivery rate, in formatted like [<|=|>]# (e.g. <0,6)|
|$alert.clickRate||A string representing the requested click rate, in formatted like [<|=|>]# (e.g. <0,6)|
|$alert.price||A string representing the requested price, in formatted like [<|=|>]# (e.g. <0,6)|
|$alert.impressions||A string representing the requested impressions, in formatted like [<|=|>]# (e.g. >100000)|
|$alert.mailTemplateId||An integer representing the ID of the mail template used.|
|$alert.creation||A date representing the alert creation date|
|$alert.modified||A 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.