Comments (11)
@anonrig it's already in documentation.
bot.api.channels.list({},function(err,response) {
})
I've created simple solution for that, loading both users and channels on bot boot-up.
var fullTeamList = [];
var fullChannelList = [];
controller.spawn({
token: config.get("slack_bot_key")
}).startRTM(function (err, bot) {
if (err) {
throw new Error(err);
}
// @ https://api.slack.com/methods/users.list
bot.api.users.list({}, function (err, response) {
if (response.hasOwnProperty('members') && response.ok) {
var total = response.members.length;
for (var i = 0; i < total; i++) {
var member = response.members[i];
fullTeamList.push({name: member.name, id: member.id});
}
}
});
// @ https://api.slack.com/methods/channels.list
bot.api.channels.list({}, function (err, response) {
if (response.hasOwnProperty('channels') && response.ok) {
var total = response.channels.length;
for (var i = 0; i < total; i++) {
var channel = response.channels[i];
fullChannelList.push({name: channel.name, id: channel.id});
}
}
});
});
Now you can use both users and channels globally.
from botkit.
I believe this is a documentation error; bot.say()
uses the RTM API, which expects a channel ID.
from botkit.
@metoikos What's your development environment?
from botkit.
Hello @ZuzooVn
OS X El Capitan
➜ ~ uname -a
Darwin rocko 15.0.0 Darwin Kernel Version 15.0.0: Sat Sep 19 15:53:46 PDT 2015; root:xnu-3247.10.11~1/RELEASE_X86_64 x86_64
➜ ~ node --version
v4.2.2
from botkit.
I can not build the source code with
➜ ~ uname -a Darwin hostname.local 15.2.0 Darwin Kernel Version 15.2.0: Fri Nov 13 19:56:56 PST 2015; root:xnu-3248.20.55~2/RELEASE_X86_64 x86_64
➜ ~ node --version v5.0.0
from botkit.
I installed with npm install botkit
command.
It generates some errors but it's not related to botkit, it is a bufferutil issue. You can check out at issue #2
from botkit.
@metoikos How do you learn the channel id?
from botkit.
We've drifted off-topic from the issue... @benbrown Any plans for a chatroom/forum/email list?
@anonrig A list of current channel IDs is available from the channel list API, but it's probably better to just use the data you get from the bot's initial connection to RTM, and then keep that list up to date. You can edit the file Slackbot_worker.js
(see line 75 or so) to have the bot cache different data sets for the Slack team to which you're connecting (e.g. users, channels, IMs, etc.)
from botkit.
@tonythomson There is an open slack room waiting for you!! http://dev4slack.xoxco.com/ We've already got a botkit channel open and active.
from botkit.
How do I get the current channel name in which my bot is replying to the user.
from botkit.
@PrajaktaNaik I had the same question today and here's how I did it (you'll want to cache it since it hits the api):
controller.hears(['test'], ['direct_message', 'mention'], (bot, message) => {
bot.api.channels.info({channel: message.channel}, (e, r) => {
if (r && r.ok) bot.reply(message, 'channel name: ' + r.channel.name)
})
})
from botkit.
Related Issues (20)
- botkit 4.15.0 and Webex Adapter 1.0.10 are not on NPM HOT 1
- How to upload this Bot to Teams? HOT 2
- Bot can send, but not receive anymore HOT 2
- Botkit Webex API client not returning data HOT 1
- Question: Handling Websocket terminations HOT 1
- Uncatchable throws on botbuilder-adapter-webex registerWebhookSubscription Functions HOT 19
- Conversation become "duplicated" when running long operation HOT 1
- Help in Implementing the B2C Chatbot
- Webex Teams Adapter Doesn't Support direct_mention Event Type
- ☺
- BotkitConversation not executing when using axios but its executing fine when calling inside request?
- Cannot read property '1' of undefined
- Block Action Issue (when 'Clear Selection' is clicked)
- Can I message a pages followers with this??
- Remove deprecated request package
- Is project Dead? HOT 2
- Botkit
- Server Crash due to Missing Credentials in Slack Adapter
- npm install -g yo generator-botkit HOT 1
- Javascript heap out of memory issue after upgrading botkit from 0.6 to 4.15.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from botkit.