WordPress and Slack integration using a Raspberry Pi

Purpose of the project

zapier is a awesome tool that allows you to create a form of collaboration between the services that you are using on the web.

It gives you an easy way to build workflows where actions on a given website will trigger events on another of your preferred websites. One of the recipes (zap) that you can find on zapier catalog creates a notification in a Slack discussion channel when a comment is posted on your WordPress website.

Zap description

The idea of this project is to use a bunch of Python tools (the Flask framework and the requests library mostly) to build the same functionality in a small web server running on a Raspberry Pi.

Pourquoi faire simple quand on peut faire compliqué.

Les Shadoks

Description of the workflow

When a new comment is posted on an article, WordPress sends a POST requests containing all the characteristics of the comment to a predefined URI.

Running on the Raspberry Pi, a Flask webserver receives the POST request that is sent by WordPress and automatically translates it in the format that is expected by the Slack incoming webhook API.

The webserver will use the requests Python library to send a POST request to the Slack incoming web hook API containing the message to be published in the discussion channel.

Final state of the tool

As you can see in the screencast below when a comment is added to the blog, a message containing all the characteristics of the comment is added in the target Slack channel. A notification is fired by Slack (Upper right side of the screen) and the message appears on the left part of the screen in the Slack conversation.

Demo of the tool

And of course, the message can be viewed in all the different Slack clients.

Same conversation on an Android phone

What did I learn?

This project was my first project with my Raspberry Pi. I learned a lot on how to set up a web server on this small machine and how to forward ports from the router to the Pi.

It was also my first project with Flask. I learned some basic knowledge of how a REST API can be built using this framework.

I also learned that you can be really happy with a functioning application that is made of only 20 lines of code!


I started with the official Slack and WordPress API documentation websites.

Most of the resources on Python Flask have been found on Miguel Grinberg’s Blog.
In particular, I used his post on how to build a REST API.

For the installation of Flask on the Raspberry Pi, I started with Matt Richardson’s blog and I then used the Raspberry Pi official website

To teach myself how to use the requests python library, I used their official website.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s