hubot-slack icon indicating copy to clipboard operation
hubot-slack copied to clipboard

Have Hubot join all open channels on startup/login?

Open jeffbyrnes opened this issue 11 years ago • 23 comments

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”.

jeffbyrnes avatar Dec 09 '14 17:12 jeffbyrnes

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 avatar Dec 09 '14 18:12 grantmd

@grantmd thanks for letting me know. Mind leaving this here, open, to track this potential feature?

jeffbyrnes avatar Dec 09 '14 18:12 jeffbyrnes

Yep, leaving this open.

grantmd avatar Dec 09 '14 18:12 grantmd

+1 as I would love to see this in the future.

carera avatar Dec 13 '14 21:12 carera

+1

gamafranco avatar Dec 14 '14 20:12 gamafranco

+1

PavelVanecek avatar Dec 17 '14 15:12 PavelVanecek

+1

mindvox avatar Jan 02 '15 02:01 mindvox

+1 please add this, many other adapters support it. Just an API to join a specific channel would be great too.

dalehamel avatar Jan 07 '15 16:01 dalehamel

also, since direct messages are implemented like channels, it would be nice for hubot to be able to start a direct message with someone.

dalehamel avatar Jan 07 '15 16:01 dalehamel

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.

dalehamel avatar Jan 07 '15 16:01 dalehamel

@grantmd what is the rationale for disallowing bots to join channels?

dalehamel avatar Jan 07 '15 16:01 dalehamel

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.

jnalley avatar Mar 04 '15 16:03 jnalley

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).

chrisatomix avatar May 23 '15 08:05 chrisatomix

I would also like to be able to have our Hubot in all of our Slack channels. +1

veganstraightedge avatar Jul 01 '15 18:07 veganstraightedge

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 avatar Jul 27 '15 21:07 interactivenyc

@interactivenyc a bit off-topic, but here’s two examples for you:

jeffbyrnes avatar Jul 27 '15 23:07 jeffbyrnes

+1 for hubot auto-joining channels

PurrBiscuit avatar Aug 31 '15 14:08 PurrBiscuit

@chrisatomix This not currently possible anymore. Bot Users are blocked from auto joining channels via the api :(

etiennemarais avatar Oct 12 '15 09:10 etiennemarais

@etiennemarais What about the reverse scenario, where the API is used to invite a Bot into a Channel?

chrisatomix avatar Oct 12 '15 22:10 chrisatomix

@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

etiennemarais avatar Oct 13 '15 10:10 etiennemarais