Creating an Event Notifications template
An IBM Cloud Event Notifications template is a pre-defined layout that includes images, text, and dynamic content based on an event. You can use a template as a base and customize it rather than creating a new one from scratch each time.
Creating a template
-
In the IBM Cloud console, click the Menu icon
> Platform Automation > Event notifications.
-
Click the name of your Event Notifications instance.
-
Click on Create on the top right.
-
Enter details about the template such as the name and description, and select a template type. Event Notifications currently supports 4 templates:
-
Click Add to save your updates.
Handlebars Integration
Handlebars is a templating language that allows for dynamic content generation within templates.Handlebars can be used to customize notification messages using template variables and conditional logic.
Template Variables
Template variables are placeholders within the notification message templates that get replaced with actual data when a notification is triggered. These variables allow users to personalize messages and include relevant information from the event being notified.
Usage:
{{variable_name}}
Example:
Event Name: {{event_name}}
Conditional Logic Helper
Conditional logic allows users to define conditions within the message templates, enabling dynamic content generation based on the values of variables. This feature is useful for creating flexible notification messages that adapt to different scenarios.
Usage:
{{#if condition}}
{{else}}
{{/if}}
Example:
{{#if severity}}
Severity: {{severity}}
{{else}}
No severity information available
{{/if}}
Contains Helper
The contains helper allows users to check if there is a specific word in any of the fields of the payload.
Example:
"data":
{
"message": "this is test alert from dev account"
}
Use the contains helpers like below:
{
{{#contains data.message "dev"}}
"environment": "development"
{{/contains}}
}
There are more helpers available for use that can be referenced from here