Get real-time device offline notifications via Slack messages and webhooks,
Dataplicity notifications for Slack allow you to send device offline notifications directly to a Slack channel.
First, create an "Incoming Webhook" app for Slack. Install "Incoming Webhooks" from the Slack App Directory. The link below will take you directly there, though you'll have to swap <your_slack_workspace> with the domain name of your own Slack workspace.
Create a new Incoming Webhook in Slack and select a channel to be the destination for notifications.
You can later tweak the icon, descriptive label and the username the Webhooks will report as in Slack.
Only the Slack Webhook URL and the destination channel are really important here. The remaining fields are cosmetic and can be adjusted without consequence. See the Slack documentation for specific details.
Take note of the Slack Webhook URL and go back to dataplicity.com. Open Profile/Settings at dataplicity.com and enter the Slack Webhook URL in the Slack Webhooks section. Hit save.
Now when devices go offline and online, you'll get notifications in Slack via this Webhook! You can test this by rebooting a Dataplicity-enabled device in your account.
The webhook for device status field will send out a notification every time the device goes online/offline.
For this example, we use the webhook.site demonstration environment.
When you visit the webhook test site, take a note of the randomly generated unique URL that appears.
Go back to dataplicity.com, open Profile > Settings, and scroll down to the section about Webhooks.
Put the webhook test URL into the URL box at dataplicity.com. Hit save and you're done!
Now let's try rebooting your device to generate the notification.
Inside the terminal in the right hand pane click the Reboot button and confirm.
Rebooting the device will cause the device to drop off the network and (if your device is configured to do so) reconnect after the reboot. Both of these events will have generated webhook notifications that should now appear at the webhook test site.
When the device goes offline, the following message is generated:
And when the device returns, this is the second generated message:
Now you don't need to wait for your customers to tell you your device is offline, because you'll know before they do!
Updated 4 months ago