How do I connect a new style bot to the RTM API (Python)

2.1k views Asked by At

Recently Slack has added the ability for bots to do many more things than they could do before. This is great!. Over the years, I have been able to connect many classic style bots to the RTM API with out any issues. Yesterday I tried to create and connect a new style bot to the RTM API to try out some new features, but was unable to.

During new style bot creation, after providing your bot with various permissions, you are greeted with a message similar to the following;

In order for your app to issue tokens with your chosen scopes, you’ll need to make some changes in your OAuth code to reflect these scopes and handle the new response format. Your app should request these scopes

Bot token scopes

chat:write

chat:read

Change your app’s authentication URL to look like this:

https://slack.com/oauth/v2/authorize?client_id=123456789012.123456789012&scope=chat:write chat:read

The problem I have is that with the RTM (Python) API, one typically does not access any OAuth methods directly. On the surface, there doesn't appear to be a method to provide a URL to the RTM API to authenticate your bot. According to official docs, the way to connect a bot is essentially this;

slack_token = 'xoxb-123456-......'
rtm_client = RTMClient(token=slack_token)
rtm_client.start()

If I provide a classic style bot's auth token, everything connects as expected. Authenticating a new style bot using this method ends up with the following;

slack.errors.SlackApiError: The request to the Slack API failed.
The server responded with: {'ok': False, 'error': 'not_allowed_token_type'}

This seems to only be an issue with new style bots. Again, via the RTM API, you typically don't access any OAuth methods directly, so I'm not sure where the provided URL might get plugged in.

The only parameter for the RTMClient object that looks like it might have worked is the "base_url" parameter. I have tried providing the supplied URL to that parameter, but that did not get me authenticated.

The server responded with: {}

How does one provide the new scopes to the RTM API?

1

There are 1 answers

0
Andenthal On

In case anyone else comes here for the same question. After more reading, I found a line on this page: https://api.slack.com/authentication/basics

New Slack apps may not access RTM.

Bummer, oh well.