How can I read local MS Teams status

Viewed 783

I am trying to implement a hardware busy light to show my Microsoft Teams presence so that my family to not enter the room I have the office while I am in a meeting. I am looking to implement something similar to:

The only problem I have with this setup is that I cannot get the MS Teams status.

The best way to go is by using MS Graph Presence API but my problem is that this is a company account and I don't have (and there is no way I could have) and app in the main subscription granted with the required scope: Presence.Read.

So I tried different ideas but none worked in the end:

  • check local running processes
  • check if MS Teams exposes any local API
  • check if there is a CLI available

This seems a simple idea, I mean, I see the status right there now while I am typing this message, I could as well do an app that gets a screenshot of the taskbar and extract the status from the icon, but is that really the only option I have?

2 Answers

I think I found something interesting for you.

Go to

C:\Users\user\AppData\Roaming\Microsoft\Teams 

you'll find a file called logs.txt

In this file you see if your current state changed

(current state: Available -> DoNotDisturb)

I would write a script with php or VB (depends on your skills) that read that logs.txt file like every minute and check for the last "current state" line.

What those posts are doing (certainly the first one, I didn't check the 2nd one) is calling the Microsoft Graph, which has a "presence" endpoint to get a user's status. There's actually even a specific "/me" endpoint, to get your own personal preference (less access rights needed). See more about this here: https://docs.microsoft.com/en-us/graph/api/presence-get?view=graph-rest-1.0&tabs=http

In order for this to work, as you've mentioned, you do need to have an Azure AD App registration. However, importantly, this will only require "delegated" permission (i.e. only permission from the single user, you, to access just data for that single user, you). As a result, you can use "delegated" and not "Application" permissions, which means that it does -not- require Admin consent for the tenant.

It -does- require and Azure Add Application though, at the risk of stating the obvious. While you don't have tenant admin rights, you need to see if you have Azure rights, just to create an application (you might have this anyway as a developer in your org). If you don't even have this, you can sign up for an M365 Developer account, and use that tenant. Importantly - the application does't have to be in the same tenant. If it's not, it's just a simple multi-tenant app, like any 3rd party Azure AD-backed application is.

Related