やりたいこと
Slackの投稿に自動応答する仕組みを作りたい。
やってだめだった方法
APIのページから普通にCreateAppしてトークン作成してワークスペースにインストールしてゴニョゴニョ。
Slack API: Applications | Slack
ソースコード概要
from slack_sdk.rtm.v2 import RTMClient
rtm: RTMClient = RTMClient(token="xoxb-********")
@rtm.on("message")
def func1(client: RTMClient, event: dict):
...
以下のようなエラーが返ってくる。
{
"ok": false,
"error": "not_allowed_token_type"
}
うまくいった方法
その1
Botsのページから「Slackに追加」してゴニョゴニョゴニョ。

Bots
> _Please note, this is a legacy custom integration - an outdated way for teams to integrate with Slack. These integrations lack newer features and they will be...
このトークンで実行すれば、動いた。
その2
classicなAppを作成する方法でもできた。
Slack API: Applications | Slack
Appを作った後、「App Home」から「Add Legacy Bot User」を押して名前を決める。
「App Home」に以下のように表示される。
Your App’s Presence in Slack
Your app is using a legacy Bot User, which comes with a bundle of scopes. You can continue to use Bot User, but to get more functionality, use much less permissive scopes, and ensure future-proofing, we recommend updating to Granular Scopes.
Your app display name and presence is how your users will see your app in Slack.
そのうち動かなくなりそうな雰囲気。一旦そのことは忘れる。
「OAuth & Permissions」の「Install to Workspace」をクリック→「許可する」をクリック。
「Bot User OAuth Token」に表示されるトークンを使う。これで一応は動く。
ただし「OAuth & Permissions」の下の方に警告文が表示される。
This scope is deprecated. Please update scopes to use granular permissions.
ためしに「update scopes」を押して見ると以下の表示。
The RTM API is not accessible to updated Bot Tokens. If your app requires RTM functionality, please exit this update and continue using your existing scopes.
新しいscopeに移行すると動かないということだ。作業を止めて引き返す。
危うい雰囲気だが、いったん今の状態で運用する。
わかってきたこと
最新のBotはEvents APIを使う。その場合、Slack側からイベントをPushするための口をインターネットに自前で設ける必要がある。
インターネットに口を開けられなければ従来のRTMを使う(SlackはRTMを積極的には使わせたくない雰囲気ムンムン)。この場合、https://api.slack.com/apps?new_classic_app=1という嫌味なURLからアプリを作ること。
以上
参考サイト

slacker.error: not_allowed_token_typeで困っている君へ - Qiita
error: not_allowed_token_type ???
PythonのSlackBotライブラリを使ってbotを作っていた所、このエラーが出た。
色々調べた結果、このエラーはSlackのbot作成のリンクが原因っぽい...
[slack]もしかしてRTMはもう使えなくなったのか(2020/03/11)?
私が以前、Pythonで使ったslackbotはこちらだ。 RTMを使っている、と。 まあ、そうなるよねぇ。 ただ、New Slack appsはRTMは使わんだろう、と書いてある。 ...

SlackのtokenとAPI、botの種類をまとめた - Qiita
Slackには様々な種類のTokenがあり、また複数の種類のAPIがあります。
Tokenに紐付いてBotが作成され、Botの種類によって利用できるAPIが違うので、それぞれは微妙に関わりがあります。
が、その辺りを分かっていないと...