SvRooij.TeamsMonitor
0.2.2
See the version list below for details.
dotnet tool install --global SvRooij.TeamsMonitor --version 0.2.2
dotnet new tool-manifest # if you are setting up this repo dotnet tool install --local SvRooij.TeamsMonitor --version 0.2.2
#tool dotnet:?package=SvRooij.TeamsMonitor&version=0.2.2
nuke :add-package SvRooij.TeamsMonitor --version 0.2.2
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:
- Install the tool
dotnet tool install --global SvRooij.TeamsMonitor
- (optional) Set the Team token in environment
TEAMS_TOKEN
- 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).
flowchart LR
T[Teams Client]-->|Websocket| M[Teams monitor]
M-->|HTTP/HTTPS POST| W[Any url]
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.
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
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 trigger. Settings
→ 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
}
}
}
Socials
If you like my Teams Monitor, please give me a shout out on any of these platforms.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
This package has no dependencies.