Slack now has deprecated legacy tokens, instead, Slack encourages us to create Slack Apps to do our job, so I created a note to record how I set up Slack app and use it on drone-slack-blame plugin.

  1. Create a app: https://api.slack.com/apps?new_app=1

    image

  2. Add features and functionality

    Edit App display name

  3. Go to OAuth & Permission, then edit the scope of bots:

    What I need is to make Drone (drone-slack-blame) to notify the users with the build status, and send messages to channels as well, so I need users:read permission to map Github users and Slack users (you can set mapping in drone-slack-blame section in drone.yml), and Drone Bot requires chat:write to send private messages, and chat:write:public to send messages to public channels.

  4. Install App to workspace

    then you should see Bot User OAuth Access Token is present.

  5. Now you can use the token in Drone, here is the example of my drone setting:

    Remember to set user mappings, first argument is your GitHub name, and the second one is Slack display name. You can check more in the source code.

  6. How it works?

    The image below is for private messages:

    And it sends message to a public channel as well:

Last but not least, you can check https://api.slack.com/apps/ to configure your Slack app, I have to say that Slack administration pages are like a huge maze… it always takes me some time to find out what I want.