howdyai / botkit

Botkit is an open source developer tool for building chat bots, apps and custom integrations for major messaging platforms.
MIT License
11.45k stars 2.28k forks source link

bot_channel_join event not firing when bot is invited to a channel #347

Closed groppe closed 7 years ago

groppe commented 8 years ago

I am listening to the bot_channel_join event as follows:

controller.on('bot_channel_join',
    function(bot, message) {
        console.log(message);

        // reply with excitement
        bot.reply(message, It\'s me!!');
});

However, when I invite the bot to a channel the event doesn't fire.

davidrussell731 commented 8 years ago

I'm having the same issue with this, as well as the user_channel_join event.

ghost commented 7 years ago

Maybe you need to use bot_group_join and user_group_join instead.

dipesh-gandhi commented 7 years ago

Same here, tried both user_channel_join and bot_channel_join but they don't fire.

jonchurch commented 7 years ago

@dipesh-gandhi Are you using the latest botkit? version 4.2? Events API or RTM? I am looking into this currently.

dipesh-gandhi commented 7 years ago

Yes, it's latest 4.2 version. Events API. I'm using console bot at moment for testing.

image

jonchurch commented 7 years ago

Events API does not send bot_id fields with channel_join or group_join events, which Slackbot.js looks for. I have removed the check for bot_id and added channel_join and group_join as exceptions to the check for events originated by the bot (which are ignored by default).

Here is a link to the lines I changed.

Will submit a PR for this after coming back and looking at that exception again 👍 Good catch @dipesh-gandhi!

dipesh-gandhi commented 7 years ago

@jonchurch Thanks much for looking into this, especially since its around holidays. :) The fix you propose seems to be specific to Slack? I'm using Console Bot at moment but I tried regardless, and no luck. I'm fairly new to Botkit so you can correct me.. My goal is for Bot to sent initial greeting message from bot in either case when user joins bot / bot joins user. This is regardless of interface slack, sms, console, web chat, etc. I was thinking there would be some events triggered at bot core, an abstraction?

jonchurch commented 7 years ago

Hmm the concept of channel joins is slack specific Im fairly sure. I honestly have not used console bot yet, but will test it today.

So to be clear, you made the changes to Slackbot.js but are still not receiving bot_channel_join events?

jonchurch commented 7 years ago

Not a solution, just another option, but when a bot is added to a slack team an event called create_bot is fired, for facebook user_optin is fired when a user clicks get started. For slack this would give you the opportunity to send instructions or welcome message to whoever added the bot to the team, for facebook its when your user first interacts with the bot.

This is the intended way to greet users on setup.

But it seems to me you are trying to have the bot say hello when it joins a users channel or vice versa, correct?

jonchurch commented 7 years ago

@dipesh-gandhi Currently with ConsoleBot you can only test text input and conversations. There is not a way to tigger events such as bot_channel_join.

There should be though! I will look into adding something.

Be aware, however, that bot_channel_join is Slack specific

dipesh-gandhi commented 7 years ago

@jonchurch Thanks dude!

bertiful commented 7 years ago

I am having this issue as well - Botkit version 0.4.3 (not using ConsoleBot).

bertiful commented 7 years ago

@jonchurch It works as far as 0.2.2, once I hit 0.4 it stops working. Also, for context, I am not inviting the bot into a private channel and I'm running:

controller.on('bot_channel_join', function(bot, message) {
  bot.reply(message, 'Yay, I have arrived!');
});
jonchurch commented 7 years ago

@chrisberthe Take a look at #514

JimLynchCodes commented 5 years ago

@jonchurch @benbrown

Are you sure this was fixed? bot_channel_join event is not ever firing for me...

Laptopmini commented 5 years ago

@JimTheMan +1, not working here either. v0.7.4. Reopened under #1640.