Send Synology Notifications to Slack

Synology DSM (NAS devices) and SRM (routers) software offers decent customization options for sending critical notifications. You can choose from email, SMS and push, but currently Synology does not support online messengers.

I love running a private Slack workspace for all of my automated notifications, history, bots and other automations. Fortunately, Howard discovered a small tweak that makes it possible to redirect Synology SMS notifications to your Slack channel.

Free Slack Plan

You can create your own Slack workspace with up to 10k searchable messages, 10 apps and integrations, 1-to-1 video calls, and two-factor authentication. Sign up here.

First of all, you need a Slack workspace where you have control over apps (i.e., you have admin rights). Next, create a new app (you can create a new Synology app or use one of your existing apps). Finally, go into Incoming Webhooks section of this app and get your incoming webhooks URL (it will start with https://hooks.slack.com/…).

Now you need to create a simple PHP script (in this case, we called it slackit.php) and host it somewhere. You can host it on your Synology Webserver or any other external server. Do not forget to replace the webhook URL ($url) with your app’s URL and change values for #channel (e.g., #general) and bot-username (e.g., Synology). Finally, make sure that your bot has been invited in this channel.

<?php
$url     = "https://hooks.slack.com/services/[Incoming-Webhook-URL]";

$msg = "Test";
parse_str($_SERVER['QUERY_STRING'], $output);
$msg     = $output['message'];
$payload = 'payload={"channel": "#channel", "username": "bot-username", "text": "' . $msg . '"}';

$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);

curl_exec($ch);
curl_close($ch);

?>

Now you are ready to configure your Synology device. Go into Control Panel > Notifications > SMS and click on Add SMS Service Provider. Following Howard’s instructions, name the new provider “SlackIt” and use the following SMS URL (using your actual path):

http://your.host/path/to/script/slackit.php?user=x&password=x&sender=x&receiver=x&message=Hello+world

Finally, map the service parameters in the following way:

Source: Durdle.com

And on the final screen fill out random username, password and phone number (you can fill out xxxx or 0000, it won’t matter).

Source: Durdle.com

Now send a test message and hopefully you should be able to see something like this:

You can configure the types of notifications under the Advanced tab, but if you are like I am, you probably won’t mind sending all notifications to your Slack channel just to make sure you did not miss anything.

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Next Article

Using emoji in Home Assistant

We use cookies to improve your experience on our site and to show you relevant advertising. To find out more, please refer to our privacy policy.