Dispatch by Mio
Published in

Dispatch by Mio

10 Things You Can Do With The Microsoft Teams API (Graph)

Microsoft Teams API (Graph)

The Microsoft Graph API is more than just an API. It’s a collection of disparate APIs that span workloads across the entire Microsoft 365 stack, brought together under a common set of standards and assumptions. So we’re not just talking about the Microsoft Teams API but everything else associated.

Previously, developers needed to learn the syntax and idiosyncrasies of individual APIs, as well as find the documentation, deal with authentication and permissions, etc.

Now, there is a common authentication and authorization model with standardized behavior for batching, pagination, and throttling. For applications that scan multiple Microsoft applications, this is a much easier way of working.

This abstraction also makes it a lot easier for developers to quickly bring in functionality from other areas of Microsoft 365 to enhance their applications. Microsoft has quietly been adding more and more functionality to Graph in the last few years and now there is a surprising wealth of features that cover a lot more than transitional methods to read and update data.

Here are 10 uses of the Microsoft Graph API which may surprise you:

1 — Manage user mailboxes

IT administrators can use Microsoft Graph to read and then update mailbox settings for users they are responsible for.

This includes being able to set automatic replies (out of office replies) for users, as well as working hours, time zones, delegate options, etc.

An example of using this is automating a reply for users that leave an organization for a period before their mailbox is removed. (Removing the mailbox could also be achieved through a Graph API call.)

Ref: Update user mailbox settings — Microsoft Graph v1.0 | Microsoft Docs

2 — Print a document remotely using CloudPrint

Microsoft Graph isn’t just about making transactional changes to data. One example of this is the API support for CloudPrint. This lets developers remotely send documents to a CloudPrint printer using just an API call.

No need for printer drivers or other setups; just make an HTTP request to upload the document and create a print job!

This API call can be made from both on and off the corporate network, meaning it could be triggered from a mobile device, an Internet of Things (IoT) device, or from an internal batch job on a schedule.

Ref: Create printJob — Microsoft Graph v1.0 | Microsoft Docs

3 — Manage the Microsoft Teams lifecycle

Looking after the ever-growing collection of teams and channels in an organization can be a full-time job, but there are APIs to help you automate the process.

Whether it’s creating teams in a set way, with a pre-defined channel list and security settings, chasing owners to archive inactive teams or auditing which applications are installed where — there are a number of different API calls to help you manage the entire lifecycle of a Microsoft Teams team.

There are also specific calls to archive and then unarchive teams, clone teams, and a special set of API operations that allow you to import historical message data from other platforms into new teams whilst preserving the original date, time, and contributor.

Ref: Use the Microsoft Graph API to work with Microsoft Teams — Microsoft Graph v1.0 | Microsoft Docs

4 — Update an Excel workbook by adding new data and recalculating formulae

For me, nothing demonstrates the power of Microsoft Graph more than this feature. Using API calls in Microsoft Graph your application can open an existing Excel workbook, insert data, re-calculate formulae, make new formulae, update, or create new charts.

In short, everything it would normally take a person time to do.

For workbooks that need to be regularly updated with data from external systems, automating this process can significantly speed up the way your business runs and can make your decision-makers more productive.

Example of a table filter:

POST https://graph.microsoft.com/v1.0/me/drive/items/01CYZLFJGUJ7JHBSZDFZFL25KSZGQTVAUN/workbook/worksheets('Sheet15799')/tables('table2')/columns(id='2')/filter/apply
authorization: Bearer {access-token}
workbook-session-id: {session-id}
{
"criteria" :
{ "filterOn": "custom",
"criterion1": ">15",
"operator": "and",
"criterion2": "<50"

}
}

Ref: Working with Excel in Microsoft Graph — Microsoft Graph v1.0 | Microsoft Docs

5 — Send cross-platform messages to Webex

Using the Microsoft Teams APIs, Mio is able to translate chat messages to Webex. This means any users in your business who prefer Webex to Teams are no longer left out of the conversation. And you don’t have to leave Teams to collaborate with them.

Microsoft Teams message interoperability with Webex

Mio listens for an event on Teams then sends it to Webex. This is called message interoperability and is a requirement in enterprises that have more than one collaboration platform.

As well as a standard chat message, the following functionality is supported:

  • Message edits
  • Message deletions
  • Channel messages
  • Group messages
  • GIFs and emojis
  • File uploads
  • Rich text formatting

Ref: 5 Ways to Connect Microsoft Teams and Webex in 2022

6 — Respond in real-time to data

As well as being able to make requests to get and set data, Microsoft Graph supports using change notifications (aka webhooks) to notify in real-time about changes to data.

This functionality isn’t supported everywhere yet but does include new Teams chat messages, new files, calendar events, and even Teams meetings and calls.

Change notifications remove the need for applications to have to poll to discover new data as well as enabling more server-less models of programming using micro-services.

Ref: Set up notifications for changes in user data — Microsoft Graph | Microsoft Docs

7 — Track usage of Microsoft Teams, Outlook, and Yammer

Much of the usage data available in the Microsoft 365 Admin Centre is also exposed in Microsoft Graph via a dedicated “/reports” section.

Within this are API calls to track usage of Microsoft Teams, Outlook, and Yammer, and discover usage by individual users over time.

You can use this data to create your own graphs of usage or analyze the data for other trends. The reporting APIs also show Microsoft 365 activations and active users.

Ref: Working with Microsoft 365 usage reports in Microsoft Graph — Microsoft Graph v1.0 | Microsoft Docs

8 — Watermark user photos

Given the right permissions, it’s possible to use the Microsoft Graph API to both retrieve and update user information, including user profile photos.

An organization wishing to watermark all user images with a company logo or add a certificate to specific users could use Graph to make this happen by downloading the photo, modifying it, and then uploading it again.

This can be an effective way to recognize user adoption champions, employee of the month, or similar initiatives.

Ref: Update profilePhoto — Microsoft Graph v1.0 | Microsoft Docs

9 — Learn insights about user behavior

Microsoft 365 has become a comprehensive repository of information about an enterprise, with knowledge of who is creating and accessing which documents, who is talking with whom, and what topics are trending in an organization.

Some of this corporate metadata is exposed in the Graph API via three different APIs:

  • Trending API shows documents from OneDrive and SharePoint which are trending around a specific user
  • Used API lists documents that a user has recently viewed or modified
  • Shared API returns information about documents that have been shared with or by the user

These documents can include URLs, file attachments in Outlook and Teams, OneDrive and SharePoint files, and Outlook messages and meetings.

Combining these APIs can paint a complete picture of a user’s interactions within an organization.

10 — Manage educational resources

A less well-known fact about Microsoft Teams is that it has an entire feature-set specifically built to service the education sector. This enables teachers to schedule and run classes, set assignments and collect and grade work via Teams.

There is also a corresponding and rich collection of Microsoft Teams APIs that can be used to work with this education data, making it possible to integrate with other educational software.

Some of the APIs here are useful when a tenant is provisioned with Microsoft School Data Sync.

Ref: Working with education APIs in Microsoft Graph — Microsoft Graph v1.0 | Microsoft Docs

Conclusion

As you can see, the Microsoft Teams API (or Graph API as we should call it) contains some surprising and powerful calls and can be used to initiate actions and make things happen, not just change data.

Because of its shared authentication and authorization model, once you’ve used the Graph API for one purpose in your application it’s easy to bring in this functionality even if it’s for a workload in Microsoft 365 that’s very different.

Keeping up to date with new features can be a challenge but a regular browse through the Microsoft Graph API documentation is recommended to ensure developers know what’s available.

Tom Morgan is a Microsoft MVP and Product Innovation Architect at Modality Systems. He recently authored Building and Developing Apps & Bots for Microsoft Teams.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mio

Mio

Chat better, together. Mio powers cross-platform messaging across Microsoft Teams, Slack, Webex, and Zoom. Learn more at https://m.io