My last posts were all about getting up to speed with the Microsoft Teams PowerShell cmdlets released two weeks ago. Running those cmdlets in an Azure Function creates some nice options in terms of creating a team in Teams (still, the wording is just awkward). I’m sure you read about all the governance discussion that services like Teams or Groups start in each environment. Only with proper tooling, you can manage the process of orchestrating your different collaboration features in Office365. To take this idea to the next level, what about using a bot in Teams to handling a users request of creating a new team.

This post describes how you can create a bot for your users that will ask for some data in order to create a new team in Microsoft Teams. The bot will call an http triggered Azure Function that is using PowerShell to handle the requests and has the new Teams cmdlets deployed to be able to create a new team in our tenant.   

To code in the git hub repo is based on an example project (https://github.com/Microsoft/BotBuilder-Samples)  of a dot.net bot that shows how the different dialogs in a bot can be wired together. The solution is quite simple and of course no way production ready:

An example dialog of the bot looks like this:

To create this kind of dialog you simply start the interaction with the user with code like this:

This will create our two different buttons and will guide the user in the directions we want them to choose from. After we have all the data from the user, in our case just an alias and a display name, we can now call the Azure Function handling our request.

This example works with a command parameter in the function endpoint and some basic json data in the body of the request. 

The PowerShell script is also pretty small and simple at the moment:

After the script finished our bot receives a http 200 everything ok message and informs the user about the success of the operation.

During testing creating a team with this approach took around 3-5 seconds from sending the final message to the bot to the created new team in the client. 

This simple project only uses two parameters when creating new teams. The one that is important from my perspective is -Alias. You can create multiple teams with the same display name only the alias parameter is unique. If you use the same display name you end up with aliases being pretty random.

 

 

Github repo -> https://github.com/thomyg/Theodore