Back to previous page

Adding Apps & Tabs in Microsoft Teams using Graph – Part 1

In part one of this two part tutorial I will show you how to add tabs within your channels in Microsoft Teams, using the Graph APIs. In part two I will also cover how you can automate the procedure using PowerShell, allowing for scenarios where you need to bulk add tabs to a large set of teams.

Microsoft Graph

MICROSOFT GRAPH

First things first, what is Graph? Microsoft Graph is the gateway to data and intelligence in Microsoft 365, and allow applications to access digital work and digital life data across the intelligent Microsoft cloud (Source: Microsoft).

Sound great, but what does it really mean? In short it’s a set of REST APIs we can connect to in order to programatically interact with services within Microsoft 365, whether it’s to get meetings and calendar data from Exchange, mobile device status from Intune or feedback and grades from assignments in Microsoft Teams for Education.

Technically Microsoft has multiple Graph APIs, or endpoints, like the Intelligent Security Graph, the education API, Office Graph and more, but we can easily interact with them simultaneously, as well as use data from one in the other, so lets refer to Microsoft Graph as an entity going forward.

Like the title says, we’re going to focus on adding tabs within Teams today, a feature, or possibility if you will, announced at Microsoft Ignite 2018.

WHO NEEDS TO ADD TABS PROGRAMATICALLY?

In many if not most cases, teams are setup and managed largely by team owners. But there are organizations that combine tools like Forms or PowerApps with Flow, in order to govern the team creation process using a request form. Others bulk create teams using the Microsoft Teams PowerShell module, and sectors like education have tools like School Data Sync to automate the teams lifecycle.

In those scenarios the team is created for the owner, often pre-populated with relevant members, and we might like to prepare it with a set of predefined channels, apps and tabs.

GETTING THE IDS

Microsoft love IDs, whether they’re called globalIDs, groupIDs or teamsAppIDs, and I’m sure also great ideas.

In order to add a tab, we first need to get the teams ID, the channel ID, and we need some info about the tab we’re adding. A great way to get started with Graph is using the Graph Explorer, so lets use that and see if we can find some of those IDs.

You must first login to the service, then modify the permissions (either according to the documentation or just add everything), and finally choose beta.

Graph Explorer

This worked at the time of writing, but since these APIs are still in beta there might have been changes by the time you read this and they might have been moved into production (v1.0).

Lets first run a GET to see if the logged on user has any team memberships.

We can see this particular user is a member of one team caled GraphTeam, and we also get the teams ID. Lets use that and see if there are any channels in that team.

You can see the ID was added to the query, as well as /channels/ since that is what we’re after, and we get two channels in return; General and Channel1. Again we’re getting the IDs, let’s choose General and see if we can query for tabs.

From the look of it we have one tab, this is obviously not right since all channels have at least one tab for Conversations and one called Files.

3 tabs

The query does however list all tabs that we are able to edit, which makes sense.

The tab that was returned was a Wiki tab, and what is the first thing we do with the Wiki tab? We replace it with a OneNote tab! So let’s remove it by adding the tab ID to the query and changing from GET to DELETE.

It doesn’t return anything, but we can clearly see that the Wiki tab has been removed.

Wiki tab removed

 

To learn how to construct the object when creating a tab there are examples in the API reference documents. You can also get information querying for existing tabs, I have added a website tab, lets see what that looks like.

Lets also have a look at the example from the API references.

We’re going to need to give the tab a name, reference the correct teamsAppId and provide a URL.

There you go, a new website tab called Teams.rocks pointing at https://Teams.rocks.

Tab called teams.rocks

 

WHAT ABOUT APPS?

To add a tab for an app we need to first add the app itself to the team. In this example I will continue along the education scenario, which actually fits very well since schools need to provision a large amount of teams every summer and often have a requirement to have the same set of tabs in every team.

In order to get the necessary information we repeat the procedure from earlier: add the app to a team and run a GET querying apps. When we’ve got the teamsAppId, all we need to do is run a POST with with the teamsAppId in the request body.

We can see the Skooler app was added to the team by the user logged on to Graph Explorer.

Next we need to add the corresponding tab in the appropriate channel.

The Skooler app is now available as a tab within the General channel.

General

Stay tuned for more in part two of this series, where you will learn how to combine what you learned above with a bit of PowerShell automation magic to add apps and tabs as part of a team creation process as well as in bulk to a set of existing teams.

About the Author:

Magnus Sandtorv is a Microsoft MVP in Office Apps & Services, currently working as an IT advisor @ Horten municipality in Norway. He is a Microsoft Teams Evangelist, Enterprise Mobility Professional, PowerShell automation enthusiast and has his head in the cloud. You will find him blogging at Teams.rocks, evangelizing at both local and international events and sharing his thoughts & knowledge on social media, Microsoft Tech Community etc.

Reference:
Sandtorv, M (2018). Adding apps & tabs in Microsoft Teams using Graph – part 1. Available at: https://teams.rocks/2018/10/14/adding-tabs-in-teams-using-graph-part-1/ [Accessed 6 November 2018]

Share this on...

Leave a Reply

Back to previous page