How to create a Slack app with JSON feed

Posted by
Senior Engineer

As part of our standard client service here at Moove, we ensure that all of our client sites are updated as soon as a new WordPress release becomes available, particularly important security patch releases. To assist us with this, we have created an application that pulls information about new WordPress releases in to Slack so that every member of our team is notified instantly of new versions. This feed is served by WordPress REST API in JSON format.

For this particular functionality, we implemented the following steps:

#1 Create the Slack application

#2 Set up a server side application to handle JSON from WP REST API

#3 Create incoming hooks to connect the server app with the Slack app

  • We chose a Slack module called ‘Incoming Webhooks’ which is a really easy way to post a Slack message from an external source (server side application).
  • Every time you want to get access to the new channel you need to create new webhook. Once this is created, you will get a unique URL where you can send a standard HTTP POST with JSON payload.
  • This payload is built up with many options, for more information see Slack API messages.

Slack Integration Webhooks

  • Immediately after receiving the webhook URL, you can build the server application.
  • Build a short script (e.g. PHP) which will handle the JSON response and send a message to the Slack channel in a desired format.
  • In global, there are many techniques to make HTTP POST/GET but to speed things up, we used Unirest which is set of lightweight HTTP libraries publicly maintained by Mashape.
  • Once the server side application/script is completed, transfer it to the server or run it locally. In our setup we moved it to our own server.
  • After this, setup a cron job otherwise you will need to run it manually which won’t have the desired effect to automatically check for WordPress releases.

Once it is created you can easily customise it with colours and a logo:

Slack API WordPress

And that’s it! We hope this helps you to stay up to date with important WordPress releases. If you’ve created any useful Slack apps that have improved your workflow then let us know!

 

Let's connect

  • Have you got a web development project you need help with? Get in touch.
  • Subscribe and get our latest news and insights delivered directly to your inbox!

posted by
Senior Engineer

Radek holds a Masters degree in Informatics. He is a very experienced developer and has worked with many of our clients including Which? In his free time, Radek likes to travel and he also plays football for his local club - he’s been playing for them since he was 6 years old!

all articles by