I have a slack app that I built using the RTM API, that was working fine last time I used it (in December). Now, without any code changes since then, when I try to run it RTM fails to connect.
I stumbled across the Migrating to 2.x wiki, and I'm seeing the same error with rtm_connect when I try to run the example 1.x code as I do when I run mine. I found people having similar issues, but unlike them, I am not on a Windows machine, and I am fairly certain I am using the correct token.
I've outlined the issue in detail in a SO question here
x in one of the [ ])x in each of the [ ])Filling out the following details about bugs will help us solve your issue sooner.
slackclient version: slackclient==1.3.2
python version: Python 3.8.0
OS version(s): Mac OS 10.14.6
Please see details, like steps taken and environment info and other context, outlined in StackOverflow question
What you expected to happen: RTM connects successfully
What actually happened: RTM connection fails
Logs, screenshots, screencast, sample project, funny gif, etc.
same story, but on linux
Hmm. Question, did either of you update your apps to the new granular scopes? Granular scopes don't support RTM. That might be why you are seeing this. You can still create a classic slack app if you need to test this at https://api.slack.com/rtm#create_a_classic_slack_app.
So the conclusion will be that slack strongly recommends updating your applications with Update to Granular Scopes and soom all apps must use granular permissions, but they do not have RTM functionality for bot users?
What should I do if I create an application of a new type (because the old type can no longer be created) and I want the bot to write to my messages?
I tried this:
slackclient==2.5.0
import os
import slack
@slack.RTMClient.run_on(event='message')
def say_hello(**payload):
data = payload['data']
web_client = payload['web_client']
rtm_client = payload['rtm_client']
if 'Hello' in data.get('text', []):
channel_id = data['channel']
thread_ts = data['ts']
user = data['user']
web_client.chat_postMessage(
channel=channel_id,
text=f"Hi <@{user}>!",
thread_ts=thread_ts
)
slack_token = os.environ["SLACK_API_TOKEN"]
rtm_client = slack.RTMClient(token=slack_token)
rtm_client.start()
SLACK_API_TOKEN is xoxb token from slack application with granular permissions
and I get
...
slack.errors.SlackApiError: The request to the Slack API failed.
The server responded with: {'ok': False, 'error': 'not_allowed_token_type'}
...
wait_time = exception.response["headers"]["Retry-After"]
TypeError: 'NoneType' object is not subscriptable
Are there any plans to support RTM-type functionality with the new granular scopes with this Python app? Just trying to get an idea of what direction we should go. I am not sure if Classic apps will be sunset in the near future...
@BigOtis No plans to support RTM with granular scopes. If you are building an internal integration (not planning on distributing to App Directory), you can keep using classic slack apps and RTM without much worry. No plans to sunset classic slack apps in the near future.
What should I do if I create an application of a new type (because the old type can no longer be created) and I want the bot to write to my messages?
If you need to use RTM API for new apps, create a Slack app from https://api.slack.com/apps?new_classic_app=1
The original question here has been clearly answered at #326. Allow me to close this issue now.
We are unable to use event subscription and unable to create new classic app with RTM access.
We want to run our Slack bot on a cloud server which gives us two very large reasons that the event subscription model is not practical for us. 1) You need to have both a static IP as well as a domain name to use this model. While possible, these do not facilitate dynamically generating slack bots. 2) This will require us to open a port to the outside world on machines that we would like to keep closed. If we had a guarenteed ip range that we could go-list for slack servers, that would help us be a little bit more comfortable but we're not willing to open a port globally. RTM also allowed for much more flexibility in that a single program being able to manage multiple apps which does not seem possible with the event subscription model. We would really appreciate the return of the ability to use RTM or a much lighter weight replacement than event subscription.
We have an old app that still works for RTM but we recently have had a need for a second app. I attempted to create a classic app that would retain RTM access as described above (https://api.slack.com/apps?new_classic_app=1) but in order to install the app, you need to add at least one scope and if you add a scope, you can no longer use RTM. So this path is also not available to us (or I'm missing something in the setup). Any advice for moving forward would be greatly appreciated.
@bkievitkylar
Here is the up-to-date way to create a new RTM app. I know it may be a bit confusing. I hope this comment will help you and other folks.
bot scope in the Scopes section
Thank you,
That appears to have worked in creating a legacy bot.
@bkievitkylar Glad to know that!
@seratch Thank you very much! It worked for me!!
Hello @seratch,
I followed your instructions in the above solution but for some reason, the RTM fails to connect. Here is a screenshot of my code and a screenshot of the error that arises when I test it. You can see that at the line that says "test_slack_bot.py::test_slackConnect False", it should instead output "True".
Any help?
Thanks!

@gbs278 I've verified with slackclient==1.3.2 just in case but I was not able to see the same situation. Can you verify if you're using the right token for it?
Also, the second screenshot publicly exposed your bot token. I've removed the file from your comment and deleted the history but I recommend revoking the token as soon as possible.
Add bot scope in the Scopes section
You'll see a warning saying "This scope is deprecated. Please update scopes to use granular permissions." but don't upgrade to the newer permission model
This scope is no longer accessible @seratch. Any idea how to proceed?
@pattrickrice
You can add bot permission in the select menu this way:

And then,

Most helpful comment
@bkievitkylar
Here is the up-to-date way to create a new RTM app. I know it may be a bit confusing. I hope this comment will help you and other folks.
botscope in the Scopes section