Slack Archiver

07.02.2019 / slack archiver

UPDATE: As of 2020, I decided to rewrite the application into Java Spring Boot backend and using Angular 8 as the frontend.

 

So my friends and I, we got this group and it has around 20 members that are active. We used to use the facebook messenger but you can imagine how easily it was flooded with messages about multiple topics. We decided to convert to the Slack and reorganize into channels (for study purposes, events etc.) However, the free slack shows up only the most recent messages and this is very inconvenient when looking up the old messages.

I found out about the Slack API and decided to do something about it. Around a year ago, I got an idea how to reduce this problem by deleting the messages that was the least important – the huge spams in the #_general channel. However, we got into a situation where we'd want to search something in this channel and so this was a no-go (beside, it didn't recovered the old messages)

That's when I decided to write the Slack Archiver which stores the messages and files into my hosting. It was initially written in Python but then I converted it to PHP since Wedos webhosting supports only it. Now the script is called twice a day (exactly at 00:00 and 12:00). As far as the images are concerned, they are compressed into low quality so I don't flood my hosting.

Initially, I had to somehow parse the JSON content of message from the API, and even then parse the message because the Slack supports the channel tagging, user tagging and this is stored up in a special format. However, as the time passes, I again, forgot about the project and stopped the development. Last week, I re-opened this unfinished project and decided to finish it since I got two-weeks break before the summer semester starts but I found out they changed a little bit the format so I had to re-write the changes.

An example of how the message looks like:

"messages": [
        {
            "type": "message",
            "text": "lorem ipsum <#(CHANNEL_ID)|_general>, <@(USER_ID)>, <https:\/\/www.google.com\/>",
            "files": [{...}],
            "reactions": [
                {
                    "name": "+1",
                    "users": [...],
                    "count": 4
                }
], ... }
]

And the output would look like this:

Beside the main feature, it can retrieve and parse the reactions, replies and emojis. Slack API provides only for custom emojis so I had to write a fast JS script that would take out the emojis available in the slack. 

At this moment, the slack archiver can do:

  • fancy message format with all the slack features
  • back up the messages from all public channels
  • back up all the files except for the videos. The images are compressed so it doesn't flood the hosting
  • search messages and files with a smart filter (filter by user, by the time interval and by the channel)
  • statistics on the back-up messages

Date: January 2018

Technology: Fomantic UI, HTML, CSS, PHP (formerly Python)

Images: