I want to know when my hive-engine witness goes down and so I use the Integromat automation tool. Integromat has a lot of really useful tools which I use to take a lot of drudge work out of my life. The free tier is sufficient for this particular task. Also, you won't need to use any of your keys. So, head on over to Integromat and signup.
Integromat automations are called scenarios. Start by creating a new scenario with any title you choose. This particular scenario will use two modules with a filter between them.
Ok, add your first module by clicking the + plus sign on the right side of the toolbar. Type HTTP into the search bar and select the HTTP module (the blue globe).
Once the HTTP module is added, then click on it to edit the settings. Set things as shown in the image. I'll list the settings to make them cut and paste-able.
URL: https://api.hive-engine.com/rpc/contracts
Method: POST
Body type: RAW
Content type: JSON (application/json)
Request content:
{"id":1,"jsonrpc":"2.0","method":"find","params":{"contract":"witnesses","indexes":[],"query":{"account":{"$in":["yourwitnessaccountnamehere"]}},"table":"witnesses"}}
Ensure you put your own witness account name in the correct place. And finally, enable Parse response. Press OK.
This is basically a manual way of constructing a JSON-RPC query, and specifically a hive-engine RPC query and sending it to the main hive-engine API node. You want to use the main hive-engine API node to ensure that you're testing whether or not your witness can be seen by other witnesses.
Now, save the scenario (disk icon on the toolbar). Then press "Run Once". What this does is contact the API node and download the JSON response. We need this to make the next step easier.
The next step is to add (+ icon on the toolbar) the Android module. Once the Android module is on the canvas, drag it until there is a link between the HTTP and Android module. Then click on the Android module to open the settings. Add a new device and follow the steps to install the app on your phone and link it with your account. The device name you choose here doesn't matter because you'll link the device via scanning a QR code later.
Finish setting out the Android notification to your desires. This image shows the text message I choose, and as a convenience, will open the witness page on tribaldex if I click on the notification. Finally, click on OK.
Now we need to filter the result from the API node so that it only sends notifications if the witness is down. Click on the little filter icon and setup the filter as shown. The key thing is to select the blue part of the condition like this...
If results don't show then check that the HTTP module is setup correctly and then press Run once. What this condition does is select the enabled property from the JSON-RPC results and only allows further execution if the enabled property is false. Then click Okay.
Next, test that the scenario is working by click Run once. If you're happy with how it's working then save using the disk icon on the toolbar. You will need to add scheduling to make have the scenario run automatically. Select whatever schedule suits you - each run will use 2 operations and around 900 bytes so this will fit within your free tier provided you don't schedule too often. I choose 15 minutes.
Finally, enable scheduling, save again for good luck and you're down. You can check your resource usage on the dashboard. If you're running out of free tier resources then you can increase the time between calls.
I hope you find this tutorial useful. And, have fun exploring the facilities that Integromat has to offer. Until next time.