← Home

◢◢ Setting up a new notification type (trigger)

Note: This guide was originally written for the Strapi-based notification system. The notification system has since been migrated to JARB. The general concepts still apply, but code paths and configuration steps should be adapted to the JARB module structure.

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 trigger type to the notification trigger enum in JARB.
  2. Add the same identifier to the NotificationConfigSetting model.
  3. Add the identifier to the notification config initialisation service function in JARB. The key is the new identifier, and the value is an array of notification types that it should send to.
  4. Run any necessary migrations 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 notification content module in JARB.
    1. A type for the notification should be created, using WithRequired<Notification, '[field names]'>. The field names should be strings separated by pipes |.
    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 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 the digest bypass triggers templates in the notification service in JARB. 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 JARB. To trigger the notification, call the triggerNotifications() service function in the notifications module.

The function takes the following parameters: