In the other articles, we read about the notify module, its utility, and its offerings. We also understood how to use the notify module to add new notification modules and new notification channels and how to send notifications on different channels using the notify module. If you have not gone through those articles, head to the links below and spare some time to read them first.

Introduction to Notify Module

Notify module usage for channel authors

Notify module usage for module authors

In this article, we are mentioning the internal APIs(not explaining) which notify provide for

  • Updating notify alert settings
  • Updating notify template sets
  • Updating notify templates

The APIs are written in the Notify module and can be found in app/Notify/routes.php. Here is the list of available APIs

  • GET             notify/api/notification-channels (get notification channels)
  • GET             notify/api/template-sets (get template sets of channel)
  • POST           notify/api/template-sets/create (create template set for channel)
  • PATCH        notify/api/template-sets/change-status/{set} (activate/deactivate template set for channel)
  • DELETE      notify/api/delete-template-sets/{set} (delete template set)
  • GET              notify/api/templates (list templates of the set)
  • GET              notify/api/get-template/{template} (get template details)
  • PATCH        notify/api/update-template/{template} (update template details)
  • GET              notify/api/base-alerts (get alert settings for default notification which allow modification via notify)
  • PATCH         notify/api/base-alerts (update alert settings for default notification which allow modification via notify)

These APIs can get templates and alert settings for specific plugins by passing the plugin name as parameters.

Recommended files: Explore the doc comments for all the files in Notify, but we recommend taking time to understand the files in app/Notify/Controllers/NotifyFoundation, especially NotifyHandlerController.php, which processes the notification events.

Special power of the Notify

Notify module can also send custom notifications to custom users on custom channels, which can be handy when you do not require templates or settings or want to pass the user-entered message to the notifications. Example use cases

  • ServiceDesk announcements
  • Email diagnostics

Check the usage of NotifyModule in these files

  • app/Http/Controllers/Admin/helpdesk/EmailDiagnosticController.php
  • app/Plugins/ServiceDesk/Controllers/Announcement/ApiAnnouncementController.php
  • app/Plugins/ServiceDesk/Helper/Import/SdAssetImport.php
  • app/ImportProcessor.php
  • app/Listeners/ReportExportListener.php

Summary

Notify module is the core of the notification process. It performs some complex functions to make the life of other developers writing modules and integrating platforms in the system more comfortable. But modifying the behavior of Notify needs a thorough understanding of the code, and we highly encourage new developers to read the documentation and doc comments before making changes.

You can share your thoughts or request help by emailing the module’s author at mverma16@outlook.com. (*offer only for a limited time period)