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
Property | Description | Value Type | Default Value |
enabled | enable/disable the module | Boolean | True |
klass | The python class name for this module | String | GenericNotifierModule |
conf.api | – | – | – |
conf.api.enabled | Enables/Disables HTTP API for pushing notifications | Boolean | True |
conf. notification | – | – | – |
conf.notification.telegram | – | – | – |
conf.notification.telegram.bot_token | Telegram bot token | String | NA |
conf.notification.telegram.chatid | List of different telegram chat ids to send notifications to. | Array | [ ] |
conf.notification.http | – | – | – |
conf.notification.http.webhook | List of HTTP(s) endpoint that will handle/receive notification | String | [ ] |
conf.notification.http.method | HTTP 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 Intent – simple_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
.