SmartNotify
Ruby Gem designed for sending various types of notifications via a common configurable interface.
Overview
The gem makes use of two components, modules, and templates.
Modules are defined within this gem, and provide various forms of generic notification functionality. The modules are created to be reusable. A module could be responsible for sending emails, posting Slack notifications, making a REST call to an external API, whatever.
Templates on the other hand, consume a specific module, in conjunction with template specific configuration, creating very specific use cases. These use cases could be team specific, allowing different consumers to tweak who, and how notifications are distributed.
Why
There was a need to easily send SLA incident emails to the correct person on support, as well as to a MS Teams channel. A module was created rotation_emailer
which could send emails, based on a given email template, and support rotation csv file. With that in place, a template was created incident_start_email
which defines where the specific email template, and support rotation csv file is located for this particular instance. This is awesome, because a new team or solution could create a template, changing only the support rotation csv location, and get the same functionality for next to no setup cost.
Usage
Add smartnotify to your Gemfile, pointing at GitHub.
gem 'smartnotify', git: 'https://github.cerner.com/PHPerfImp/smartnotify.git', branch: 'master'
Within your code add:
require 'smartnotify'
smartnotify = SmartNotify.new
smartnotify.run(template, json, [debug], [dryrun])
*Note: when updates are made to the gem in github, bundle update & bundle install must be run to pull in the changes.
Param | Type | Requirement | Default | Description |
---|
template | String | Required | | The id of the template to use. The templates are configured externally in PHPerfImp/smartnotify-config |
json | String | Required | | The JSON key/value pairs to be used as input to the selected template. Each template defines what keys must be provided. |
environment | String | Optional | production | The id of the environment configuration to use. Choices are local, development, staging, and production. |
debug | Boolean | Optional | false | Enables debug logging within SmartNotify. |
dryrun | Boolean | Optional | false | Enables debug logging within SmartNotify, and disables sending any notifications for testing purposes. |
Example
smartnotify = SmartNotify.new
smartnotify.run('incident_start_email', "{\"mnemonic\": \"sbmcin\", \"cerner_mnemonic\": \"UNVR_NY\", \"link\": \"https://jira2.cerner.com/browse/PERFIMPDEV-1349\", \"title\": \"Readmission SLA Exceeded\", \"message\": \"Readmission SLA exceeded, please check the JIRA for more information.\"}", 'production')
Modules
The following are the currently available modules that can be consumed. Follow the link to get more information on
intended usage, and configuration.
Releasing New Version
*N/A - As long as we are using our internal GitHub for storage of the gem, there is no need to 'release' a new version. Using a different version of the branch can be achieved by pointing the Gemfile reference at a different ref. See http://bundler.io/v1.12/git.html for more information.