Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .noah.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ monitor_interval=1 # time to wait after a lo
# example would be notification_drivers=(log slack pushover)

notification_drivers=(log) # notification methods...
# values: none, log, email, mailgun,
# slack, nexmo, pushover, pushbullet, discord
# values: none, log, email, mailgun, slack, nexmo
# pushover, pushbullet, discord, twilio_call, twilio_message

# -------------------------
# [Notifications] Log
Expand Down Expand Up @@ -94,6 +94,20 @@ notifications_mailgun_from='noah' # sender name...
notifications_mailgun_to='' # recipient e-mail...
notifications_mailgun_subject='noah' # e-mail subject

# -------------------------
# [Notifications] Twilio
#
# twilio_call will call you if there's a problem with your node. Be aware that it can be
# very annoying, specailly during the night. Consider using the Night Mode if it annoys you.
#
# -------------------------

notifications_twilio_account_sid='' # twilio api client id...
notifications_twilio_auth_token='' # twilio api token...
notifications_twilio_from='' # caller phone number (In this convention: +15551234567)
notifications_twilio_to='' # recipient phone number (In this convention: +15551234567)


# -------------------------
# Night Mode
# -------------------------
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ If you wish to use **Mailgun** as your notification driver you will need to sign

If you wish to use **Slack** as your notification driver you will need to sign up for [Slack](https://slack.com) and create an [Incoming Webhook](https://api.slack.com/incoming-webhooks).

### Twilio

If you wish to use **Twilio** as your notification driver you will need to sign up for [Twilio](https://www.twilio.com). With a trial account, you can send unlimited calls and sms to the number you use on the sign up process (your phone number).

`twilio_message` will send you SMS, and `twilio_call` will call you when there's a problem with your node. Be aware that `twilio_call` can be very annoying, specially at night, so you might want to use the Night Mode if you enable it.

## Commands

```bash
Expand Down
24 changes: 24 additions & 0 deletions modules/notifications.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,24 @@ notify_via_discord()
-F content="$1"
}

notify_via_twilio_call()
{
curl -X "POST" "https://api.twilio.com/2010-04-01/Accounts/$notifications_twilio_account_sid/Calls.json" \
--data-urlencode "Url=http://demo.twilio.com/docs/voice.xml" \
--data-urlencode "From=$notifications_twilio_from" \
--data-urlencode "To=$notifications_twilio_to" \
-u "$notifications_twilio_account_sid:$notifications_twilio_auth_token"
}

notify_via_twilio_message()
{
curl -X "POST" "https://api.twilio.com/2010-04-01/Accounts/$notifications_twilio_account_sid/Messages.json" \
--data-urlencode "From=$notifications_twilio_from" \
--data-urlencode "Body=$1" \
--data-urlencode "To=$notifications_twilio_to" \
-u "$notifications_twilio_account_sid:$notifications_twilio_auth_token"
}

notify()
{
local datetime=$(date '+%Y-%m-%d %H:%M:%S')
Expand Down Expand Up @@ -100,6 +118,12 @@ notify()
discord)
notify_via_discord "$message"
;;
twilio_message)
notify_via_twilio_message "$message"
;;
twilio_call)
notify_via_twilio_call "$message"
;;
*)
:
;;
Expand Down