← Home

◢◢ Setting up a new notification type (trigger)

Note: This article assumes that by "notification type", what is meant is referred to as a trigger in the code base. There is a type field on the Notification model, but that refers to how the notification is delivered (i.e. onsite or email). The trigger field refers to the event that causes the user to be sent a notification.

Updating the models

  1. Add an identifier for the new type to the trigger field on the Notification model in Strapi admin
  2. Add the same identifier to the trigger field on the NotificationConfigSetting model
  3. Add the the identifier to the newTriggers constant in the initialiseNotificationConfig() service function. The key is the new identifier, and the value is an array of Notification.types that it should send to.
  4. Run the GET /migration/update-notification-configs migration to give all existing users the default settings for the new notification trigger.

Setting up the new notification

  1. The template text for the on-site version of the notification should be added to the content file.
    1. A type for the notification should be created at the top of the file, and should be WithRequired<Notification, '[field names]'>. The field names should be strings separated by pipes | (see AwardedBountyNotification for an example).
    2. It should return an object with the following values:
      • imageUrl - The path for an image to be displayed next to the notification in the drop down. This should be saved to the email folder in S3.
      • text - The text that appears on the notification
      • title - The header that will be used in the email digest
  2. Email notifications are included as part of a digest by default, but if the new notification should be sent immediately as a stand-alone email, it will need to be be bypassed.
    1. Set up the template in Postmark. This should be created in the Just About Sandbox first and then pushed to Just About Production when it's ready.
    2. Add the notification to digestBypassTriggersTemplates on the Notification service. The key should be the name of the trigger and the value should be the name of the Postmark template.

Triggering the notification

Notifications should be triggered within Strapi. To trigger the notification, call the Notification.triggerNotifications() service function.

The function takes the following parameters: