slackapi / python-slack-sdk

Slack Developer Kit for Python
https://tools.slack.dev/python-slack-sdk/
MIT License
3.86k stars 832 forks source link

Bots can't delete their messages #1557

Closed simonasmulevicius-humbility closed 2 months ago

simonasmulevicius-humbility commented 2 months ago

How bots are supposed to delete the messages they've sent?

Even though there has been a proposed solution , but it seems that the problem persists - other community members are also struggling to find a way that would allow bots to delete their old messages..

Our use case - we have Grafana Slack bot that sends alert notifications to Slack. But occasionally some alerts become outdated and we would like to remove these outdated notifications. As we are using Grafana to send alerts, we are forced to use webhook with the bot token. As mentioned in another post, the only solution possible seems very grim:

your bot will not be able to delete your messages, because they have been created via webhook. Those messages no longer belong to the bot user, but to the webhook app. (It might still work with the app's user token and assuming you are using a webhook from your own app, not via Slack's webhook app)

So do I need a super-duper-admin permissions to delete my bot messages?

WilliamBergamin commented 2 months ago

Hi @simonasmulevicius-humbility thanks for writing in 💯

we have Grafana Slack bot that sends alert notifications to Slack

Is this a custom Slack Application or the Graphana Slack Integration?

If you are using the integration and it is configured with the "Bot User OAuth Token" rather then the webhook url then the application should be able use chat.delete to clean up old messages

simonasmulevicius-humbility commented 2 months ago

Thanks, your instructions helped to solve our problem!

Yeah, we are using the aforementioned Grafana Slack Integration. Switching from webhook url to Bot User OAuth Token solved our problem