/pin on steroids

So, one of the Army Knife’s fans reached out to me and asked if I could make the /pin command into a reminder service (thanks, Kevin!). My initial reaction was that it was a too big task, mainly because I had to handle time zones and implement a trigger to send alerts when they are due.  However, over the next weeks the challenge kept returning to me, and it suddenly occurred to me how I could make it simple: Use a time delta format instead of time stamps, let’s say 34 hours from now, and then store the times ordered by timestamp and check if an alert is due every time the app receives a webhook from Spark.

So, that’s what I did, and you can now use Spark Army Knife as a simple task management system using the /pin command.

Let’s say there is a message from John two messages up in a room, and you need to do something about it tomorrow. You type /pin 2 +1d Remember to send John the docs and 24 hours from now, you will get an alert message in the 1:1 Army Knife room with John’s message and your comment. Your /pin command is automatically deleted, so it doesn’t clutter the room.

You can also easily add a reminder without referring to a message. In the Army Knife 1:1 room (or any room) type /pin 0 +72h Pick up the package at the office. (that’s a zero, not the letter o). Try it out! You can use minutes (m), hours(h), days (d), and weeks(w).

Another handy command: /pins will list all your upcoming reminders. Of course, the plain /pin or /pin x command still pins the message and puts it into the 1:1 Army Knife room as a reference like it used to.


I have also recently added a new very handy command: /copyroom Continued Discussions on XYZ. You see, we have several general topic, on-going discussion rooms, but then quite often specific topics are discussed, and instead of cluttering one room with multiple discussions, I use /copyroom <roomtitle> to quickly create a new room with the same members. Of course, if it’s a team room, the room will be created in the same team.

Refresh tokens and notifications

One problem you need to tackle with an integration app like Spark Army Knife is that users authorising the app leads to the app getting an access token to get access. This token has a limited life span. However, the app also gets a refresh token that can be used to get a new security access token. However, the refresh token also has an expiry, and as a privacy measure, Spark Army Knife does not do anything with notifications from the Spark platform unless there is a message from the user or the message is an @mention of the user.

This means that if the user is on vacation (or is not using Spark a lot), the token may expire without the app getting the chance to refresh it. I have done quite a lot to improve this process and have added a check if the refresh token is about to expire and then pro-actively refresh the token.

In the end, there will some situations where the app will loose access (typically low volume of received messages), so I have added a notification to users that the Spark Army Knife has lost access and that they need to re-authorize. Unfortunately, it turned out that due to an earlier issue in the app, some users have ended up with more than one account in Spark Army Knife. These users will be able to re-authorize one of their accounts, but the other account is still there without access and the user will get notifications about lack of access… This is easily cleaned up by doing /delete DELETENOW and then /init in the 1:1 room with the Spark Army Knife.

Happy Sparking with the Army Knife! (as always, the code is available on bitbucket)

Leave a Reply

Post Navigation