beginner-corp/slack

Listen for messages using the RTM

gazpachu opened this issue · 4 comments

What's the correct way to listen for messages in a slack channel using the RTM API? https://api.slack.com/events/message

In v8.1.1, I used to do this:

this.bot.message((payload) => {});

this.bot.user_typing((data) => {});

But that doesn't seem to work anymore in the latest version.

I've checked inside the slack object and inside rtm I can only find two methods: connect and start

Ah sorry we deprecated that API in 9.x but you can still find the code here https://github.com/smallwins/slack/blob/0ab67869ab671664f8a299f74dd4e9f5d2472334/src/rtm.client.js

@brianleroux thanks. May I know why the RTM API was deprecated in the lib? How would users be able to fetch messages without having to ping the slack api every x seconds?

@gazpachu I think the Events API is probably what you want. Create a webhook for Slack to call, then subscribe to the Event Types you need (probably the message family).

yep! it is way better because you don't need to keep a socket open. just need a web-accessible url for slack to ping as the events happen. works great!