Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I allow users to delete my Slack bot messages?

I created a Slack bot that allows coworkers to report issues to certain channels, but occasionally someone misclicks or wants their report (reported in Slack by the bot via chat.postmessage) deleted. As far as I can tell, this can only be done by the bot itself through a message shortcut or an interactive message with chat.delete. I would like it to be deletable by users in the same way they would delete their own messages, by clicking the ellipses on the post and choosing delete message in the context menu. Is there a way, either by OAuth scopes or maybe Slack/Workspace/Channel admin permissions this can be done?

like image 766
phuzE koj Avatar asked Oct 22 '25 00:10

phuzE koj


1 Answers

Unfortunately there's no way to do this via the traditional route that a user might delete their own messages.

The only way you could accomplish this is by attaching a button or some other kind of menu to the message (which might look similar, but would not actually be the same menu) with an event attached to it that then calls your application to delete the message.

eg you might have

{
    "blocks": [
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "Here is a message to delete"
            },
            "accessory": {
                "type": "overflow",
                "options": [
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "Delete message",
                            "emoji": true
                        },
                        "value": message.timestamp
                    }
                ],
                "action_id": "delete-action"
            }
        }
    ]
}

As your message, where message.timestamp is the ts value of the message.

And then a handler that calls the chat.delete method on that message id.

like image 80
MattieTK Avatar answered Oct 26 '25 17:10

MattieTK



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!