Templates
Overview#
A template is an outline of the email notification which is sent out to invite people to subscribe to a group. This is similar to how templates are used in the Passport Service.
Velocity templates#
In a template object, the subject and body properties are Velocity templates. Velocity is a Java-based template engine. For more information on Velocity, visit Apache Velocity Project.
Velocity templates parameters#
In a Velocity template the following parameters are available:
| Parameter | Type | Description |
|---|---|---|
cancelAllLink | String | URL to block the device from receiving notifications. Should always be included in a normal email template. |
cancelLink | String | URL to cancel the subscription. Should always be included in a normal email template. |
acceptLink | String | URL to confirm the subscription. Should only be included in emails associated with the SUBSCRIBE_VERIFY action in a sender. |
request | Object | The request payload (for an EVENT trigger, this is the body of the event). |
device | Device | The device object (fields are those on the Device object: email, id, owner, etc.). |
sender | Sender | The sender object (fields are those on the Sender object: id, email, displayName, etc.). |
group | Group | The group object, if present. Fields are those on the Group object. |
Template guidelines#
Some general guidelines for using templates, include:
- Always include
cancelLinkandcancelAllLinkin your email templates to allow user control. - Include the
acceptLinkonly for emails related to theSUBSCRIBE_VERIFYaction in a sender.
Template examples#
Standard Notification Email (Velocity syntax)#
<html> <body> <h2>Hello from $applicationName!</h2> <p>Your device: $device.email.address</p> <p> <a href="$cancelLink">Cancel Subscription</a> | <a href="$cancelAllLink">Block Device</a> </p> <p>Request details: $request</p> #if($group) <p>Group: $group.name</p> #end </body></html>
SUBSCRIBE_VERIFY Email (Velocity syntax)#
<html> <body> <h2>Subscription Verification - $applicationName</h2> <p>Your device: $device.email.address</p> <p> <a href="$acceptLink">Confirm Subscription</a> </p> <p>Request details: $request</p> #if($group) <p>Group: $group.name</p> #end </body></html>