Hello everybody. I try my best to blog about new and unique Microsoft Teams related stuff at least once a month. If you’re new to my stories, feel free to check out my previous articles here.
Today we’re going to take a look at something very cool. A few months ago, I wrote this little code snippet which lets you change a Teams user’s presence by using PowerShell and the Microsoft Graph API. The API endpoint is documented here. You might be asking yourself: why would we want to do this in the first place? Teams already updates our presence if we’re in a call, a meeting or just busy because of an Outlook appointment, right?
Use Cases
Setting the presence of a user can be very useful if for example not all your users are on Teams yet. Let’s say that we’ve still got a legacy PBX system with SIP devices registered to it, but we use Teams for internal calls. There’s no way to know that a user is already on the phone unless the user specifically updates his status to Busy or Do not disturb. A user can’t set his own status to “In a call” or “In a meeting” though.
![](https://www.sharepointeurope.com/wp-content/uploads/2022/09/Set-your-Teams-Status-to-In-a-Call-when-using-other-Calling-Meeting-Apps-on-iOS1.png)
If we’re using an anynode SBC for example, we could implement a Route Supervision which calls an Azure Function, whenever a user receives or starts a call on a legacy PBX system. The Azure Function would then send an http POST request to the Graph API to change the presence status of the user.
Since Microsoft has now released the SIP Gateway the need for such a solution has significantly decreased because the SIP Gateway already handles Teams presence out of the box. If you’re interested in learning more about the SIP Gateway for Teams, please check out this session from Commsverse from my colleague Thorsten Pickhan.
What about other use cases?
I know, we all love Teams but sometimes we do need to use other calling and meeting apps such as Skype, Zoom, WhatsApp, or Discord. Don’t you just hate it that Teams doesn’t know when you’re already on a call in another app? Today, we’re going to change that!
The Power of Siri
If you have an iPhone or iPad you probably know about Siri Shortcuts and Automations. If you don’t know them already, I highly recommend checking them out. Shortcuts and automations are like local Power Automate Flows which are created and executed on your iOS device. Today I discovered that you can actually do http POST requests with Shortcuts. How cool is that?
Granted, coding or building shortcuts is quite a hassle on such a small screen but there’s an easy workaround for that. We’re just using the Shortcut to call an Azure Function and let the Function do all the work for us.
Creating an Azure AD App Registration
First, we need an Azure AD App where we can grant the required permissions to set and clear the Teams presence. There’s an exceptional tutorial here. (I also used the example code to acquire the token from this website.)
“Presence.ReadWrite.All” is the permission we need.
![](https://www.sharepointeurope.com/wp-content/uploads/2022/09/Set-your-Teams-Status-to-In-a-Call-when-using-other-Calling-Meeting-Apps-on-iOS2.png)
Create an Azure Function
Next, we create an Azure Function. If you’re not familiar with Azure Functions, please read this article. The creating of a Function App and a Function is described under “Create the Refresh Card Function”.
Copy and paste the following code into your function. Populate the variables on lines 10–14 with your tenant specific information.
https://medium.com/media/fbe87f534b1d3226d302c1398dbb199f
Create the Siri Shortcut
Now, we’ll create a new Siri Shortcut. Choose “Get contents of URL” as your first action. Now go back to your Azure Function and copy its URL.
![](https://www.sharepointeurope.com/wp-content/uploads/2022/09/Set-your-Teams-Status-to-In-a-Call-when-using-other-Calling-Meeting-Apps-on-iOS3-1024x137.png)
Paste the URL into the Shortcut. I always use Sticky Notes to quickly synchronize text between my Windows PC and my iPhone.
Next, expand the action by clicking on the circled arrow which points right. This will reveal additional options. Change the Method to POST and add a key and a value (Text) to the Request Body. I used “Name”: “Azure”.
![](https://miro.medium.com/max/1400/1*JPlHNIr6mVHsBIA1HLoOqA.jpeg)
That’s it for the shortcut. You should now be able to run the shortcut. Every time you do so, your iOS device will call the Azure Function which will request a token and then set the defined user’s presence to In a Call.
By now, I hope you can understand why I didn’t bother to try and also build the authentication flow using only Shortcuts.
Building the Siri Automation
The last piece we need to do is to create an Automation which will trigger the Shortcut. Unfortunately, there aren’t as many triggers as I had wished but using “When an App is opened” does the trick, sort of.
In Shortcuts, switch from My Shortcuts to Automation on the bottom. Click + to create a new Automation. You want to create a Personal Automation.
Select “App” as your trigger and then select one or multiple calling Apps.
![](https://miro.medium.com/max/1400/1*Qi4dsjTt9HZZOb1tkTRRVA.png)
Then, add an action and search for “Run Shortcut”. Click on Shortcut and select the previously created Shortcut from the list.
![](https://miro.medium.com/max/1400/1*c9TA4amw9yA5TGJHnvOueA.png)
Click Next and then Done. Leave “Ask Before Running” enabled. This way you’ll be asked if you want to update your Teams presence each time you open one of the selected Apps. If you’re not making a call, you can just ignore or close the notification banner.
![Set your Teams Status to In a Call when using other Calling & Meeting Apps on iOS](https://miro.medium.com/max/1400/1*xnsJrcVZZlXYiUnOFGfqfg.png)
Now you’re all set. Every time you open one of your selected Apps (just Skype in my case) the automation will be triggered and ask you, if you want to set your Teams presence to In a call.
If you like, you can repeat all the steps and create another Function, Shortcut and Automation to clear the presence again, if you’re done with your call on the other App.
In this case, just replace line 42–51 with this code in the “Clear Presence Function” and choose “When an App is closed” as the Siri Automation trigger.
$Body = @"{"sessionId": "bf3cbc08-e5b0-47bb-a4f0-89e3e3f7adac",}"@Invoke-RestMethod -Method Post -Uri "https://graph.microsoft.com/v1.0/users/$UserId/presence/clearPresence" -Headers $Header -Body $Body -ContentType "application/json"
Demo
Here you can see the Automation in Action. At first, the user’s Teams presence is “Available”. When Skype is opened, the Automation is triggered and confirmed by the user. When Teams is opened again, we can see that the status has changed from “Available” to “In a call”. Because Skype was closed/minimized when Teams was opened, the second Automation, which clears the Teams presence again is triggered and allowed to run. This resets the Teams presence to its original state. Teams is closed and opened again to force a refresh of the presence.
![Set your Teams Status to In a Call when using other Calling & Meeting Apps on iOS](https://miro.medium.com/max/1200/1*WA9VV3zTsQF3ov8DnQGfog.gif)
What’s cool is that this even works when you’re getting an incoming call in an App like Skype, WhatsApp etc. When you accept the call, the App is opened and thus triggers the automation. I can’t record that on video because iOS screen recording is stopped if an incoming call gets accepted and the notification does not show up, when screen sharing through AirPlay is active.
Bonus
Because we now have Shortcuts to set our Teams presence to “In a call” or clear the presence again, we can also use Siri to execute these Shortcuts. All we have to say is Hey Siri, followed by the name of the Shortcut. E.g. “Hey Siri, Set Teams Presence” or “Hey Siri, Clear Teams Presence”.
Recommended Blog: Low code bot onboards members to Microsoft Teams channel
About the Author:
ultra high definition enthusiast / skateboarder / xbox guy / mini driver / blogger / in love with @boxbread / consultant @twincapfirst / thoughts are my own.
Heusser, M. (2022). Set your Teams Status to In a Call when using other Calling & Meeting Apps on iOS. Available at: https://medium.com/@mozzeph/set-your-teams-status-to-in-a-call-when-using-other-calling-meeting-apps-on-ios-3409d68aceb6