Event handling¶
Event handling gives you the option of triggering predefined events for certain events Trigger actions. For simple signals, predefined action types such as SMS or e-mail can be used. For more complex actions, Protegear also offers Webhooks, i.e. a URL is called up on the Internet and via POST the Transfer event data.
Use the symbol to create a new handler or click on
a handler to edit it.
Basic data¶
In addition to a name and a description, each handler also has a switch that activates the handler. Only active handlers are executed by the system.
In the list of event codes, you can select the events for which the handler should be triggered.
You can select several codes here or the entry - all -
, which selects all events.
Info
The event code POSITION
is only evaluated for the handler type Webhook
, as with devices
too many emails or text messages could be sent at very short intervals.
Device list¶
At the bottom of the page, specify the devices for which the handler should be triggered. You can select one or more devices here.
Content¶
You can define the data to be transferred for each handler. To do this, you can the content of the message using Go Templates dynamic design.
Each template receives the event and device data in the .Information
fields,
Contacts
, .Event
and .Device
are transferred. As the template language of go
is used,
you need to know these field names to access fields.
The .Information
Field contains the data that is stored in the organisation’s settings in the
Field Information are saved.
The .Contacts
is the list of contacts that are stored in the Protegear
Console can be maintained. The sequence is undefined, i.e. there is no special
Sorting. A contact has the following data structure:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
The data structure for Device is as follows:~go
type Device struct {
ID string json:"id"
SecondaryID string json:"secondary_id"
Name string json:"name"
Changed time.Time json:"changed"
ChangedBy string json:"changedBy"
Type DeviceType json:"type"
Organization string json:"organization"
Comment string json:"comment"
ContractID string json:"contractid"
Rate DeviceRate json:"rate"
Firmware string json:"firmware"
Configuration DeviceConfiguration json:"configuration"
Status DeviceStatus json:"status"
EventLifetimeDays int json:"eventLifetimeDays"
}
type DeviceConfiguration struct {
Activation ActivationType json:"activation"
GSM bool json:"gsm"
Satellite bool json:"satellite"
RescueService bool json:"rescueService"
RescueType RescueType json:"rescueType"
ReceiveMessages bool json:"receiveMessages"
}
type DeviceRate struct {
Active string json:"active"
Inactive string json:"inactive"
}
type DeviceStatus string
type ActivationType string
type RescueType string
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
Example¶
SOS notification¶
To send an e-mail in the event of an SOS event, you can use the following code:
Subject template:~
SOS from {{.Device.Name}} ({{.Device.ID}})
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
Handler type¶
A distinction is made between different types of handlers. Each handler type has its own Settings.
EMail¶
Email handlers send an email when an event occurs. In the handler, you define the Recipient, the subject and the content of the email.
If you use a globalmail address, the handler can use the email address associated with the device as the sender address if you select this option.
SMS¶
Similar to the e-mail message, you can also send an SMS. Here you can the text of the message may also contain variables. Please note that an SMS can only contain 160 characters and the number of the recipient in the international Format must be specified.
Note
Please note that every SMS message incurs costs which your Debit account.
Telegram¶
Telegram handlers send a message to a Telegram chat. To do this, you must
enter the chat ID and the @ProtegearBot
to your chat group. You can use the /chatid
command to add the bot to your chat group
ask for the correct chat ID.
Telegram supports a subset of HTML tags that you can use. It is it is advisable to use as little formatting as possible, because if the formatting is not supported tags/formats, these messages will be rejected by Telegram.
Slack¶
Slack handlers send a message to a Slack channel. To do this, you must enter the webhook URL of the channel.
Webhook¶
A webhook is a URL that terminates on the Internet at a server of your choice. You you can enter any URL you want here.
You should not normally change the values for Rate limit and Concurrency. You can use these values to limit the number of simultaneous requests that are sent to your server or the number of requests per second. The default values should be sufficient for most applications. However, if you require special Requirements, you can change these values. If you are working with a very high load please contact our support team, who will be able to assist you.
The following options are available to ensure a certain level of security:
- Enter a URL that contains special parameters that only you know and that Check on your server
- Enter values in the field
Headers
Field, which our system will then send as HTTP headers to To your server. In contrast to URL parameters, header parameters are normally not to be seen in logs. - Use an HMAC with a secret key. You can then use a few lines Code check whether the key you have incoming request was sent by Protegear.
If your server has an insecure certificate (selfsigned), please activate
the Skip TLS Check
switch.
Warning
Switching off the TLS check is only recommended for testing/development. In productive Systems, the check should always be activated.
A list of events is always passed to the webhook. In contrast to the other handlers, there are no templates or similar. Instead, the hook is called for incoming events. It is however, it is not guaranteed that a webhook always contains exactly one event. If if there are many events, the system can also send them as a batch. Your webhook must therefore always process a list of data records; if the load is very low, this list is List usually consists of only one element.
Test Webhook¶
You can use the Send Test Message
button to link the webhook to a dummy event at any time
test.
Alternatively, you can also send real data to your system. To do this, select a
Start and end date. Protegear will then select the events from this period and
to your webhook. You can use Count Events
to count in advance how many events in
of our database match the criterion and only then with Push Events
the data
send. Use the Batch limit
to specify the maximum number of events per request
be transported.