Presence Scheduler


Ever wonder how our presence scheduler works to keep you active on slack? In this article we talk about how it works as well as some of the challenges we came across while creating this app.

Presence scheduler is an Slack application registered and created through the slack.com website. The ‘Presence Scheduler’ app lets you grant permissions to the owner of the app to perform some actions on your behalf - ie keep your status active. To do this, it uses the Slack API - this is where all of the permissions get granted and how we can interact with your slack channel to keep you active without ever logging into your slack account.

Once we have your permission we keep use the slack API to keep you active. With the free version of the app, we use the ‘set.Presence’ method this will keep your status turned to ‘auto’, and if you don’t know what that means, read more about the type of presence !!!here!!!. With the paid version of the application, we use a number of methods to help keep you active - and its not just as simple as simply sending a request to slack. Its much more complicated to force a use to stay active because there is no API endpoint specifically designed for this.

For the free version, we needed to send a message to slack every 15 minutes, to do this we used ‘cron’ which is a time based scheduler in linux, and set its schedule to execute every 15 minutes. When executed it runs a php script which checks all of the schedules on the presence scheduler site and sends a request to slack (using the set.presence method) to keep that slack channel online.

Since it takes a few seconds to get a response from the API for each request sent, we noticed that if the app got any bigger, it would actually take longer then 15 minutes to send all of the requests, and this would lead to problems with the scheduler. To fix this, we actually created a number of cron jobs which would execute different php scripts, and then these scripts would organize the users into groups of 50 so that - no matter what - the time it would take to send all of the requests to slack would be under 2 minutes. This solved most of our problems relating to scheduling and is how the app is currently functioning.