Slack notifications on Raspberry Pi

For those of you who haven’t heard of or used Slack, it is a great communication tool that is used in many modern workplaces. It is a chat tool that reduces the dependence on emails, and allows for quicker more efficient communication in the office.

The beauty of Slack is that it is free to use (there is a paid-for subscription for enterprise level usage) but can be integrated with a wide variety of third-party applications, as well as being able to utilise incoming and outgoing webhooks.

Slack controlled On-Air sign

This is an example of how I use Slack every day at work in my job. As I often speak to important enterprise customers, often from other countries, I found that it often became noisy whenever the guys upstairs needed to grab another cup of coffee. Being a fan of all things IoT, I decided to build an On-Air sign that could be controlled via Slack, so that I could quickly turn the sign on whenever I was on an important call. I’ll be writing up a separate post on this particular project, but being able to control it via slash commands in Slack was really useful and we now use it every time we have a conference call with a customer.

This (pretty badly shot) video, should give you an idea of what is to come when I get the project on here:

Raspberry Pi Twitter Follower Bot

I tend to check how many Twitter Followers I have every now and then, as I’m always looking to spread the word about Raspberry Pi and Raspberry Coulis where possible. I then thought it would be pretty nice if I could automate this process using a Raspberry Pi and some Python code.

To save making this post unnecessarily long, I have included detailed instructions in the README.md file on my GitHub repository, which will guide you through the necessary parts, but if you are after the code then here it is:

If all goes well, you should receive a Slack notification telling you how many followers your account has!

If your code works, you should get a Slack notification that tells you how many followers your Twitter account has

If your code works, you should get a Slack notification that tells you how many followers your Twitter account has

As I’m still learning Python and all things Raspberry Pi related, I’d welcome any feedback on this code via my Gist.

Raspberry Pi Facebook Fan Bot

In similar fashion to the Twitter Follower Bot above, the Facebook Fan Bot works in a very similar way. The great thing about this script is that you only need to add a few access keys, secrets and ID’s to get it working.

Again, to save repeating myself in here, take a look at the README.md on my GitHub repository that tells you how to get and add the necessary keys and IDs to your script. This is what it looks like:

And if successful, you should get another Slack notification that looks like this (assuming you have added the custom icons included in my repository):

If your code works, you should get a Slack notification that tells you how many fans your Facebook page has

If your code works, you should get a Slack notification that tells you how many fans your Facebook page has

If you would like to provide your feedback, please feel free to do so via my Gist.

Automating Slack Notifications on Raspberry Pi

Rather than have these scripts run constantly, bombarding your with Slack notifications, it may be better to schedule them via cron to run at specific times of the day. Unless you are uber-popular, like the official Raspberry Pi Twitter account, then checking on your followers once or twice a day ought to be enough.

Cron can appear confusing at first, but if you use a crontab generator then this whole process is a lot easier to manage. In my setup on my Raspberry Pi, I have my Twitter Follower Bot and Facebook Fan Bot checking in the morning and in the evening, which is perfectly adequate for me.