slackapi / bolt-python

A framework to build Slack apps using Python

Home Page:https://slack.dev/bolt-python/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

slack bot suddenly got inactive on my slack account

suavelad opened this issue · comments

I noticed this evening when testing my app that I was getting this error:

{'error':'account_inactive'}

When I checked, I noticed my slack bot was no longer showing up as an installed app on my slack workspace.

I later went to the slack api dashboard and triggered a reinstall, then retested.

This time , I was getting another error:

{'error': 'invalide_auth'}

When I checked again, I noticed my slack bot token had changed also .

Please what could be the cause ?

I cannot afford to have this same occurrence in production.
This is the first time after over 6 months.

Regards,

Hi, @suavelad! Thanks so much for raising this issue! 🙌

Based on the info provided, the error looks like something to do with the workspace it was installed on / who it was installed by.

As seen here:

Typically, the account_inactive error happens when using a bot token and the bot is uninstalled, or when the token is for a deleted user or workspace. If you reinstall your app, you should receive a new token and that should work.

Re: the deleted user instance, this can happen if the user that installed the app is deactivated - sometimes, apps that they install are also deactivated.

I recommend investigating how your app was uninstalled from your workspace! If you have any further questions, let me know and I'd be happy to help! ✨

Hi @hello-ashleyintech In other to investigate, I would like to ask if a member of the workspace can uninstall a bot.

What are the ways bot can be uninstalled ?
Regards

What are the ways bot can be uninstalled ?

Users in your workspace can visit the app configuration from "Configuration" button on the "About" tab of your app, and they can uninstall the app by clicking the "Remove App" button there.

Hi @seratch ,

I noticed when a user remove app, it is removes it from the workspace?

How can we prevent this ?

Secondly,
I created a slack bot which is linked to workspace A ( the origin from which the bot was created ) with SLACK_TOKEN_A
I installed the bot into workspace B . When sending a message to a user in workspace B using:

client = WebClient(token=SLACK_TOKEN)
client.chat_postMessage(
    channel=approver_slack_user,
    # thread_ts=message_ts,
    text=f"Hey <@{approver_slack_user}> :wave:",
    blocks=blocks,
)

for the token, I used SLACK_TOKEN_A (which is the originator of the bot) and I got channel_not_found message.

Am I suppose to use the SLACK_TOKEN for the user workspace I want to talk to

How can we prevent this ?

When a user can install apps into workspace, there is no way to prevent the removal. To detect the event, your app can subscribe this event: https://api.slack.com/events/app_uninstalled

As for the second question, when your app can be installed into multiple workspaces, your app is responsible to manage tokens per workspace. The token for workspace A does not have permissions to access any data within workspace B. To enable the proper token management, your app needs to serve the OAuth flow to store the installation data including the tokens in a database. Refer to the following resources for details:

@seratch Thanks for the response

On the unistalling/removal of a slack app.

Does this mean that if I install my slack bot into a workspace called workspace A which has users in it, if any of the users deletes the bot app, from the workspace, it removes it totally for the workspace ?

When a user has the permission to remove an app from their workspace, yes. Your app can be removed by the interactions on the app configuration page.

@seratch I guess this happened because the bot app is owned my the workspace (workspace A) and the user was a member of it.

a user from workspace B where our bot is installed on will/should not be able to see the delete button ?

A user in the workspace B can remove your app from workspace B. Thus, the remove button can be available for their own workspace. The removal is an operation for each workspace.

@seratch Apologies that my questions are much.

Are you saying that if on my workspace , we installed polly bot app, and a user uses the X - button at the side (in the app listing module), it will remove the polly bot app from my workspace and not other member of my workspace will be able to use it?

image

No, clicking the "x" on the UI means just hiding the DM from the side bar at the moment. As I mentioned above, removing an app can be done on my the app configuration page, where a user has to visit the app's "About" tab, click the "Configuration" button, scroll down on the app configuration page to its buttom, and then click "Remove App" button. This is a quite intentional operation so that no one won't do that unintentionally.

scenario 1 : I created a slack bot app (BOT A) and it is owned by workspace A. A member of workspace A, went to About -> Configuration, which took him to the configuration page, at the button, he saw the "Remove App" button.

scenario 2: In workspace B, there is a bot app that was added ( Bot B) which is not owned by workspace B, when the user clicked on About -> Configuration tab and navigated to the bottom, i did not see the "Remove App" button

My Question:
what conditions makes "Remove App" button show in some and not show in some others ?

This depends on how the workspace is configured in terms of user permissions by admins. Since this is a general question about Slack, not specific to this Python SDK, would you mind contacting our customer support team? You can send a question by /feedback command within your Slack workspace. It'd be appreciated if you could understand this.

Since this issue has been inactive for a few weeks, let me close this now.