Skip to main content

GetNotificationTemplate@1

Node GetNotificationTemplate@1 is used to retrieve a notification template from the OctoMesh Asset Repository based on the notification template name. The template name can be specified directly or retrieved from a path in the data context.

Notification templates are used to define the structure and content of notifications sent by the OctoMesh platform. These templates can be customized to include specific information and formatting based on the use case.

Adapter Prerequisites

Node Configuration

For fields path, targetPath, targetValueWriteMode, and targetValueKind, see Overview.

Configuration Fields

FieldTypeRequiredDescription
notificationTemplateNamestringNo*The name of the notification template to retrieve (direct value)
notificationTemplateNamePathstringNo*JSONPath to retrieve the notification template name from the data context
subjectTargetPathstringYesThe path where the subject of the notification template should be stored in the payload
targetPathstringYesThe path where the body of the notification template should be stored in the payload

*Either notificationTemplateName or notificationTemplateNamePath must be provided.

Direct Template Name Configuration

transformations:
- type: GetNotificationTemplate@1
targetPath: $.body
notificationTemplateName: my-template-e-mail
subjectTargetPath: $.subject

Path-Based Template Name Configuration

transformations:
- type: GetNotificationTemplate@1
targetPath: $.body
notificationTemplateNamePath: $.templateName
subjectTargetPath: $.subject

Usage Examples

Example 1: Direct Template Name

Here's an example of how you might use the GetNotificationTemplate@1 node with a direct template name in a transformation pipeline. In this example, the node retrieves a notification template named emaildemo and stores the template body in the payload at $.body and the subject at $.subject. There are two placeholders in the template body, tableData and firstName, which are replaced with the query result and the customer's first name, respectively. After replacing the placeholders, the email is sent to the specified email address.

triggers:
- type: FromExecutePipelineCommand@1
transformations:
- type: GetNotificationTemplate@1 # Get the notification template
notificationTemplateName: emaildemo
targetPath: body
subjectTargetPath: subject
- type: GetRtEntitiesById@1 # Get the customer entity
ckTypeId: OctoSdkDemo/Customer
rtIds:
- 673b5e451c7375d2ea2bec85
targetPath: $.customer
- type: GetQueryById@1 # Get the query result
targetPath: $.query
queryRtId: 673b5c06de73e7b1755754e4
- type: QueryResultToMarkdownTable@1 # Convert the query result to a Markdown table
path: $.query
targetPath: $.table
- type: PlaceholderReplace@1 # Replace placeholders in the notification template
replaceRules:
- placeholder: tableData
path: $.table
- placeholder: firstName
path: $.customer.Attributes.FirstName
- placeholder: lastName
path: $.customer.Attributes.LastName
path: $.body
targetPath: $.resultBody
- type: SetPrimitiveValue@1 # Set the email address
value: "demo@demo.com"
targetPath: $.to
- type: SendEMail@1 # Send the email
serverConfiguration: smtptest
subjectPath: $.subject
path: $.resultBody
toPath: $.to

Example 2: Path-Based Template Name

This example demonstrates using a path to retrieve the template name dynamically. The template name is first set in the data context, then retrieved by the GetNotificationTemplate@1 node.

triggers:
- type: FromExecutePipelineCommand@1
transformations:
- type: SetPrimitiveValue@1 # Set the template name dynamically
value: "customer-welcome"
targetPath: $.templateName
- type: GetNotificationTemplate@1 # Get the notification template using path
notificationTemplateNamePath: $.templateName
targetPath: body
subjectTargetPath: subject
- type: GetRtEntitiesById@1 # Get the customer entity
ckTypeId: OctoSdkDemo/Customer
rtIds:
- 673b5e451c7375d2ea2bec85
targetPath: $.customer
- type: PlaceholderReplace@1 # Replace placeholders in the notification template
replaceRules:
- placeholder: firstName
path: $.customer.Attributes.FirstName
- placeholder: lastName
path: $.customer.Attributes.LastName
path: $.body
targetPath: $.resultBody
- type: SetPrimitiveValue@1 # Set the email address
value: "welcome@company.com"
targetPath: $.to
- type: SendEMail@1 # Send the email
serverConfiguration: smtptest
subjectPath: $.subject
path: $.resultBody
toPath: $.to

Error Handling

The GetNotificationTemplate@1 node throws exceptions in the following scenarios:

  • Configuration Error: Neither notificationTemplateName nor notificationTemplateNamePath is provided
  • Path Value Error: notificationTemplateNamePath is provided but the path contains no value or null
  • Template Not Found: The specified template name doesn't exist in the OctoMesh Asset Repository

When any of these errors occur, the pipeline execution will stop, and a detailed error message will be provided indicating the cause of the failure.