Messaging service
The messaging service enables you to configure and send notifications to your customers via SMS or email. The messaging service serves as a notification gateway for other parts of the OneWelcome Identity Platform to unify the configuration of the notification channels.
The messaging service can send out SMS and emails with the data directly embedded in the request, or can use templates. Using templates gives you the option to adjust the look and feel of notifications.
Expected structure
The messaging service expects the following structure:
tenant-specific-folder:
|
messaging-service:
|
email:
| |
| html:
| - template.mustache
| - template2.mustache
| text:
| - template.mustache
| - template2.mustache
sms:
| - template.mustache
messages:
- messages.properties
- messages_en.properties
- messages_pl.properties
- messages_nl_BE.properties
- messages_otherlangugecode_COUNTRYCODE.properties
Mustache templates
The messaging service uses the Mustache template language for templates. Templates can be localized and sent in a language that is specified in the request. All messages files must contain all translation keys. The messaging service does not merge the default file with localized files to avoid unnecessary file downloads. The locale must be passed in the request. If no locale is provided, the default file is used. If no file for the provided locale is present, the default file is used. To include a localized message in the template, the message key should be wrapped in the {{i18n}}
tag.
Note
The requested locale is case-sensitive and must match the messages.properties
extension. For example, if the requested locale is nl_BE
, it matches the file messages_nl_BE.properties
.
Example: Template file
One, two, {{key}}. {{#i18n}}message.key{{/i18n}}!
Example: Template parameters
{
"message": {
//...
"parameters": {
"key": "three"
},
//...
}
}
Example: Messages.properties content
message.key=Three elements Sir
When such a template is processed, {{key}}
is replaced by the value provided in the template parameters from the request, and {{#i18n}}message.key{{/i18n}}
is replaced by the value from the properties file. The output is:
One, two, three. Three elements Sir!