poshbotio / PoshBot

Powershell-based bot framework
MIT License
537 stars 108 forks source link

Using Teams backend: Bot responds to commands in chat, won't in channel #112

Closed gkingston closed 6 years ago

gkingston commented 6 years ago

Expected Behavior

Bot responds to commands like !status in a channel that has the url-decoded id from the correct portion in the teams link in the TeamId in the backendConfig like the example in the docs. I also have Scope set to both Personal and Team in the Edit your Bot information screen

Current Behavior

Everything works great for me in a Chat with the bot. The bot has been added to the team and all commands, permissions, groups, etc work fine when in a chat. Doesn't respond in the channel

Possible Solution

Not sure, I could totally be doing something wrong

Steps to Reproduce (for bugs)

Context

Just trying to get the bot to respond in both chat and in a team channel

Your Environment

devblackops commented 6 years ago

@gkingston Curious. Do you see any errors in the logs? Try setting the LogLevel to Debug in the configuration file.

ChrisLGardner commented 6 years ago

Are you @'ing the bot before issuing the command? It caught me out a few times but you should be doing @botname !status and that should correctly trigger the bot, if you don't @ the bot then the messages aren't actually sent to it using the bot framework.


From: Brandon Olin notifications@github.com Sent: Friday, September 14, 2018 6:26:56 AM To: poshbotio/PoshBot Cc: Subscribed Subject: Re: [poshbotio/PoshBot] Using Teams backend: Bot responds to commands in chat, won't in channel (#112)

@gkingstonhttps://github.com/gkingston Curious. Do you see any errors in the logs? Try setting the LogLevel to Debug in the configuration file.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/poshbotio/PoshBot/issues/112#issuecomment-421235088, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AQDqFmOEmKGM7LmOiW-9SKXpSMv4Bcllks5uaz4ggaJpZM4WoiU4.

devblackops commented 6 years ago

Ah yes. With Teams, you must @mention the bot when in a channel. Otherwise, Teams will never send the message to Bot Framework and PoshBot will never see it. In one-on-one conversations with the bot, that isn't needed.

gkingston commented 6 years ago

Looks like I was doing this wrong. Instead of doing @botName !status, if I do !status @botName it works. Seems to be trying to execute the botname if I do that first? In my logs below, the last line has the actual bot name as the command it's trying to parse WARNING: {"DataTime":"2018-09-14 13:49:00Z","Class":"PluginManager","Method":"MatchCommand","Severity":"Warning","LogLevel":"Info","Message":"Unable to match parsed command [:<at>M+Bot</at>] to a plugin command","Data":{}}

ChrisLGardner commented 6 years ago

Either approach works for me but I don't have any special chars in my bot name.

I suspect sending the bot name after the command might cause issues when you start using commands that accept parameters but I haven't looked at the command parsing properly to know if PoshBot automatically removes it's own name from the incoming data (I'd assume so).

gkingston commented 6 years ago

Thanks @ChrisLGardner and @devblackops for the help. I foolishly have a + sign in my bot name and probably need to change that.

devblackops commented 6 years ago

I haven't tested with special characters in the bot name but this log messages tells me that it's not parsing the command correctly.

WARNING: {"DataTime":"2018-09-14 13:49:00Z","Class":"PluginManager","Method":"MatchCommand","Severity":"Warning","LogLevel":"Info","Message":"Unable to match parsed command [:<at>M+Bot</at>] to a plugin command","Data":{}}

When you enter a message like @botname !status, PoshBot will strip out the bot name you've defined in your bot configuration here: https://github.com/poshbotio/PoshBot/blob/f708e41f6f5e1fdd389fbd00cc5faa3c9c12f7e5/PoshBot/Implementations/Teams/TeamsBackend.ps1#L76 and should just be left with !status. It will then use that value to search for registered commands.

The fact that the message lists :<at>M+Bot</at> instead of :!status tells me it's looking for a command called M+Bot which it will never find.

gkingston commented 6 years ago

Thanks @devblackops . I had some issues setting up my bot with teams and permissions and what not insiitally. I had the name of an older bot from testing in there vs the new name so the name in my config didn't match what was being stripped out.

I appreciate all the help.