Skip to content

A simple Node.js app that detects changes to your online presence (status) in Microsoft Teams for taking custom actions on changes. For example, turning on/off lights! WARNING: NOT compatible with "new" teams currently!

License

EthyMoney/Microsoft-Teams-Presence-Detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Teams Logo       Available Icon       Away Icon       Available Icon      

Microsoft Teams Presence Detector

This is a Node.js application that monitors the Microsoft Teams log file for user presence state change events and provides triggers to act on changes. This allows detection of changes to your online status (e.g., when you go from Available to Away) which can be used to trigger other actions, such as turning on/off lights in your home office, sending notifications to other applications, changing a status light color at your desk, and much more! Personally, I use this at work to change the color of an RGB light on my desk to indicate my status and tell people if I'm available or not before they walk over to ask me something.

🛑🛑 NOTICE: This is currently NOT compatible with the "new" Teams. 🛑🛑

This only works with the old Teams due to the new one not writing presense states to a log file, which this program depends on. This could change in the future where this log file method works again, but there's a good chance that this program will need to be reworked to work with the new Teams once it's being forced to use it. You can currently still opt to use the old one so this still works.

How It Works

The application watches the Teams log file for changes and uses regular expressions to extract the current state from the log entries. It keeps track of the last known size of the file and reads the new content after each change. It compares the new state with the previous state to identify the latest presence state and alert when it has changed.

The best part? No cloud connection, API, or any authentication is needed thanks to the simplicity of just reading a log file stored on your local machine. Luckily, Microsoft writes presence changes to the log file, so we can do away with all the complicated Azure account and Graph API setup and authentication.

The app will detect what operating system you're on and your username so it can dynmaically update the file location path of the Teams log file before it loads it. If for some reason yours fails to load or your file is in a different place than expected (like some flavors of linux), you can manually set the file path in the code to where your file actually is. Just remove the part that checks the operating system and set it yourself.

Prerequisites

  • Node.js v18 or higher
  • Microsoft Teams (desktop app only, not browser version)
  • Running on Windows 10/11, MacOS (Apple Silicon too!), and most flavors of Linux

Installation

  1. Clone the repository:

    git clone https://github.com/EthyMoney/Microsoft-Teams-Presence-Detector.git

  2. Navigate to the project directory:

    cd Microsoft-Teams-Presence-Detector

  3. Open main.js and add your code for what you want to have happen when your presence changes. The current example code will print the current presence state and changes to the console, customize it to your needs.

  4. Run it:

    node main.js Note: The step to install dependencies was left out purposefully because this doesn't require any more than just Node.js itself!

That's it! You can now use this to trigger other actions based on your presence status.

Example Output (from the current example code in main.js that just prints to the console)

hello, <User>!
Running on Windows
log file loaded, current lines count: 19631
Latest state change on startup: Available  
watching file for changes...
Latest state change detected: Busy
Latest state change detected: Available

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

If you have any suggestions or improvements, please open an issue, or pull request. I'm always looking for ways to improve and would love to hear your feedback!

About

A simple Node.js app that detects changes to your online presence (status) in Microsoft Teams for taking custom actions on changes. For example, turning on/off lights! WARNING: NOT compatible with "new" teams currently!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published