Is there a way to specify that a Hubot should join all open channels on startup? This would mimic the previous behavior, where Hubot is omnipresent, if “invisible”.
That's not something that is currently possible, as the accounts that Hubots use are limited in their abilities, including the ability to join channels. They currently must be invited to each channel or group.
We will look into lifting this restriction and then making auto-join an option on startup.
@grantmd thanks for letting me know. Mind leaving this here, open, to track this potential feature?
Yep, leaving this open.
+1 as I would love to see this in the future.
+1
+1
+1
+1 please add this, many other adapters support it. Just an API to join a specific channel would be great too.
also, since direct messages are implemented like channels, it would be nice for hubot to be able to start a direct message with someone.
Oh, this is actually explicitly disabled by the slack API!? https://api.slack.com/methods/channels.join
user_is_bot This method cannot be called by a bot user.
@grantmd what is the rationale for disallowing bots to join channels?
I'm using lita. It would be really nice to allow the bot API to support channels.join.
We have several internal "apps" and create a channel per app. Manually inviting the bot to each of these channels is tedious.
I needed this functionality too, so I ended up working around this by writing a standalone PHP script to automatically invite the bot into every channel. If I get time I'll convert it into node.js.
It essentially just uses the Web API to pull down a list of all channels:
https://slack.com/api/channels.list?token=MY_TOKEN
This gives me the Slack ID for every channel (ie "A12B45C789"), as well as which Users are members of that Channel.
I can then send a second API request to invite my bot into every channel which it isn't already a member of.
https://slack.com/api/channels.invite?token=MY_TOKEN&channel=A12B45C789&user=U123456789
(the user parameter is the Slack ID of my bot).
It's clunky but it works. Currently running it as a scheduled cron job but would eventually prefer to use a webhook (listening for a channel created event).
I would also like to be able to have our Hubot in all of our Slack channels. +1
Are there any good examples of Hubot chat bots - like a template for handling dialog, listening for keywords and phrases, and speaking random chunks of dialog based on the input? I'd like to do something like:
if (input_text contains "where is"){
if (input_text contains "Obama"){
var random:int = random(3)
switch (random){
case 1: say "Obama's in the White House"
case 2: say "Obama's in New York at the theater with his family"
case 3 say "Obama's sleeping right now"
}
}
if (input_text contains "Homer"){
// different dialog appropriate for Homer Simpson
}
}
@interactivenyc a bit off-topic, but here’s two examples for you:
+1 for hubot auto-joining channels
@chrisatomix This not currently possible anymore. Bot Users are blocked from auto joining channels via the api :(
@etiennemarais What about the reverse scenario, where the API is used to invite a Bot into a Channel?
@chrisatomix Does not seem so. I did a test with the HUBOT_TOKEN as auth though, maybe I need to replace the token with a token from a real user? Would that work because the error I get is user_is_bot
It would have to be a real user, because a Hubot token won't have the ability to invite itself into channels. That may explain the user_is_bot error
+1
At this point, I'm going to close this as won't fix—The rules for bot users specifically preclude them from inviting themselves into channels. This is for security purposes. Bots _must_ be invited into a channel, they cannot invite themselves.
This is not to say there aren't workarounds available if you poke around the Slack API methods…but they're not especially elegant. And, at any rate, out of the box, Hubot should respect the rules for bots.
Most helpful comment
At this point, I'm going to close this as won't fix—The rules for bot users specifically preclude them from inviting themselves into channels. This is for security purposes. Bots _must_ be invited into a channel, they cannot invite themselves.
This is not to say there aren't workarounds available if you poke around the Slack API methods…but they're not especially elegant. And, at any rate, out of the box, Hubot should respect the rules for bots.