in Development, Infrastructure, Scripting

Faking Web to SMS so Synology can Notify via Slack

As bits of hackery go, this is pretty niche. I have a bunch of storage in a Synology Diskstation – this can send various notifications in case disks fail, components get too hot, or other bits of the system break down in ways that require immediate attention. It can send emails, you can use their app to enable push notifications to your phone and if you really want to you can have it send you SMS (actual SMS, in 2017?!). What it can’t do out of the box is send a message to a Slack channel.

I really like Slack. As well as running a paid instance of Slack with my teams at FISCAL, I have a separate (free) one for friends and family and for running experiments with bots and other integrations. So I wanted the Synology, like most of my other house/home automation devices, to talk to Slack. The easy way would be to make the Synology send an email to the Slack email integration – except the email->Slack integration is only available to paid Slack instances. So what to do?

It turns out that the SMS notification works by just sending an HTTP GET to a URL with a bunch of stuff in query strings. So if you can send that request to your own script you can grab the message and send it on to a Slack incoming-webhook.

To keep everything as local as possible I enabled the web server on the Synology itself and wrote a small PHP script to parse the message and send it to Slack. I know, I know, PHP, ew. It was quick to build and quick to get running on the Synology.

Use any PHP enabled webserver that the Diskstation can see and host this file on it. You’ll need to create the incoming-webhook in Slack, and alter the script to include the correct URL and payload details.

  • On the Diskstation, in the Control Panel -> Notification, select the SMS tab.
  • Check Enable SMS notifications, and then click Add SMS service provider.
    You’ll be prompted to create the new service provider.
    I called it SlackIt and added the SMS URL in the form:

  • It will list the parameters we put in the URL and allow you to map them to the things the Synology will know about. You have to map them all, but the key one for us is the message param.

  • With the service created, you can fill out the details it “requires”. You can put x in for username, password, confirmation and zeroes for the phone:

  • Now, hit Send a test SMS message and you should see it appear in your Slack channel.

Check out the Advanced tab under Notification to see what else you can have the Synology alert on. I’ve enabled all the major failures, as well as all the stages of array rebuilds and consistency checks: