github.com/simpleiot/simpleiot@v0.18.3/docs/ref/notifications.md (about) 1 # Notifications 2 3 (see notification [user documentation](../user/notifications.md) 4 5 Notifications are messages that are sent to users. There several concerns when 6 processing a notification: 7 8 1. The message itself and how it is generated. 9 2. Who receives the messages. 10 3. Mechanism for sending the message (Twilio SMS, SMTP, etc) 11 4. State of the notification 12 1. sequencing through a list of users 13 2. tracking if it was acknowledged and by who 14 5. Distributed concerns (more than one SIOT instance processing notifications) 15 1. Synchronization of notification state between instances. 16 2. Which instance is processing the notification. 17 18 For now, we assume all notifications will be handled on a single SIOT instance 19 (typically in the cloud) -- distributed aspects of notifications will 20 implemented later. 21 22 Notifications can be initiated by: 23 24 1. rules 25 2. users sending notifications through the web UI 26 27 ## Notification Data Structures 28 29 Elsewhere in the system, configuration and sensor data are represented as 30 Points. The Point data structure is optimized for synchronization and algorithms 31 where simplicity and consistency allows us to easily process points with common 32 code. But a Point does not have enough fields to represent a message or 33 notification. We could encode the message as JSON in the Point text field, but 34 it would be nice to have something a little more descriptive. Additionally, all 35 notifications and messages should be stored in the time series database so there 36 is a history of everything that was sent. 37 38 Time series databases like InfluxDB store records with the following attributes: 39 40 - timestamp 41 - measurement (similar to collection, bucket, or table in other databases) 42 - keys (string only, indexed) 43 - values (can be a variety of data types: float, integer, string, boolean) 44 45 Notifications will be handled by two data structures: 46 47 - Notification 48 - typically generated by a rule or a node that is directly sending a message 49 - stored in main database as they may contain state that needs to be processed 50 over time 51 - Message 52 - an individual message to a user (SMS, Email, voice call) 53 - stored in time series database as they are transient 54 55 Notifications are initiated (as is all write data in the system) by 56 [sending a message](api.md) through NATS. The typical flow is as follows: 57 58 rule -> notification -> msg