TeamsConnector 1.0.3

dotnet add package TeamsConnector --version 1.0.3
                    
NuGet\Install-Package TeamsConnector -Version 1.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TeamsConnector" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TeamsConnector" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="TeamsConnector" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TeamsConnector --version 1.0.3
                    
#r "nuget: TeamsConnector, 1.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TeamsConnector@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TeamsConnector&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=TeamsConnector&version=1.0.3
                    
Install as a Cake Tool

About TeamsConnector

A simple package for interfacing with Microsoft Teams, written in C# and .NET 6.0.

Main features:

  • Get presence of current user
  • Get notified about presence changes
  • Get notified about incoming calls, including the calling phone number
  • Make outgoing calls

Works with both the old and new (beta) Teams client!

Getting started

Create a new instance of TeamsClient and get presence of the current user:

var teamsClient = new TeamsClient();
string presence = teamsClient.GetAvailability() + "/" + teamsClient.GetActivity();

Get notified about presence changes:

teamsClient.PresenceChanged += TeamsClient_PresenceChanged;
teamsClient.CreatePresenceSubscription();
private void TeamsClient_PresenceChanged(object? sender, PresenceChangedEventArgs e)
{
    Console.WriteLine($"Presence changed: {e.Availability}/{e.Activity}");
}

Get notified about incoming calls:

teamsClient.IncomingCall += TeamsClient_IncomingCall;
private void TeamsClient_IncomingCall(object? sender, IncomingCallEventArgs e)
{
    Console.WriteLine($"Incoming call from: {e.PhoneNumber}");
}

Start an outgoing call:

teamsClient.MakeCall("+41441112233");

Error handling

The constructor of the TeamsClient class throws a TeamsConnectorException exception if:

  • Microsoft Teams ist not registered as the default IM application
  • MIcrosoft Teams is not started

If your program ends or you no longer need your instance of the TeamsClient class, you should remove all event handlers and call the Dispose() method:

teamsClient.PresenceChanged -= TeamsClient_PresenceChanged;
teamsClient.IncomingCall -= TeamsClient_IncomingCall;
teamsClient.Dispose();

How it works

TeamsConnector does not make use of the Graph API, instead it uses UI Automation to interact with the Microsoft Teams window and the Office UC API to get presence information.

Product 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 was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 433 4/7/2023