Search code examples
slackslack-api

Is there any event on slack app reinstallation and a possibility to change bot user tokens when it changes?


I am developing a slack bot and when I install the bot to a workspace, I store the bot access token as they say in Slack documentation: "Once installed, you will have generated a bot token that you should store for use later on". But when I add new permissions to my bot I need to reinstall my bot and after that bot access token changes. Is there any way to handle bot reinstallation and update bot access token?

I was checking available events in slack documentation but there is nothing about app reinstallation. I was thinking that if I reinstall my bot I could use my installation redirect link but it doesn't work.


Solution

  • There is no event for re-installation, but that's because you don't need one.

    If you decide to add scopes to your Slack app it has to be reinstalled into the workspace. For that the installer of the workspace (e.g. admin) must manually start the re-installation, which will redirect him to your installation web page. There you can control the installation flow.

    So you don't need an event, because the user needs to open your installation web page again.

    Best approach btw. is just to replace the existing token in your storage with the new one generated on reinstall.