How I Built a Call Status Monitor for Microsoft Teams to Prevent Interruptions
If you’re like me and you’re working from home with your family, then I’m sure this will sound familiar. You tell your family you’re going to work. You commute to your office (up the stairs) and shut the door. You hope for four hours of peace until lunchtime, then another four after that.
What really happens is someone will quickly “pop in” to ask a question like what you fancy for lunch. Or your child might burst through the door to demand a packet of crisps or to play hide and seek. These things normally happen while you’re on an important video call with a customer.
Recently, I’ve seen a few examples of people who have made a “call status monitor” for different chat platforms, such as Slack and Telegram. Call status monitors are ways of letting others (co-workers in the office, family when working from home) know whether you’re busy. We have someone in the office who simply uses a light hooked up to Teams – green for available, red for go away.
It got me thinking… could I do something similar for Microsoft Teams? Our team at Perfect Image has come to heavily rely on MS Teams in the last few weeks. It’s become my primary call/video/chat/general work communication platform. Could I link up being on a call, with a sign I could hang outside of the door to let everyone in my house know when I can and can’t be disturbed?
Time to find out!
Building an App
I did a quick bit of research and looked at the API’s provided by the Microsoft Graph. The Microsoft Graph sits at the heart of the Microsoft 365 platform and allows the various services to communicate and talk to each other.
For example, when you open Word on your home machine and it shows you the files you were working on earlier using a different device in the office (remember working in an office?!), that’s powered by the Microsoft Graph.
The Graph provides a single entry point for us to query and access data from the different Microsoft 365 services. As developers, we can bring this data together to build our own, intelligent apps.
After a little bit of searching through the API documentation, I found a reference to the “GetPresence” method in the beta API. This is tied directly to your MS Teams status, which updates as you join and leave calls. Using the Graph Explorer, I ran a quick test to verify that it was returning my Teams status as expected:
The next step was to write an application that could query the API and display the status. I had a spare Raspberry Pi to hand with a small 5” screen, so decided to use that as the basis for the project.
Setting Up Permissions to Access Teams Data
In order to get the bare bones of the application built, I opted to use the Microsoft Graph Quick Start service. This service lets you select a language, in this case, Node.js, and provides you with a sample application with examples of how to handle the authentication in Azure Active Directory, and then communicate with the Graph API.
When going through the quick start wizard, you’re prompted to create a new app registration in Azure Active Directory. This ensures that your app can communicate securely with the Graph API.
The wizard creates the app registration for you in Azure AD. However, it only grants permissions to calendar data, which is what the sample application queries. As such, I had to modify the API permissions to include the permission to read my presence information:
Once I had the correct permission, I was able to modify the sample app and point it towards the GetPresence method in the Graph API. A little bit of coding later, I had created a (very) basic dashboard which showed if I was on a call or not.
There are other statuses available in Teams, but my availability was the only one I was interested in for the purposes of this project. The application handles the authentication with Azure AD, and then presents the dashboard:
The Result: A Functioning Call Status Monitor!
Now, when I’m not on a Teams call, my status shows as free.
And when I join a call in Teams, the dashboard updates to show my status as on a call.
And that’s how I ended up with a Raspberry Pi and 5 inch screen taped to the outside of the door to my office. Now my family know exactly when I can and can’t be asked to fix something or grab something from the top of the cupboard! My next steps are going to be for the call status monitor to update when I need a cup of coffee…