How to program to attend the next Microsoft Teams meeting

1 minute read

If you click the link in the email such as the Teams meeting request email, Teams will start up and go to the meeting participation screen.
As long as you can get the URL written there, you should be able to hit the API that launches the URL according to the OS-specific method.

With Xamarin.Forms, it’s like ʻawait Xamarin.Essential.Launcher.OpenAsync (URL of an online meeting); `.

How to get the URL of an online meeting

You can get this URL with the Microsoft Graph API. I think I’ll be fetching my upcoming meetings in many cases, so I’m going to use this API.

List events

The resulting value will be an array of objects representing the event (JSON when hit with the raw HTTP API) and a bool value that can be used to check if the meeting is online with the ʻisOnlineMeeting property. If this is true, you will find the desired URL in ʻonlineMeeting.joinUrl.

If you do it in C #, the process of hitting the API to get the URL and opening it is as follows.

var eventsResult = await _graphServiceClient.Me.Events
var firstOnlineMeeting = eventsResult.FirstOrDefault(x => x.IsOnlineMeeting ?? false);
if (firstOnlineMeeting == null)
    await DisplayAlert("Information", "Cound not find an online meeting", "OK");

if (await Launcher.CanOpenAsync(firstOnlineMeeting.OnlineMeeting.JoinUrl))
    await Launcher.OpenAsync(firstOnlineMeeting.OnlineMeeting.JoinUrl);

The _graphServiceClient class is an instance of the Microsoft.Graph.GraphServiceClient class in the Microsoft.Graph package. Since you need Calendar.Read permissions to call this API, register an app with the following permissions in Azure AD, sign in using its ClientId, etc., and get an access token in advance. Let’s go.


How it moves

If you run the button click event with the source code pasted on Android, it will work as follows.