From the Office Of Slack App

CBS wanted the ability to schedule announcements "From the Office Of," as a type of official letterhead. This was distinct from allowing an app to post directly as an individual, and instead was designed to allow a third party to post on behalf of an individual, the way that institutions often use "From the Office Of" in emails. An authorized user (see my post about limiting user access for some ways I have approached this) can schedule a post and see/delete scheduled posts from the app home.

Slack provides several methods to schedule messages (interestingly, these existed well before the ability to schedule messages was rolled out to the UI). They are scheduleMessage (which returns a message ID that allows the message to be deleted), scheduledMessages.list and deleteScheduledMessage. There is no ability to edit messages; users must delete and recreate the message.

The "See Scheduled Announcements" button lists out all scheduled messages in a block, with a button to delete each one. I did not filter them by creator; any user of the app can see all messages scheduled by anyone. This is by design, to help monitor and prevent abuse. Since the app is restricted to authorized users, the potential for abuse is in theory limited, but the added transparency seems like a good idea.

The "Compose an Announcement" button launches a modal. The user can choose the user to post as, and the app will populate their title and picture. They can choose the date, time, and any channels that they want. (They must have access to any private channels, of course.) At the time of this writing, the app can post from the office of any user; we had not decided whether or how to limit the app's user selection, but it is likely that we would choose to only allow the app to post on behalf of executives at a certain level or higher, or a specific list of individuals.

There are also a couple of strange extra features: the ability to use block kit and the ability to download files. To implement block kit, eventually I decided to search for an opening bracket as the first character, indicating a block. This seemed like an acceptable solution because very few non-block messages will just start with a bracket.

Adding attachments was a little bit more complicated. There is no block with upload capabilities at this time, although there is an upload method. But I was asked to please try.

I came up with two ways to get the user's attachments, neither ideal.

One was to add a textbox, and require users to paste the complete document path into the box, then take that input.

The second was by populating a dropdown menu from os.environ['HOME'], finding their documents folder, going into it, and building a list from there. This was much more user friendly, but I overlooked an obvious issue. The app is deployed to AWS, and cannot access the user's operating system.

In both cases, assuming a valid file path or that the dropdown method works, the app then uploads the selected file to a secret channel, gets the link to that file, formats it into a hyperlink with the text "download attachment," and adds it to the message. This approach was inelegant, but it did work for local development. A planned extension was to add a database that would store uploaded files to AWS and retrieve them at the scheduled time. This may have been implemented by having the user message the app with the uploaded file. Another feature that would have been made possible with the addition of a database is the ability to edit scheduled messages. With Slack's built-in message scheduling, it is not possible to make edits. The message must be deleted and a new one scheduled.

The app was a prototype, and has been demoed but not deployed to production.

The app features:

  • Message scheduling
  • Channel and user selection

And was built with:

  • Slack bolt
  • Python
© 2024 A Minor Studio