We have a bot user who posts replies (in thread) to certain messages in public or private Slack channels (private bot in our own workspace). But sometimes, we would like to delete some (or all) of those messages.
It is easy enough to do manually by retrieving the timestamp of each message by hand ("Copy link" usually does the trick)... but obviously, this does not scale to hundreds or thousands of messages. So we would like to automate the process of retrieving and deleting the messages. However, the documentation for conversations.replies
says this:
Bot user tokens may use this method for direct message and multi-party direct message conversations, but lack sufficient permissions to use this method on public and private channels.
To use
conversations.replies
with public or private channel threads, use a user token withchannels:history
orgroups:history
scopes.
So let me get this straight: we can use a bot user to post replies to messages in public or private channels... but then we cannot retrieve those same messages??? It's impossible? Surely there has to be a way...
We do not have a single user who has access to all channels (other than IT/admins)... only the bot does. So the workaround of using a user token does not work at all for us.
The input we get would be from a user asking for a thread with the both to be deleted (all of the bot's messages within that thread). But it seems like we have nowhere to go from there if we cannot even see or retrieve those messages. 🤷♂️
We ended up implementing a completely different solution based on custom functions/steps for Slack workflow apps:
:delete:
emoji for this).POST
request to our delete bot message API with:
And then our bot/API can easily use the above information in order to delete the message! 🎉
And the information is all easily available to be sent directly from a Slack workflow (see screenshot below). 👌