Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Slack implementation from Bot to App #12383

Closed
dacort opened this issue Apr 22, 2020 · 23 comments
Closed

Update Slack implementation from Bot to App #12383

dacort opened this issue Apr 22, 2020 · 23 comments
Labels
Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness .Release notes mention Ex. breaking changes, removes functionality, changes API, requires 3rd-party driver changes Reporting/MetaBot Type:New Feature
Milestone

Comments

@dacort
Copy link
Contributor

dacort commented Apr 22, 2020

Is your feature request related to a problem? Please describe.
Slack has made the move more towards apps than bots. This appears to be largely due to their old "bot" implementation requiring global permissions and new apps are more appropriately scoped. The current bot implementation is not deprecated, but we don't know if or when it will be.

From https://api.slack.com/authentication/quickstart

You can now select individual scopes for your bot token, rather than just one umbrella bot scope that grants access to many methods, some of which you may not need.

image

Describe the solution you'd like
Option 1: Update our documentation to reflect the current best practice approach
Option 2: Overhaul our Slack implementation to use a proper "App"

How important is this feature to you?
Slack is an important way that folks share Metabase questions.

Additional context
Discovered while looking into #12382

⬇️ Please click the 👍 reaction instead of leaving a +1 or update? comment

@dacort
Copy link
Contributor Author

dacort commented Apr 23, 2020

Enumerating the methods we currently use and their docs/deprecation status based on slack.clj:

Method Scope Deprecated?
channels.list channels:read Y
users.list users:read N
files.upload files:write N
chat.postMessage chat:write N
rtm.start(?) bot (classic) Y

That said, I created a new Bot app and added the necessary scopes and images and the MetaBot avatar aren't getting set properly.

chat:write.customize scope is required to set a customized avatar and username. Still unsure why the file upload isn't working with the new app.

@matthewlent
Copy link

@dacort nit users:read

@ctivanovich
Copy link

I'm attempting to set this up now at my organization--is it still a requirement that the API be set-up specifically for a channel called metabase_files?

@dacort
Copy link
Contributor Author

dacort commented May 11, 2020

is it still a requirement that the API be set-up specifically for a channel called metabase_files?

Yes, although it can be archived if you like. Note that you still need to create a “bot” user and not an app.

@ctivanovich
Copy link

is it still a requirement that the API be set-up specifically for a channel called metabase_files?

Yes, although it can be archived if you like. Note that you still need to create a “bot” user and not an app.

Also, this is a bit misleading. I think what you mean is you must create an app, and a bot user for that app. There is no "just a bot user" option anymore, everything is encapsulated in the Slack API app service now.

@dacort
Copy link
Contributor Author

dacort commented May 11, 2020

@ctivanovich Please take a look at the workaround in #12382 - we're still using the "bot" user in Slack and have not migrated to proper apps yet. You can still create a bot user using the link in that ticket.

This ticket is for researching what the required permissions are to move to an app.

@manghat
Copy link

manghat commented May 21, 2020

It would also be great if metabot could send files into private channels.

@flamber
Copy link
Contributor

flamber commented May 21, 2020

@manghat I think you're looking for #2694 - support for private channel

@nmuldoon
Copy link

We just received a notification (below) from Slack that the API used by the Metabase Bot will be deprecated on 24th February 2021. Rewriting the bot as an app before then would be greatly appreciated.

The Conversations API is a one-size-fits-all replacement for a variety of APIs that are used to read and write information about channels, private channels, direct messages and multi-party direct messages. On 24th February 2021, Slack will end support for any methods preceding the Conversations API. We’ve detected that your organisation has created Slack apps using these legacy methods. If users expect your app to work in channels of any kind, you’ll need to verify use of the Conversations API by following these suggested next steps.

@dacort
Copy link
Contributor Author

dacort commented Aug 28, 2020

@nmuldoon Thanks for the notice, Slack integration is certainly critical so will address this in an upcoming release.

@camsaul
Copy link
Member

camsaul commented Oct 6, 2020

We don't use channels.list anymore -- I fixed this in #12921

@Limess
Copy link

Limess commented Jan 13, 2021

The date above rapidly approaching, are there still plans to address this before then?

@flamber
Copy link
Contributor

flamber commented Jan 13, 2021

@Limess Which date? Metabase has been using Conversations API since 0.36.0. Additional information would be appreciated.

@Limess
Copy link

Limess commented Jan 13, 2021

Ah thanks, I didn't find it clear from the above that this was changed - if this is the case that's great.

As an aside, while re-adding metabot to our slack install, I tried creating a new Slack app, and adding the appropriate scopes - rather than using a bot integration, and received this error in the metabase logs:

2021-01-13 15:14:38,403 WARN integrations.slack :: {:error-code "not_allowed_token_type", :message "Slack API error: not_allowed_token_type", :response {:ok false, :error "not_allowed_token_type"}}
	at metabase.integrations.slack$do_slack_request.invokeStatic(slack.clj:65) ~[metabase.jar:?]
	at metabase.integrations.slack$do_slack_request.invoke(slack.clj:47) ~[metabase.jar:?]
	at metabase.integrations.slack$GET.invokeStatic(slack.clj:70) ~[metabase.jar:?]
	at metabase.integrations.slack$GET.doInvoke(slack.clj:67) ~[metabase.jar:?]
	at metabase.integrations.slack$handle_error.invokeStatic(slack.clj:38) ~[metabase.jar:?]
	at metabase.integrations.slack$handle_error.invoke(slack.clj:26) ~[metabase.jar:?]
	at metabase.integrations.slack$handle_response.invokeStatic(slack.clj:45) ~[metabase.jar:?]
	at metabase.integrations.slack$handle_response.invoke(slack.clj:40) ~[metabase.jar:?]
	at metabase.integrations.slack$do_slack_request.invokeStatic(slack.clj:63) ~[metabase.jar:?]
 "api.slack$fn__71273$fn__71276.invoke(slack.clj:25)"
 "api.slack$fn__71273.invokeStatic(slack.clj:21)"
 "api.slack$fn__71273.invoke(slack.clj:13)"
 "api.slack$fn__71273$fn__71276.invoke(slack.clj:25)"
 "api.slack$fn__71273.invokeStatic(slack.clj:21)"
 "api.slack$fn__71273.invoke(slack.clj:13)"

Is that mechanism supported?

@flamber
Copy link
Contributor

flamber commented Jan 13, 2021

@Limess That's what this issue is - about updating Metabase to allow using the App instead of the Bot.

@cernael
Copy link

cernael commented Jan 19, 2021

@flamber I just upgraded from 0.35.3 to 0.37.6, but I see no changes in the Slack integration, which I expected to do.

Do I understand correctly that, while the integration in Metabase has switched over to the Conversations API, there's still stuff in the Bots Slack app that allows use of the old API, and that's why it still shows up in the warnings in my Slack admin interface?

@flamber
Copy link
Contributor

flamber commented Jan 19, 2021

@cernael Metabase does not support App, only the Bot. That is what this issue is about. I don't know what warning you're seeing.

@cernael
Copy link

cernael commented Jan 20, 2021

@flamber In my Slack admin page, Bots show up on this warning page. And Metabot is the only one we're using. As someone with very limited knowledge of how Slack apps in general, and the Bots app in particular, work, the warning here makes me a bit uneasy.

On reflection, it seems reasonable that the warning arises because some Bot, somewhere, still uses the deprecated API, and that the shutdown only will mean that that bot breaks. But it's not really clear that that is the case.
Slack could have been clearer by also breaking down the usage to the API tokens I have generated for Bots.
Metabase could have been clearer by including a more explicit mention of the switch to Conversations in the release notes for 0.36.0 - up until now the only mention of a fix I've found is your offhand comment above. I did just now go looking deeper, and while there is a mention of Slack in the 0.36.0 release notes, neither it nor the linked issues ever explicitly mention the Conversations API by name - it's only by digging into the code itself, in #12921 (which is not even the issue linked from the release notes), that I get solid hints that this is fixed.
bots

@flamber
Copy link
Contributor

flamber commented Jan 20, 2021

@cernael If you have just upgraded, then you'll see MetaBot on that list - as it says:

Apps listed here have used at least one of these deprecated APIs within the last 30 days.

While we are trying to become better at making release notes, in 0.36.0 release notes it links to the issue #12678 and was fixed by PR #12921.
Anyhow this is going way off-topic.

@easeev

This comment has been minimized.

@flamber

This comment has been minimized.

@easeev

This comment has been minimized.

@flamber flamber changed the title Update our Slack docs and/or implementation Update Slack implementation from Bot to App Aug 11, 2021
@flamber flamber added the .Release notes mention Ex. breaking changes, removes functionality, changes API, requires 3rd-party driver changes label Aug 11, 2021
@codyborn
Copy link

codyborn commented Dec 7, 2021

I've received a notice that the metabase slack bot rtm.start functionality will be deprecated beginning November 30, 2021 for newly created connections.
Is there an existing alternative to the Slack bot? Is there any ETA on the Slack app? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness .Release notes mention Ex. breaking changes, removes functionality, changes API, requires 3rd-party driver changes Reporting/MetaBot Type:New Feature
Projects
None yet
Development

No branches or pull requests