| copyright |
|
||
|---|---|---|---|
| lastupdated | 2025-10-29 | ||
| keywords | event notifications, event-notifications, tutorials | ||
| subcollection | event-notifications |
{{site.data.keyword.attribute-definition-list}}
{: #en-create-en-template}
An {{site.data.keyword.en_full_notm}} template defines the layout and content of notifications (email, webhook, Slack, etc.). Templates can include images, static text, and dynamic content (variables, conditional logic) based on events.
Event Notifications supports two types of templates:
-
User-defined templates: You can design your own templates to structure notification messages.
-
Pre-defined templates: These are standard templates defined for a pair of specific source and destination. You can customize pre-defined templates to create a user defined template.
{: shortdesc}
{: #en-create-template}
-
In the {{site.data.keyword.cloud_notm}} console, click the menu icon
> Platform Automation > Event notifications.
-
Click the name of your {{site.data.keyword.en_short}} instance.
-
Select Templates from the left panel and click Create.
-
Enter details about the template such as the name and description, and select a template type. Event Notifications currently supports the following user-defined 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 ,conditional logic and various other helpers.
{: #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-template-variables}
Example:
{: #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-conditional-logic-helper}
Example:
{: #contains-helper}
The contains helper allows users to check whether there is a specific word in any of the fields of the payload.
{: #example-contains-helper}
"data":
{
"message": "this is test alert from dev account"
}
Use the contains helpers like:
There are more helpers available for use that can be referenced from here {: note}
{: #template-examples}
Payload:
"data":
{
"message": "this is test alert from dev account",
"secrets": [
{
"event_time": "2025-01-24T00:45:01Z",
"event_triggered_by": "SecretsManager",
"secret_expiration": "2025-04-24T00:45:01Z"
}
],
}{: #conditional-contains-helpers}
{: #for-loop-1}
{: #for-loop-2}
Payload:
"toolchain.tool-instance":{
"name":"sample-date"
}
{: codeblock}
Accessing name:
{{[toolchain.tool-instance].name}}
{: codeblock}
To access the name value from a JSON payload where the key is "toolchain.tool-instance" , the syntax {{[toolchain.tool-instance].name}} is used because the key contains special characters and cannot directly be accessed with a dot notation.