Teams monitor

A simple command line application that connects to the local Teams API and forwards the meeting status to any endpoint (you manage).

Sending the status from your Teams client to any website is a matter of three steps:

  1. Install the tool dotnet tool install --global SvRooij.TeamsMonitor
  2. (optional) Set the Team token in environment TEAMS_TOKEN
  3. Run the tool teams-monitor {teams-token-here} --webhook {url-here}

This app needs either .NET6 or .NET7 installed on your machine.

What does Teams Monitor do?

It connects to Teams and allows you to send the realtime data from your Teams client to any server (flowchart only displays at github).

https://viewscreen.githubusercontent.com/markdown/mermaid?color_mode=light#ba30a8a8-e2f4-4fe6-afdd-f41497196166

If you run this tool with a webhook specified, the webhook will receive a HTTP POST message with the following JSON payload:

{
    "meetingState": {
        "isMuted": false,
        "isCameraOn": true,
        "isHandRaised": false,
        "isInMeeting": false,
        "isRecordingOn": false,
        "isBackgroundBlurred": false
    },
    "meetingPermissions": {
        "canToggleMute": false,
        "canToggleVideo": true,
        "canToggleHand": false,
        "canToggleBlur": false,
        "canToggleRecord": false,
        "canLeave": false,
        "canReact": false
    }
}

Meeting light for your home office

I’ve been working from home a lot lately, and I always wanted to control the light in the hallway to turn another color when I’m in a meeting. I was doing this with a button on my desk and forgot to switch it approximately fifty percent of the time.

Home Assistant

I’m a big fan of Home Assistant, it helps me automate everything around that house. So let’s configure home assistant to change the color of the lights in the hallway

Happy Teams week! 😀

Home assistant – Step 1

Create a toggle helper for the user you want to monitor. These are hidden under Settings -> Devices & Services -> Helpers, pick a name that makes sense like {name} Meeting.

Home assistant – Step 2

Create a new blank automation and use the webhook triggerSettings -> Automations & Scenes -> Create Automation.

Add a Webhook trigger. This wil generate a new webhook url that looks like https://{your-ha-domain}/api/webhook/{some-complicated-string} and this should be kept secret!

Add an action, pick the If-Then and add a template condition. The template should be {{trigger.json.meetingState.isInMeeting}} with the brackets!

In the then section you should add a Call Service action that calls input_boolean: Turn On and be sure to select your helper from step 1

Press the Add else link and add a Call Service action that does the reverse input_boolean: Turn Off.

Home assistant – Step 3

Copy the webhook url from the automation you just created and use that to start the Teams Monitor

teams-monitor {teams-api-token} --webhook {webhook-url}

If you want to make it easier on yourself, you can also save both values in the environment settings

  • TEAMS_TOKEN Teams token copied from the External api under privacy.
  • TEAMS_WEBHOOK Url copied from Home Assistant.

Home assistant – Step 4

You now have a toggle helper that changes automatically when you’re in a meeting. You can create an addition automation that does something when the toggle changes state. By connecting the automation to the toggle and not to the webhook, you can also manually trigger the same actions.

Teams has a local api?

Yes, it does! If you never heard of it, that might be right because it was released February 1st 2023. Once you enable it, you get a local api token.

I’m not explaining what the api looks like, as Martijn Smit already did that. For now you just need to know, if you enable the local api your Teams client will open a websocket server at localhost post 8124.

You can just use any client that supports websockets and connect to the following url.

ws://localhost:8124?token=API-TOKEN-FROM-PRIVACY&protocol-version=1.0.0&manufacturer=MuteDeck&device=MuteDeck&app=MuteDeck&app-version=1.4

If something changes to your meeting status (or any of the other values), you’ll get a JSON encoded message on the open websocket connection that looks like:

{
    "apiVersion": "1.0.0",
    "meetingUpdate": {
        "meetingState": {
            "isMuted": false,
            "isCameraOn": true,
            "isHandRaised": false,
            "isInMeeting": false,
            "isRecordingOn": false,
            "isBackgroundBlurred": false
        },
        "meetingPermissions": {
            "canToggleMute": false,
            "canToggleVideo": true,
            "canToggleHand": false,
            "canToggleBlur": false,
            "canToggleRecord": false,
            "canLeave": false,
            "canReact": false
        }
    }
}

About the Author

Microsoft MVP in Security, blogger, speaker and software architect the rest of the time.

Reference

Van Rooij, S., 2023, Team monitor, Available at: https://github.com/svrooij/teams-monitor [Accessed on 14 March 2023]

Share this on...

Rate this Post:

Share: