Reputation: 2704
I am using simple template of slack bot RTM API, that is given at https://github.com/slackapi/node-slack-sdk
var RtmClient = require('@slack/client').RtmClient;
var CLIENT_EVENTS = require('@slack/client').CLIENT_EVENTS;
var bot_token = process.env.SLACK_BOT_TOKEN || '';
var rtm = new RtmClient(bot_token);
The question is how to fetch the channels name?
I found that I should use channel.list which is compatible with WEB API.
But how to call WEB API when I am using RTM API? And, in general, why all these so overcomplicated?
Upvotes: 0
Views: 440
Reputation: 201378
How about following sample? Please import your access token, when you use this.
Sample :
var WebClient = require('@slack/client').WebClient;
var web = new WebClient('## your access token ##');
web.channels.list(function(err, info) {
if (err) {
console.log(err);
} else {
for(var i in info.channels) {
console.log("%s", info.channels[i].name, info.channels[i].id);
}
}
});
Result :
channelName1 channelID1
channelName2 channelID2
channelName3 channelID3
If I misunderstand your question, I'm sorry.
Upvotes: 2