Background
The questions and requests for automatic Teams provisioning keeps increasing as more and more organization move over to restrict group creation in their Office 365 tenant. Since this will create more administrative overhead, many wants a simple effective workflow for team requests and provisioning.
You can read more about restricting group creation here:
Get started
The last couple of days (evenings!) I’ve been building a flow for automatic provisioning of Microsoft Teams! I started out by building the sample flow from Lee Ford’s blogpost which you can find here:
https://www.lee-ford.co.uk/new-team-request-for-teams-using-flow-and-graph-api/
This is a great blogpost which gives you easy directions how to build a flow using Microsoft forms, an approval and Microsoft Graph to provision a team. Make sure to follow @Lee_Ford on twitter!
This flow is great but is meant to be built out to suit your own needs and this is exactly what I wanted to do. I am by no means an expert on Microsoft Flow or the Microsoft Graph and this post is about the workflow itself and my take on how you might do the provisioning process. I won’t show you all the details and settings in the flow itself, but if you want to know just ask 🙂
I followed Lee Ford’s blogpost and built the flow which worked out great! The workflow looked something like this:
As you can see, you start out by filling in a Microsoft Forms form with the following questions:
- Team Name
- Team Description
By submitting the form, a flow will start an approval process, sending an approval mail to a preferred recipient. If the request is approved, the flow will use the HTTP-connector to create a team with the help of Microsoft Graph! The team will get the name and description from the form and the requester will be the owner of the team and receive a mail when the process is completed.
Now, I wanted to build on this to fit my needs better. First off, I added some more questions to the form:
I added the “why do you need a team” question because I want the approver to have some more information to help his/her decision to approve / deny the request
The “Team purpose” question is of choice type and gives the option to choose between “Work” or “Project” I’ll explain the purpose of this in a bit.
Next, I added a SharePoint list into the mix! I want to add all created Teams as an item to this list to have an easy overview of all teams.
This is similar to the Teams Admin Centre – > Teams button, but the advantage of a list is that you can:
- grant anyone access to it without any administrative privileges
- add it as a tab in a team or create an app with PowerApps
- create your own columns and metadata
- create views and better filtering
- add this list as a trigger for another flow
Keep in mind that only teams provisioned by this flow will end up in the list by default!
I created a list in one of my SharePoint sites and added the columns Name, Owner, Purpose, Type and Created. The columns get filled in automatically when the team is created. The name and purpose columns get its data from the form as well as the “type” which relates to the team purpose option.
Now, what is that “Team Purpose” option? Depending on what purpose the requester will need the team for, the team will get created differently.
By adding a condition just before the team creation in the flow, two different teams can be provisioned depending on the option selected for “Team purpose”
For example, my work team have different channels, settings, tabs and files than the project team.
If “Team purpose” equals “Work” it will create the work team and if no – the project team will be created instead! You can build this out to include more types as well.
The team itself is created with the POST method to the Graph via the HTTP-connector in the flow. I took my time to build two different team setups, one for “Work” and one for “Project” I mostly used Microsoft’s documentation to add my own channels, tabs and settings for each.
You find it here: https://docs.microsoft.com/en-us/graph/api/team-post?view=graph-rest-beta
Lastly, I wanted to copy files/folders to the newly created team. This is very useful for example in this following scenario:
You are running different projects with Microsoft Teams and have a few document templates which are used in every project. Instead of having to manually copy these to every new team, we can now do this automatically with the help of the same flow.
To do this I first needed to add a new SharePoint connector after the team creation with the action to create a file in the folder which corresponds to the team channel of choice.
This might sound odd because I just said I wanted to copy over my existing template documents! This needs a brief explanation:
When you create a team, a SharePoint site is also created. All files in that team exists in the default document library of that site and every channel in teams is a folder with the same name in the library.
The problem is that those folders in the SharePoint library won’t get created until you open the corresponding “files” tab in Teams!!
This means that if you programmatically create a team and wants to copy a document to the General channel without manually interact with the team first, this will fail because the folder “General” in SharePoint won’t yet exist.
You can however solve this by triggering the creation of this folder by creating a file in that location!
For example as above: https://flowdemo.sharepoint.com/sites/shared documents/general/dummyfile.docx
This will force the general folder to be created! A copy action will not trigger this!
Now I could add another SharePoint connector to copy my files and folders to my teams general folder with the “Copy a file” or “Copy a folder” action.
Finally, this is what my flow looks like today:
I will continue to add functionality to the flow like sending out mails to people involved, add metadata to my list etc. There might be a part 2 coming later 🙂
The purpose of this blogpost was to give an example of a teams provisioning workflow. This can be done in several ways and this is just one of them. It will probably also look different every time to fit the needs of the organization.