Slack recently released a bunch of APIs that allow you to interact with Lists within Slack — something that was long awaited by many of you! I hadn’t played around with this particular set of methods just yet so I decided to create something lightweight that I’ll share with you here! I wanted this to be practical, achievable and demonstrate one of the great reasons to use lists in Slack — being able to aggregate data from multiple sources.
The Problem Statement
Now I am by no means a stock trader, nor do I even dabble that much in the finance space (though I probably should learn some more — adulting, am I right?). So in an effort to enhance my financial knowledge, I decided that I want to be able to see all the data about a particular ticker symbol all in a single glance. Enter :sparkles: lists in Slack :sparkles:! With lists I can:
- Aggregate all the information about stocks that I need to know right within Slack.
- Learn about the new API methods to help others
- Prevent myself from making any excuses about it being a drag to find the news articles that I need to see to make informed choices since everything will be in one place.
If that isn’t feeding three birds with one scone, then I don’t know what is!
What are Slack Lists?
Lists are a lightweight way to organize and collaborate on work happening in Slack. They’re perfect for structured data and you can use them to manage tasks, track project work, display information and more. With many templates at your disposal, you can create a list, add items and collaborate with others directly. It is also possible to set workflows to trigger on list item changes, powering automation within your workflows.
What I Vibe-Coded (High-Level)
Since the API methods for lists just released in September, they are yet to be supported by the SDK (though this will change very soon!). In such cases, it’s recommend that you use the Python Slack SDK to interact with newly released methods as the SDK will help with reducing errors and complexity. The script can be broken down in several sections:
- Constants – things like your tokens, API keys, which users you want to share this list with and other information about the list itself.
- Utilities – some wrappers to make calling the API methods a bit easier. Since we’re using three different APIs here, including these utilities makes the code a bit cleaner. There’s also some convenience that
- The main script – this portion creates the list, pulls information via our utility functions above inserts the data into items in the list.
Take a look at the full script and take it out for a spin for yourself! Also if you have any suggestions for improvements, please let me know!
Challenges I Hit (And Solved Quickly)
- Understanding that lists are also files within Slack and the
files.*methods also apply to them.- If you’re looking to see if your list exists or not, try using
files.listand filtering ontypes=list
- If you’re looking to see if your list exists or not, try using
- Files created by bots are not visible to users until they are shared
- This is because the bots themselves are the file owners, so they themselves can see them but no one else can. For this reason, we need to use the
slackList.access.setmethod.
- This is because the bots themselves are the file owners, so they themselves can see them but no one else can. For this reason, we need to use the
- The specifics of most of the
slackList.*methods.- Working with lists can be pretty confusing (at least for me!) but having the very detailed documentation helped me out a lot.
Ideas for next steps
- Update the script so that I can pull the data and update the list on a schedule
- This would involve using some of the other list methods like
slackLists.items.infoandslackLists.items.listand setting up acronjob or something else that would run the script on a schedule.
- This would involve using some of the other list methods like
- Explore the use of workflows on list items that trigger when column items change.
I hope this has been a short introduction to how you can use lists within Slack. Please let us know if this was helpful to you by sending us a message in the Slack Community!
Resources
- The script
- Slack Lists documentation
- Finnhub https://finnhub.io
- NewsAPI https://newsapi.org/