Notifier Module

"Only a life lived for others is a life worthwhile." – Albert Einstein

MODULE NAME


generic_notifier

-modules/genericnotifier.py

DESCRIPTION


The notifier module is responsible for dispatching notifications to smartphones & servers through various means. The notifier module currently supports sending notifications using the telegram API and over HTTP/HTTPS. You do not need to work directly with the module’s codebase. Rather, whenever you need to send a notification using the notifier module you simply need to broadcast the specific Intents which will automatically trigger the notification dispatching logic.

CONFIGURATION


modules/conf/genericnotifier.json

{
	"enabled": true,
	"klass": "GenericNotifierModule",
	"conf": {
		"api":{
			"enabled": false
		},
		"notification":{
			"telegram":{
				"bot_token": "",
				"chat_id": []
			},
			"http":{
				"webhook": [],
				"method": "GET"
			}
		}
	}
}

CONFIGURATION PROPERTIES


PropertyDescriptionValue TypeDefault Value
enabledenable/disable the moduleBooleanTrue
klassThe python class name for this moduleStringGenericNotifierModule
conf.api
conf.api.enabledEnables/Disables HTTP API for pushing notificationsBooleanTrue
conf. notification
conf.notification.telegram
conf.notification.telegram.bot_tokenTelegram bot tokenStringNA
conf.notification.telegram.chatidList of different telegram chat ids to send notifications to.Array[ ]
conf.notification.http
conf.notification.http.webhookList of HTTP(s) endpoint that will handle/receive notificationString[ ]
conf.notification.http.methodHTTP method (GET/POST) that the webhook expects.String (GET/POST)GET

NOTIFICATIONS

The Generic Notifier module is all about sending notifications. At its current state, it can send messages using telegram API & Generic HTTP calls to remote servers. That said in the future more communication channels can be augmented into this. The notifier module normally works in conjunction with reaction rules that help trigger the notifications.

Given below is a sample reaction-rule format for broadcasting an Intent using telegram. The rule listens to the /capture/path topic path (The topic you want to listen to) and on receiving an event on the topic path it broadcasts the Intentsimple_telegram_notify along with other essential parameters – bot_token (telegram bot token) & chat_id (an array of chat ids to which the notification must be sent to).

NOTE: TO USE REACTION RULES YOU NEED TO HAVE REACTION MODULE INSTALLED

Sample Reaction Rule – reaction-rule-telegram-notify

{
	"id": "reaction-rule-telegram-notify",
	"description": "Rule for triggering telegram notification",
	"listen-to": "/capture/path",
	"enabled": false,
	"trigger":{
		"on-payload-object": {
			"key":"data",
			"on-content": "*",
			"on-condition": "equals"
		},		
		"evaluator": null
	},
	"response":{
		"nonce" : false,
		"intent": "simple_telegram_notify",
		"parameters": {
			"telegram":{
				"bot_token": "",
				"chat_id": []
			}
		}
	}	
}

The notification message is usually constructed through the source event data. If you wish to override the message data with your own custom message, you can add the attribute message to the telegram JSON object and set it with the value you want to send as the message.

"telegram":{
    "bot_token": "",
    "chat_id": [],
    "message": "My message"
}

NOTE: TO USE REACTION RULES YOU NEED TO HAVE REACTION ENGINE MODULE INSTALLED

Sample Reaction Rule – reaction-rule-http-notify

{
	"id": "reaction-rule-telegram-notify",
	"description": "Rule for triggering telegram notification",
	"listen-to": "/capture/path",
	"enabled": false,
	"trigger":{
		"on-payload-object": {
			"key":"data",
			"on-content": "*",
			"on-condition": "equals"
		},		
		"evaluator": null
	},
	"response":{
		"nonce" : false,
		"intent": "simple_http_notify",
		"parameters": {
			"http":{
				"webhook": []
			}
		}
	}	
}

The above reaction rule listens to the topic /capture/path and on intercepting data, broadcasts an intent by the name simple_http_notify to trigger the process of sending HTTP notifications to the list of HTTP(s) endpoints defined by the attribute webhook.