Message Templates
Within the Message Templates application view, users have the ability to create new message templates, edit existing ones, and remove templates that are no longer needed.
When you click the Create button, the Message Template view opens, presenting a detailed interface for configuring the template. Within this view, you’ll find the Template Details tab and the Parameters tab.
Template Details
The Template Details tab contains a panel for configuring template attributes and a panel for the HTML editor, where you can design the template’s layout and content.

Setting Template Attributes
You must configure the following parameters for each template:
-
Name: A human-readable name for the template. This is a required field and should clearly describe the template’s purpose.
-
Code: A unique identifier for the template. This code can be used to locate the template via API calls. This is also a required field.
-
Type: Choose between
Plain Text
orHTML
format, depending on the template’s intended use. -
Group (optional): Assign the template to a specific group for better organization. Groups can be configured in the Message groups view.
Designing the Template
In the HTML Editor, you can create and customize your template using various elements such as text, images, buttons, and more. Each element’s properties can be fine-tuned through the editor’s built-in panels.
Within the template text, you can leverage placeholders to insert dynamic data.
For more advanced customization and detailed instructions on using the editor, refer to the GrapesJS Documentation.
Placeholders
Placeholders are dynamic variables within your message templates that are replaced with actual data at runtime. These placeholders are enclosed in FreeMarker’s variable interpolation syntax (typically ${variableName}
).
The data used to populate these placeholders can be derived from various sources, such as: template parameters defined within the template itself, and parameters passed programmatically from the application code.
Beyond simple value insertion, FreeMarker offers a rich set of built-in functions to format and manipulate data within placeholders. You can use functions for date formatting, number formatting, string manipulation (uppercase, lowercase, substring), and more. For example, ${date?string["MM/dd/yyyy"]}
would format a date value as MM/dd/yyyy
.
For more detailed information, please refer to the FreeMarker documentation.
Template Editor Tools
The button panel located at the top of the HTML editor provides essential tools for working with templates:
-
Import HTML: Upload and integrate existing HTML code into your template.
-
View Source Code: Display the raw HTML code for editing or analysis.
-
Preview HTML: Open a preview of the template in a new tab to check its appearance.
Parameters
Parameters of the template can be created and configured in the Parameters tab.
After you click on the Create button the Template parameter dialog is displayed.

Parameter aliases must be unique within a single template. |
Parameter Details
In the Parameter details tab, you can configure the properties of parameters used in your templates. Each parameter has the following configurable properties:
-
Name: The name of the parameter as it will appear in the parameter input form.
-
Alias: A unique identifier used to reference the parameter within the template. This alias is essential for accessing the parameter programmatically.
-
Type: The data type of the parameter. Supported types include primitive types (
String
,Number
,Boolean
), temporal types (Date
,Time
,Date and Time
), as well as complex types such asEnumeration
,Entity
, orList of Entities
. -
Hidden: A flag that determines whether the parameter input field should be hidden from users. If enabled, the parameter will not be visible in the input form.
-
Required: A flag that specifies whether the parameter is mandatory. If enabled, users must provide a value for this parameter before proceeding.
-
Default Value: The value that will be automatically assigned to the parameter if no other value is provided by the user. This ensures the parameter always has a valid value, even if left unchanged.
Parameter Types and Additional Fields
Depending on the selected parameter type, additional fields may be required for configuration:
-
Entity or List of Entities:
-
Entity: Specifies the entity to be used as the parameter. This is required when the parameter type is set to
Entity
orList of Entities
.
-
-
Enumeration:
-
Enumeration: Specifies the enumeration to be used as the parameter. This is required when the parameter type is set to
Enumeration
.
-
-
Temporal Types (Date, Time, or Date and Time):
-
Default date/time is current: A flag that determines whether the current date, time, or timestamp should be used as the default value for the parameter. If enabled, the system will automatically populate the parameter with the current date/time when no other value is provided.
-