Teams Status Update via Power Automate

Setting your status in Teams. Are you available, busy or maybe do not disturb? Did you know that it’s possible to set your status automatically using Power Automate? The method I am about to share is undocumented and is for you to explore and test independently but based on my initial tests, it works. Not only can you set your status, but you can also set an expiry and update your message. Interested in giving this a try yourself? Then please read on.

There are two unpublished URIs that allow you to do this.

  1. https://presence.teams.microsoft.com/v1/me/forceavailability
  2. https://presence.teams.microsoft.com/v1/me/publishnote

In the USA?? Or using a US tenant? You might need to use https://noamdf.presence.teams.microsoft.com or https://presence.gcc.teams.microsoft.com or you will get a Status 301 error when the action runs.

Initially, I built a proof of concept in Postman and was able to resend an HTTP PUT to both destinations, repeating the authorisation token grabbed from my browser session. This worked, yet how would this work in Power Automate? I tried getting a token via graph and playing that back to the HTTP action but that simply didn’t work, out of curiosity, I tried the Send an HTTP Request to SharePoint action, which as the name suggests allows you to invoke a SharePoint REST API.

SharePoint Rest API

Much to my surprise, it worked! In one single action, I can update my status or message via Power Automate!

Set my Status

The body on the update status is a single object containing a single key / value. Key: “availability” The value of the availability can be set to one of the follows:

“Available”
“Busy”
“DoNotDisturb”
“BeRightBack”
“Away”
“Offline”, activity: “OffWork”

This is how your action should look

Set your presence in Teams via Power Automate

If you want to set an expiry for your availability, you can also include an optional “desiredExpirationTme”. Here is a sample payload with this set:

{
  "availability": "DoNotDisturb",
  "desiredExpirationTime": "2021-08-29T14:29:01.834Z"
}

Set my Message

Much like the first action, updating the message is just as easy. A single key / value. This time the key is “message”. The value is based on your exact message. Below you can see that I am “Working on my next YouTube Video”.

Update my Teams Note

If you are looking to set the option “Show when people message me”, you can simple add the XML tag <pinnednote></pinnednote> to the end of your message.

{
    "message": "Recording a new video, please leave me alone<pinnednote></pinnednote>"
}
show when people message me

If you are looking to include an expiry date/time for this action, you can include the option “expiry” key / value. Both dates are in the ISO8601 format which you can read up about here.

The other observation is that in the UK we are in British Summer Time, which is UTC+1. All dates submitted via this action appear to be 1 hour ahead. Therefore my assumption is there is a need to adjust the expiry or desiredExpirationTime based on UTC.

Offline?

Set your presence as offline

If you are looking to set your status to offline, the availability key value needs to be accompanied with the activity value which has a default of “OffWork“.

{
"availability": "Offline",
"activity": "OffWork"
}

Reset your Status?

During testing and observation of the API, it would appear that in order to reset your status, you can simply send an empty body to the earlier endpoint. Please let me know if that works for you?

Copy the action into your Flow

If you are looking for an easier option, copy the code below to either Set your status or update your message and paste it straight into Power Automate via “New step” -> “My Clipboard”.

{"id":"df8ed291-8914-430f-b8f9-bd02-83cc554c","brandColor":"#036C70","connectionReferences":{"shared_sharepointonline":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline/connections/64fe180a9817427a81aa7d96a25630de"}},"shared_webcontents":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_webcontents/connections/e39ac199af6243a0a479d5982da9e26b"}},"shared_teams":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_teams/connections/shared-teams-f41b4e3d-0b06-40c0-ae62-0ff8ebe47571"}}},"connectorDisplayName":"SharePoint","icon":"https://connectoricons-prod.azureedge.net/releases/v1.0.1505/1.0.1505.2520/sharepointonline/icon.png","isTrigger":false,"operationName":"Set_My_Status","operationDefinition":{"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_sharepointonline","operationId":"HttpRequest","apiId":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline"},"parameters":{"dataset":"https://presence.teams.microsoft.com","parameters/method":"PUT","parameters/uri":"/v1/me/forceavailability/","parameters/headers":{"content-type":"application/json"},"parameters/body":"{\n\"availability\": \"Available\"\n}"},"authentication":{"type":"Raw","value":"@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']"}},"runAfter":{}}}
{"id":"2d33557a-8219-4b60-97af-d5d6-cac4a8d3","brandColor":"#036C70","connectionReferences":{"shared_sharepointonline":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline/connections/64fe180a9817427a81aa7d96a25630de"}},"shared_webcontents":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_webcontents/connections/e39ac199af6243a0a479d5982da9e26b"}},"shared_teams":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_teams/connections/shared-teams-f41b4e3d-0b06-40c0-ae62-0ff8ebe47571"}}},"connectorDisplayName":"SharePoint","icon":"https://connectoricons-prod.azureedge.net/releases/v1.0.1505/1.0.1505.2520/sharepointonline/icon.png","isTrigger":false,"operationName":"Update_My_Note","operationDefinition":{"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_sharepointonline","operationId":"HttpRequest","apiId":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline"},"parameters":{"dataset":"https://presence.teams.microsoft.com","parameters/method":"PUT","parameters/uri":"/v1/me/publishnote","parameters/headers":{"content-type":"application/json"},"parameters/body":"{\n    \"message\": \"Working on my next YouTube Video\",\n    \"expiry\": \"2021-08-29T13:30:00.000Z\"\n}"},"authentication":{"type":"Raw","value":"@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']"}},"runAfter":{"Set_My_Status":["Succeeded"]}}}

Remember this is a proof of concept but something that is worth exploring for very little effort. Please let me know how you get on with your own testing.

Update **08/09/2021** it would appear that Microsoft are working on this functionality in the form of a Graph API endpoint. At this point in time you can not set DND presence and the endpoint is in preview. It’s therefore worth keeping an eye on this article and let me know of your experience and use cases by leaving your comments below or reaching out to me on Social Media

Share