Broadleaf Microservices
  • v1.0.0-latest-prod

Building Templated Emails

Table of Contents

Overview

The Notification Service includes the ThymeleafMessageBuilder which is an integration with Thymeleaf to provide support for creating templated messages.

By default, the Template engine looks in the classpath to find templates using the lower-cast pattern of /templates/{deliveryType}/{messageType}.

For example, a Notification with deliveryType of EMAIL and a messageType of reset-password will look in the classpath for /templates/email/reset-password.html.

By default, the ThymeleafMessageBuilder assumes the Notification.data property is a valid JSON object. It converts it to a map and adds the and converts it to a map to the Thymeleaf context so that the data is available to the template.

For other templating approaches, implement a custom MessageBuilder component or extend the ThymeleafMessageBuilder as needed.