Event handling/handler¶
Event handling offers you the option of triggering predefined actions for certain events. Predefined action types such as SMS or email can be used for simple signals. For more complex actions, Tripshare also offers webhooks, i.e. a URL is called up on the Internet and the event data is transferred via POST.
Create handler¶
To do this, click on the symbol in the handler overview
Standard fields¶
Each handler has two standard fields for Name
and Description
.
Give your handlers a name and a description so that they can be clearly identified in the overview list.
Device list¶
Handlers are assigned to their devices. You can select one or more devices that serve as a source for events.
To do this, scroll through the list of your devices; you can also enter a filter text as shown in the example so that only devices containing the text are displayed. If you only have a few devices, it is usually not necessary to use filters.
Event code¶
Use the event code to specify the events that trigger the action. The list contains the event codes of the Tripshare platform.
You can select various codes from the list or the entry - all -
, which selects all events.
Info
The event code POSITION
is only evaluated for the handler type Webhook
. Actions such as email, SMS or Telegram can otherwise block the call of the hook at very short time intervals, as quotas are reached very quickly.
The WEBHOOK type may only be available at a higher rate! Please contact support@protegear.com
Handler type¶
Depending on the type of handler, you can enter different data
EMail¶
You can generate the subject and content of the email using templates. Please note that automatically generated emails can often get stuck in SPAM filters.
You can use the following template to send an email with all data for debugging purposes:
1 2 3 4 5 6 7 8 9 10 |
|
SMS¶
Info
SMS messages are subject to a charge
If the content of an SMS is generated dynamically, it is essential to ensure that the content is short, as otherwise long texts are sent with the help of individual SMS’s and these are each subject to a charge.
Telegram¶
Telegram supports a subset of HTML tags that you can use. It is recommended to use as little formatting as possible, as unsupported tags/formats will cause Telegram to reject these messages.
You can obtain the ChatId
by adding our ChatBot with the name @ProtegearBot to your desired chat in the Telegram app on your smartphone. If you do not yet have a chat, click on the link above to create a chat. If the bot is a member of the chat, you can use the command /chatid
to request the ID of the chat. The bot will display this and you can enter this ID in the field provided.
Info
If you have an existing chat that you want to use as a channel, please add @ProtegearBot as a member. A click on the link creates a new chat instead or selects an existing chat between you and the bot.
Slack¶
In addition to the message, which you can generate dynamically, you must also enter the URL of your webhook for Slack support. To find out how to create such a webhook in Slack, please refer to the description at Slack.
Webhook¶
A webhook is a URL that terminates on the Internet at a server of your choice. You can enter any URL you want here. However, to ensure a certain level of security, the following options are available:
- Enter a URL that contains special parameters that only you know and that you check on your server
- Enter values in the ‘Headers’ field that our system then sends to your server as HTTP headers. In contrast to URL parameters, header parameters are not normally visible in logs
- Use an HMAC with a secret key. You can then use a few lines of code to check whether the 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. The check should always be activated in productive systems.
Events are passed to the webhook. In contrast to the other handlers, there are no templates or similar here. Instead, the hook is called for incoming events. However, it is not guaranteed that a webhook always contains exactly one event. If there are many events, the system can also send them as a batch. ##### Test webhook
You can use the ‘Send Test Message’ button to test the webhook with a dummy event at any time.
Alternatively, you can also send real data to your system. To do this, select a start and end date. Tripshare will then select the events from this period and send them to your webhook. You can use ‘Count Events’ to count in advance how many events in our database match the criterion and only then send the data using ‘Push Events’. Use the batch limit to define the maximum number of events to be transported per request.
Handler content¶
You can define the data to be transferred for each handler. To do this, you can design the content of the message dynamically using Go Templates.
Each template receives the data of the event and the device in the fields .Event
and .Device
. As the template language of go
is used, you must know these field names to access the fields.
The data structure for Device is as follows:
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 |
|
Ein Event hat folgende Struktur:
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 |
|