Simplert
Simple way to send alerts via Slack, Email, Discord, SMS, etc. Simplert is currently geared towards personal and smaller apps where you just want a simple way to alert on some event like when a new user signs up. The idea is that you can just drop your simplert config file in any of your projects and quickly start alerting on events through multiple platforms without having to rewrite or copy over platform specific code. I would advise against using this in any critical production apps as of now.
Getting Started
- Install simplert:
npm install simplert
- Generate simplert configuration file:
npx generate-config
Simplert Configuration File
{
"discord": {
"enabled": false,
"token": "",
"send_to": ""
},
"email": {
"gmail": {
"enabled": false,
"send_to": "",
"send_from": "",
"subject": "",
"token": {},
"credentials": {}
}
},
"slack": {
"enabled": false,
"send_to": "",
"token": ""
}
}
enabled - whether you want this type of alerting enabled or not
discord:token - the token of your discord bot
discord:send_to - the name of the discord channel you want to send your alerts too. Make sure your bot has permission on the server to send messages
email:gmail:send_to - the default receipient email you want to send to, otherwise passed into the email function
email:gmail:send_from - The default email you want to send from. You may have a Gsuite account with multiple aliases that you can specifiy here which one you want to send from. Otherwise passed into the email function
email:gmail:subject - A default email subject for every alert, otherwise passed into the email function
email:gmail:token - Used for authorization, can be generated with npx generate-gmail
assuming you have your email:gmail:credentials
populated correctly.
email:gmail:credentials - Credentials provided by Google when setting up your project in the Google Cloud Console usually downloaded as gmail-credentials.json
. Set this key as the contents of that file.
slack:send_to - The channel or user you want to send the message to. Examples: #some_channel or @some_user
slack:token - The token of your Slack bot. Make sure it has the right permissions setup to send messages.
Usage
Note: Make sure you have setup your configuration file
simplert.discord(message,[send_to])
Send a message to a discord channel.
send_to
can be optional if it is specified in the configuration file underdiscord:send_to
as the default, otherwise it needs to be passed in as the second argument
const simplert = require("simplert");
simplert.configure("simplert.json");
simplert.discord("some event"); //assuming discord:send_to is set in config file
simplert.discord("some other event", "general"); // send to a different channel
simplert.email(body,[send_to, subject, send_from])
Send an email message
send_to, subject, send_from
can be optional if defaults are set under email:gmail:*
in the configuration file. Otherwise, they need to be passed as arguments to the function.
const simplert = require("simplert");
simplert.configure("simplert.json");
simplert.email("some event"); //assuming discord:send_to is set in config file
simplert.email("some other event", "email@example.com"); // send to a specific email
simplert.email("another event", "email@example.com", "Some Email Subject"); // set an email subject
simplert.email("and another event", "email@example.com", "Some Email Subject", "alias@example.com"); // set a send from alias if you use Gsuite
simplert.slack(message,[send_to])
Send a message to a Slack channel or user
send_to
can be optional if it is specified in the configuration file underslack:send_to
as the default, otherwise it needs to be passed in as the second argument
const simplert = require("simplert");
simplert.configure("simplert.json");
simplert.slack("some event"); //assuming slack:send_to is set in config file
simplert.slack("some other event", "#general"); // send to a different channel
simplert.slack("some other event", "@johndoe"); // send to a different user
Scripts
generate-config
npx generate-config
Generates a simplert configuration file. By default, all alert will be set to disabled, you will need to manually configure the necessary values in this file before using simplert.
generate-gmail
npx generate-gmail
This will generate an auth token and automatically populate the email:gmail:token
value in your configuration file. This assumes that you have email:gmail:credentials
set in your configuration file which should be set to the content in your gmail-credentials.json
file that was download from Google Cloud Console when setting up a project.
Supported Alerts
SMS coming eventually
Bugs and Improvements
Please open an issue on the repo to report any bugs or improvements as I am sure there are. I would consider this still in beta and not to be used in any critical production apps rather used for personal projects that you just want some simple alerting on.