poshbotio / PoshBot

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

How to define ChannelRules in Microsoft Teams channels? #223

Open drenand opened 4 years ago

drenand commented 4 years ago

Good morning. I would appreciate some help setting up Channel Rules for Microsoft Teams channels.

Thank you very much for any help offered!

Expected Behavior

I want to be able to configure Channel Rules for Poshbot on a Microsoft Teams backend.

Current Behavior

The documentation only shows how to configure channel rules for Slack, but contains no examples for Microsoft Teams.

Specifically, in the "Channel" field on the ChannelRules hashtable, what should I put in this field when using Microsoft Teams? For Slack the example is pretty straightforward (example: 'general'), but for Teams this doesn't seem to be enough.

On my Teams, my channel is called 'General', and is under a team called 'DevOps'.

In this "Channel" field, under ChannelRules, I have tried, with no success:

If I have ChannelRules enabled and issue a command such as !about, every single time I get this response from PoshBot: "Sorry :( PoshBot has been configured to not allow that command in this channel". If I remove the ChannelRules, the commands run fine, so the remaining configurations seem to be properly done.

Possible Solution

I have no idea what else I should be doing, maybe it's just not possible to issue ChannelRules on Microsoft Teams?

Steps to Reproduce (for bugs)

  1. Setup Poshbot with Microsoft Teams backend.
  2. Test issuing commands on a channel, confirm that PoshBot is working.
  3. Try setting up ChannelRules for that channel, PoshBot will refuse to answer every single time because the "Channel" field is not filled correctly.

Context

I am deploying a Teams Bot to allow users to run some select powershell commands, in order to simplify some work from the DevOps team.

Your Environment

Windows 10 laptop (localhost) Microsoft Teams (cloud version) PoshBot v0.13.0 Powershell v5.1.18362.752

Thank you!

dreznicek commented 3 years ago

Hey, just checking on this. We are needing to do this as well. Is this a slack only feature?

drenand commented 3 years ago

Hey, just checking on this. We are needing to do this as well. Is this a slack only feature?

Hi.

I had to forget about this feature as I was not able to get it working, found no documentation on the issue, and got no replies.

I only used a tight control on the permissions engine, and "disciplined" the users to call all bot interactions on a dedicated channel, or through DM.

Still, if you find a solution, please let me know. Cheers!

dreznicek commented 3 years ago

Yeah, I'm currently working on a middleware solution on PreReceive where specific commands can only be executed on specific channels, which is exposed in $Context.Message.ToName. I can go more granular by also incorporating $Context.Message.FromName. So far, preliminary tests are working.