Slack clean all messages (~8K) in a channel

后端 未结 11 548
暖寄归人
暖寄归人 2021-01-30 06:00

We currently have a Slack channel with ~8K messages all comes from Jenkins integration. Is there any programmatic way to delete all messages from that channel? The web interface

11条回答
  •  情歌与酒
    2021-01-30 06:40

    I wrote a simple node script for deleting messages from public/private channels and chats. You can modify and use it.

    https://gist.github.com/firatkucuk/ee898bc919021da621689f5e47e7abac

    First, modify your token in the scripts configuration section then run the script:

    node ./delete-slack-messages CHANNEL_ID
    

    Get an OAuth token:

    1. Go to https://api.slack.com/apps
    2. Click 'Create New App', and name your (temporary) app.
    3. In the side nav, go to 'Oauth & Permissions'
    4. On that page, find the 'Scopes' section. Click 'Add an OAuth Scope' and add 'channels:history' and 'chat:write'. (see scopes)
    5. At the top of the page, Click 'Install App to Workspace'. Confirm, and on page reload, copy the OAuth Access Token.

    Find the channel ID

    Also, the channel ID can be seen in the browser URL when you open slack in the browser. e.g.

    https://mycompany.slack.com/messages/MY_CHANNEL_ID/
    

    or

    https://app.slack.com/client/WORKSPACE_ID/MY_CHANNEL_ID
    

提交回复
热议问题