Wednesday 18 November 2020

SlackClient Python RTM not capturing messages

I want to write a simple slack bot, which responds a given string to @ mentions, however I am not able to make the official documentation code to work.

I gave all OAuth permission to the bot and have the following code:

from slack import RTMClient

@RTMClient.run_on(event="message")
def gravity_bot(**payload):
    data = payload['data']
    print(data.get('text'))

try:
    rtm_client = RTMClient(
        token="my_token_auth_code",
        connect_method='rtm.start'
    )
    print("Bot is up and running!")
    rtm_client.start()
except Exception as err:
    print(err)

I think the connection is established, as the "Bot is up and running" message appears, however on the slack channel to bot seems to be offline, also I am not able to get any response in the terminal, not for direct messages, not for channel messages even after inviting the bot to given channels.



from SlackClient Python RTM not capturing messages

No comments:

Post a Comment