Notifier is a free tool to send notifications or messages to a variety of channels. The message is template-based. We store the template in Notifier then send a request to Notifier with matching payload to populate the message content.
- Send email through SMPT
- Send email through Amazon SES using API key
- Send email through Brevo using API key
- Send message to Whatsapp
- Send message to Telegram
- Send message to Slack
-
Create templates.
Templates are stored in/templates
directory. We can create a template inside subdirectories under/templates
. It is recommended we have the template with bothhtml
andtxt
format as the email sender function will try to render both formats. For example, we have/templates/en/sample.hello.html
and/templates/en/sample.hello.txt
. Then, in the HTPP request body we can select the template by setting thetemplate
field toen/sample.hello
. -
Create and configure
.env
file based on.env.sample
. -
Install dependencies.
pnpm install
# development
$ pnpm run start
# watch mode
$ pnpm run start:dev
# production mode
$ pnpm run start:prod
-
An example of
docker-compose.yaml
configuration is available here. -
Configure your
.env
file based on.env.sample
. -
Bind your templates directory to
/app/templates
directory in the container.
To send an email, send a POST
request to http://<your_host>:<your_port>/send
. The body parameters are as follows.
is_sync
: boolean.
Default false. Setting mode to synchronous or asynchronous. If the client wants to receive the email sending result, it can be set to true (synchronous).method
: “smtp” | “ses” | “brevo”.
Default “smtp”.to_email
: string.
Receiver's email address.to_name
: string.
Receiver's name.template
: string.
It is required if themethod
is not “brevo”. It is not required if themethod
is “brevo” andbrevo_template
is not empty.subject
: string.
Subject of email.payload
: object.
The content depends on the target template.brevo_template
: string or number.
Template number in Brevo. It can be used if the method is “brevo”.
For example:
{
"is_sync": true,
"to_email": "lukibsubekti@gmail.com",
"to_name": "Luki",
"subject": "Registration Success",
"payload": { "fullName": "Luki", "url": "http://google.com" },
"method": "smtp",
"template": "en/sample.hello"
}
- Schedule notification
- Send notification status through webhook
- Error logging
Notifier is MIT licensed.