Notification service
- Concept
- 3 minutes
The notification service manages self-notifications. You can use it to allow your users to register email notifications for themselves in your app. Events related to a resource your app presents will trigger these notifications.
Concepts
You need to know the following concepts to work with the notification service.
Self-notifications
Self-notifications are emails sent to a user, triggered by an event matching a DQL matcher expression. The notification service supports the same event trigger configuration options as the AutomationEngine for workflows.
A self-notification is defined via the notification service API and the notification template as a static asset in your app. The default approach to registering/unregistering a self-notification is to use the NotifyButton the Strato design system offers. You can use the notifications-client SDK to customize the behavior to your needs.
The self-notification is defined by
-
- A resource ID that identifies the relevant resource. Together with the notification type, you can use this to look up the self-notification configuration.
- The notification type that associates the notification template with the self-notification.
- The trigger configuration defines which event(s) trigger a notification.
- The notification template defines the email's subject and body text.
A self-notification is always implicitly associated with the user who clicked the NotifyButton and the app where the request originated.
Resource ID
The resource ID identifies which resource the notification is about (for example, an app ID for app update notifications, or a workflow ID for workflow change notifications). Together with the notification type, you can use the resource ID to determine whether there is a self-notification for the user and app.
Notification type
The notification type is a string that allows users to differentiate between multiple types of notifications in the context of one app. It can associate a notification with a template, see Notification template.
Notification template
The notification template defines the subject and body of the email to send. The SDK expects a JSON file in your app's static asset folder. The filename must follow the convention {notification_type}.notification-template.json
.
The service supports Markdown syntax to format the content in the notification body.
The subject and body may contain expressions to define the content dynamically, for example, by referencing attributes of the triggering event. The expressions are a subset of the expressions supported by the AutomationEngine:
environment()
event()
now()
timedelta()
For details, refer to the AutomationEngine expression reference.
Notification template example
{
"subject": "New app version for {{ event()['details.app.name'] }} - {{ event()['details.app.version'] }}",
"content": "{{ event()['details.app.name'] }} was updated to version {{ event()['details.app.version'] }} in environment {{ environment().id }}. "
}
Properties available for event()
depend on the events matching your notification trigger configuration.
Trigger configuration
The trigger configuration defines which events trigger sending an email to the user. Check out the notification-client SDK and .
Notify button
The Strato design system offers a NotifyButton that allows users to register and unregister a self-notification. Look at the component documentation for details.
Limitations
- The notification service limits the number of emails sent to a user to 30 per user per app per hour. An email notifies the user when they're about to hit this limitation.