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.
- https://presence.teams.microsoft.com/v1/me/forceavailability
- 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.
27/09/2024 **Update**
Hi folks, thanks for reaching out. It would appear that the root cause of this is the SharePoint HTTP connector. The teams API is still available but sadly the SharePoint HTTP Action has been updated so that it only allows SharePoint Rest API calls to be authenticated. There is absolutely nothing I can do about this.As far as I can tell, you have two main options:
Option 1: used the Entra ID Pre-auth HTTP action and create a connection with https://presence.teams.microsoft.com as both endpoints. This will allow you to continue using the Teams Endpoint. Please note that this is without any guarantee and may eventually also be restricted.Option 2: You can look to use the Graph API presence: setPresence – Microsoft Graph v1.0 | Microsoft Learn. I understand why this is not an option for everyone as it will require an app registration in Azure. I have explored the standard HTTP actions for Teams and Users and neither support this for User Authentication sadly. When I published this in 2021, I never expected it to have such an impact., I appreciate your respectful comments below, as I am sure you appreciate I do this research and sharing in my spare time.
The original post is as follows:
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.
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
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”.
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>" }
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?
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
This was incredibly helpful. I was able to get this to work using calendar events as a trigger and tt works really well. In the status message option, is there a way to trigger checking the box called “Show when people message me”?
Good idea David! I will take a look and add it to the article if possible. Thanks for the feedback and idea.
Hi David, simply add an XML string to your message. < pinnednote >< /pinnednote > i.e. This is a test< pinnednote >< /pinnednote >. I’ve updated the blog to reflect this and thanks again for the idea! Keep them coming.
Thanks for the quick response. This is awesome and works perfectly! I’ve spent way too many hours trying to solve this. You’ve saved me a ton of headache. Thank you!
I was also able to add the step “Add to Time” and use a “Dynamic content / Calculated Time” block within both expiration lines. It’s great for having it dynamically run on a daily and weekly schedule for after-hours and weekends.
I had a play too. There is a trigger “Office 365 Outlook – When an upcoming event is starting soon (V3)”. This also retrieves the event end datetime which ties in nicely with the expiry. I’ll update the article to include this too as I think it will be the most popular use case. Thanks again for reaching out. It makes blogging worthwhile. Feel free to reach out with any more challenges you’re working on.
I might have been too prematurely excited. Apparently, there’s a bug in recurring events. The flow runs on the first calendar event, but it doesn’t run on subsequent ones.
It looks like others have reported this issue, but I haven’t found any follow-up. For the time being, I can set that schedule from within the Flow, but it would be better to have more control within the Outlook and Teams Calendars.
Here’s the link that I found https://powerusers.microsoft.com/t5/Using-Flows/quot-When-an-upcoming-event-is-starting-soon-quot-trigger-isn-t/td-p/93364
Hey David,
Are you using v3 of the trigger? I have looked at limitations of the triggers/actions here https://docs.microsoft.com/en-us/connectors/office365/#when-an-upcoming-event-is-starting-soon-(v3) and it states (at the bottom of the doc): The When an event is added, updated or deleted (V3) trigger fires on each event occurrence. When you change a recurring event, it affects all events in this series, so the trigger fires multiple times based on how many events you have in the series. I am yet to try this myself.
Yes, I’m using the V3 trigger. I created copies of the event and those appear to be working, but if it’s just a recurring event, it doesn’t run for the second one. Their documentation says it should work, so if it’s not a bug, it could be something with my setup. I’ll keep playing with it too.
I’ve setup a 9am reoccurring event… will report back and we can compare notes 😉
Works great Damo! Thanks for sharing
N.B. Make sure you amend the expiry date in the provided Message text, otherwise, like me, you’ll wonder why this isn’t appearing in your Status 🙂
Hi Bill, do you mean change it from the date I’ve supplied? It can be removed entirely but can also be used to reset your status at a future date/time. I am really curious to hear how this works for folk and appreciate your feedback. Cheers.
I have managed to set everything up, flow also approved with no errors in test mode. But my status will not change in Teams? Any ideas what can be wrong?
My code:
{
“inputs”: {
“host”: {
“connectionName”: “shared_sharepointonline_1”,
“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 \”availability\”: \”Away\”\n}”
},
“authentication”: “@parameters(‘$authentication’)”
}
}
Hi Svenne, you’ve used the wrong endpoint…/v1/me/forceavailability is the correct one for updating the status. You’ve passed the availability to the publishnote endpoint and so it will pass but not do anything.
Tx, I made it work, works fine between Available and DoNotDisturb.
What I don’t manage to do is Offline, I get error in PowerAutomation have tried all different combinations
{
“inputs”: {
“host”: {
“connectionName”: “shared_sharepointonline_1”,
“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”: “Offline”,\n“activity”: “OffWork”\n}”
},
“authentication”: “@parameters(‘$authentication’)”
}
}
Problem solved
As someone just starting to work on Power Automate flows, is there a way to set the expiration dynamically? My plan is to make a flow that I can trigger manually for my lunch break and have the presence and message to expire 1 hour after I trigger it.
Absolutely, you could take a date/time from a form response or an outlook event, just make sure it is formatted in ISO8601 – an article available on my blog
Hey Scott, there is and I am planning to demo this over the weekend with an update to the article and new video. If you want to give me your specific requirements, I can attempt to capture it for you. How do you plan to manually trigger?
Hey Damo, that’s awesome! I’m just manually triggering from the Power Automate flow page, but if you know of a better way, I’m all ears. Since my lunch floats to just whenever works best for my day, my plan is to run the flow, have it change my status to Busy, trigger the second flow to set an away message saying I’m at lunch, and both of those expiring after one hour.
You could create a flow button on your phone or maybe have flow prompt you at midday with an adaptive card and when you hit the confirm, it updates the status and starts the 1 hour countdown.
I too have everything setup as above but Teams status will not update even though i get a successful run.
My Code:
{
“host”: {
“connectionReferenceName”: “shared_sharepointonline”,
“operationId”: “HttpRequest”
},
“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\”: \”Offline\”,\n}”
}
}
Is there a method in which I can reset status (rather than changing to available)?
The “offline” body is a bit more complex than the others, as it requires a default activity. try:
{
“availability”: “Offline”,
“activity”: “OffWork”
}
In order to reset, you can send an empty body.
I’m trying to use the Offline option too and I get an error when using the above suggestion and nothing changes if I just use the availability key.
Error is
{“message”:”The request is invalid.”,”modelState”:{“$type”:”System.Web.Http.HttpError, System.Web.Http”,”incomingForcedAvailability”:{“$type”:”System.String[], System.Private.CoreLib”,”$values”:[“An error has occurred.”]}}}
clientRequestId: bca05bc3-ff55-42f3-a638-7030ccdf11a7
Any ideas?
Sometimes the error messages just mean nothing. Can you screenshot your flow and email me? Ideas @damobird365.com
Perfect – that has me fully up and running now.
Reoccurring trigger (every 5 mins) with a condition to check working days/time and offline/online.
Thank you 🙂
Hi Damo,
I’ve got everything running, but for the life of me I cannot get the Teams status to ‘reset’.
I’ve tried several approaches:
1. Using the ‘expiry’ option (tried all sorts of date formats including ISO8601 for a duration)
2. Using ‘desiredExpirationTime’ option (again, all sorts of date formats)
3. Using another undocumented URI that resets the user’s status (but couldn’t get it working) – for reference: https://docs.microsoft.com/en-us/graph/api/presence-clearpresence?view=graph-rest-1.0&tabs=http
Do you have any ideas?
Thanks in advance
Hi Shane, i’ve had a quick look and it would appear that an empty payload will reset your status. I will update the article to demonstrate.
Thanks Damo,
I can confirm that this works!
Cheers
Hi Damo
Thanks for your blog and the youtube video about this topic. Its awesome to be finally able to change the Teams Status via Power Automate and also the additional options with the status message.
I found three post in the Power Automate Community looking exactly for this action since a few years. One of them I already answered and mentioned you.
This are the link to the other two.
https://powerusers.microsoft.com/t5/Power-Automate-Ideas/set-MS-Teams-status-message/idi-p/357255
https://powerusers.microsoft.com/t5/Power-Automate-Ideas/Auto-Teams-Status/idi-p/363018
Feel free to answer them linking to the YouTube Video and blogpost.
Thanks again and Im still excited about the new possibilities with this “actions”.
Lars
Cheers Lars. I spotted it. Thank you. If there are any other challenges you are experiencing, please drop me a note.
Dumb question probably but how do you edit the code? I’ve tried the clipboard paste but it doesn’t show up.
If you copy the sample json code to your clipboard, you can then navigate to new step in Power Automate and “My Clipboard” and hit Ctrl + V, which will give you the pre-built action.
Interesting find. Are there any other endpoints that can be used by this “Send HTTP” Action? i’m really curious what other non-sharepoint endpoints are available. Also, not sure if it’s technically a violation of a license in some way?
There are definitely other endpoints, like zipping files. Not sure about violations but it’s most definitely unsupported. So use at your own risk. It does drive creativity and will hopefully in time will be supported officially as it has a use case.
Still any ideas how to reset status from dnd? I succesfully created an automation where my Teams status is set to dnd and status message is shown when a calendar meeting starts, but I am unable to clear the status after the meeting ends. However, I can clear the status message with dynamic content (“expiry”:end time with time zone”) but for some reason this does not work for dnd. I know you mentioned empty body but I have no idea how to trigger it within the same automate (I am quite a beginner).
You could insert a delay, set status, delay hour, set status.
Yes, but that would be static, right? I would like to clear the dnd when the calendar meeting ends, not after a certain period of time 🙂
The delay can be dynamic, using delay until and specifying the meeting end time?
That might be it, thanks for the idea (did not even realize that there was such an action). First effort gave me an error (BadRequest. The ‘timestamp’ value of the ‘Wait’ action ‘until’ inputs must be specified in UTC…etc”) but it I’ll look into it, at least there’s hope 🙂 Thanks for replying!
No problem. Here’s a post on formatting date times too https://damobird365.com/formatdatetime-and-formatting-a-string-date/
I managed to get this up and running. Convert timezone did the trick. I also considered using a delay based on the lenght of the event. Thanks for this great post!
Thanks for coming back to let me know. I really appreciate the feedback. Glad you’re up and running and if there are any other challenges or ideas you would like explored, drop me a message 😉
Thx for this useful tip, i’m using it since couple of days for updating my message status. Alternative questions :
– Do you know about the Expiry parameter, can we set it up at “today” like in GUI?
– Any clue to trigger it based on your localization? or Wifi name?
Today is just setting the expiry to 23:59 – so something like formatdatetime(utcnow(),’yyy-MM-dd’) and append T23:59:59.999Z to the end.
For the location, there is a location trigger but I haven’t tried it. You could also look at creating a Powershell to query your Wifi and create a file on OneDrive, which could then trigger your update like follows: https://www.youtube.com/watch?v=kPbn4WMCXUU
Hi,
This is exactly what i need but cant get it work.
i get an error: 401 UNAUTHORIZED
Are you USA? There is potentially a different url to use.
sorry my mistake, got it work!
Thanks for this useful tip, but I can’t seem to get a dynamic expiry to work despite several tries. It always work when adding a date and/or time manually. I.e. 2021-11-03 or 2021-11-03T23:59.
Any tips?
Have you tried 2021-11-03T23:29:01.834Z
It works like a charm for me, but is it possible to change a users status? i have a check in app where a sharepoint list is updated. because of /v1/me/publishnote i changes the status of the connection user. Can it be a variable? /v1/%variable% /publishnote
I don’t believe you can update other users status using a change of endpoint, it’s designed for /me/.
It was fun as it worked, but apparently starting on Nov 16, 2021, I started to get plain Fails and as I try it now with Graph Explorer, this is what I get:
{
“message”: “Authorization has been denied for this request.”
}
Hi Antti, where is your tenant based? I have just tested and I can still update my Status and Message with a new flow that I have just created using the samples on the blog. It’s all very possible that Microsoft have blocked it as it is unsupported but could there be something up with your tenant? I wonder what the difference could be?
I am so glad to have found this. Unfortunately it may not work for GCC (US government) clients. I have tried the USA specific URL and still receive Status 301. Thanks for the article, fingers crossed we get a more official way to do this soon!
Here is was I am passing into the Send HTTP request:
{
“host”: {
“connectionReferenceName”: “shared_sharepointonline”,
“operationId”: “HttpRequest”
},
“parameters”: {
“dataset”: “https://noamdf.presence.teams.microsoft.com”,
“parameters/method”: “PUT”,
“parameters/uri”: “/v1/me/publishnote”,
“parameters/headers”: {
“content-type”: “application/json”
},
“parameters/body”: “{\n \”message\”: \”Hello? Is this thing on?\”,\n}”
}
}
Solved! Thanks to Damien’s brainstorming and some testing.
If you are a GCC client user (US Government). Try https://presence.gcc.teams.microsoft.com
Neither site address is working for me 🙁 Neither https://presence.teams.microsoft.com or https://presence.gcc.teams.microsoft.com are working in the Power Automate. Any update on a new URL for this?
What’s your error and where are you based? The is a GCC address too.
A couple of quick questions.
1. I am trying this without the sharepoint bits, but in Postman, When trying to set custom text via the publishnote API call, I get the following message:
Authorization has been denied for this request
2. Assuming I can figure no.1 is it possible to set someone else’s status text? A manager might want to set a status for someone who goes on vacation and forgets to do it themselves.
3. Is there an API I havent seen with Fiddler that enables me to retrieve custom status? The activity/availability combo is a bit basic.
I did manage to get setPresence working in C# but it took some work. Testing ClearPresence now
Thanks
Mark
The great thing about the SharePoint action is that it deals with Authentication. This endpoint cannot be delegated and so 2 is only achievable (I believe) if you share credentials. I’m not aware of any custom status messages beyond those I have listed. There is a beta graph api call here https://docs.microsoft.com/en-us/graph/api/presence-setpresence?view=graph-rest-1.0&tabs=http&WT.mc_id=DX-MVP-5004666 that you could explore. Please let me know how you get on.
Really appreciate the time and effort you’ve put into this, Damien, thank you.
Anyone know how to avoid the “Run flow” prompt you get after hitting Play button in the “My flows” list? I just want the thing to run, that’s why I pressed the Play button 🙂
anyone try to get it to work with microsoft graph yet? i noticed they have a lot of new documentation getting pout out on microsoft graph, and noticed its out of beta
Hi David, are you referring to https://docs.microsoft.com/en-us/graph/api/presence-setpresence?view=graph-rest-1.0? It’s application permission based so will require an Azure app registration I believe. I’ve been watching it too 😂
Hi, I am struggling to get the Pinned Note to work. Have copied the exact same code but it doesn’t seem to come through?
I seem to be getting a 301 status error for the publishnote url which suggests it has been moved. Anyone know the new URL?
Are you US? Try https://presence.gcc.teams.microsoft.com
I am writing a service where I am trying to programmatically update the team status for a user.
How can I generate token for this API using Graph Presence ?
https://presence.teams.microsoft.com/v1/me/publishnote
Or is there any other way to get the token to call this API programatically?
Awesome, is it possible to get other users presence? (read only)
Not with this method, but you can look at https://docs.microsoft.com/en-us/graph/api/presence-get?view=graph-rest-1.0
Very basic question, I hope. What do I need to insert to set the duration for the Status Message to “Today”
Thanks for the blog!!!
I’ve done the following:
– setting a variable with following expression: startOfDay(adddays(utcnow(),1))
– using the variable as expiry date: “expiry”: “varName”
Please note that varName has to be inserted as dynamic content, not as text.
Hi,
when I enter the URL in the Send an HTTP Request to Sharepoint
https://presence.teams.microsoft.com
it gives me an error
“We are unable to find the site address. Please try selecting a site address from the dropdown.”
I tried re-creating the connection (Cloud-services), which completes successfully with my 365 user but the flow still gives this error on the sharepoint step
It appears that you can ignore the warning. Just save the flow and it will work.
Hi, is it possible to GET my actual absence message into a Power Automate variable?
Hi, Ive been trying for hours and cant work with the URL, constantly getting status 301, tried all the URLs but apparently the URL has been shifted by Microsoft to some Graph site, sorry if im wrong about anything i am just beginner at this. Can someone please help.
Hi, Everything works fine. Just want to check if we can do a status check and change if the status not in a particular status then change the status. Else do nothing.
example if I’m in a call and my status is automatically on “In a Call”, I want to retain the status else I would set it to “Available”.
Thanks in advance.
I don’t see why not, just use a condition. You could use get presence https://learn.microsoft.com/en-us/graph/api/presence-get?view=graph-rest-1.0
This is a great feature, and it works perfectly!
I have a question though – recently MS Teams has released a feature where you can indicate your location, via a drop down (options are: ‘Office’, ‘Remote’, and ‘Clear location’. What would be the required JSON code to update the ‘work location’ in Power Automate? Thanks!
@DamoBird – I have searched online, and I do not think there is an API to connect this new MS Teams feature. Do you agree?
What new feature do you refer to?
Hi @DamoBird365, I was alerted to this a couple months ago:
– in the drop-down menu that appears after selecting your name/icon (top-right corner of the Teams App), there are now THREE options just below your name/email (I think it used to only be TWO) : “Status”, [NEW] “Work Location” (appears as a dropped-pin that might appear on a map, with a ‘+’ in the middle of it), and “Edit status message”
– when you select the dropped-pin icon, there are two available options: “Office”, and “Remote”.
– after selecting one of the two options, a third option then appears with an option to “Clear location”
I am interested in how we might be able to add the selections of “Office” or “Remote” into the JSON code string alongside the teams message?
Does this description make sense?
It does, just struggling for time. Have you checked developer options?
You can set the work location using the parameters below.
Use the Uri:
/v1/me/workLocation
location:
“0” clears your status,
“1” is in office,
“2” is remote
Example body:
{
“location”:”1″,
“expiration”:”2023-08-11T15:21:01.834Z”
}
Champion, thank you for sharing 👍
IT WORKED!!!! THANK-YOU SO MUCH!!
Of note, when I copied/pasted from your “Example body” below, the pasted content created ‘curly’ quotation marks, instead of the required ‘straight/vertical’ quotation marks.
When I went through and deleted all the ” ‘s and manually replaced them, the JSON coding worked.
Thanks again
I am not exactly sure what ‘developer options’ pertains to? If by ‘developer options’ you are referring to ‘Graph’, then yes, I looked (unsuccessfully), but to be honest I wasn’t entirely sure what I was even looking for…
No worries about the time to respond – I was hoping that it was clear for you, which it appears it was. If you have any other insight into this, I look forward to hearing what you have to offer!
Hi Damo.
I am trying this in 2 of my tenants and getting
“{“message”:”The request is invalid.”,”modelState”:{“incomingForcedAvailability.availability”:[“An error has occurred.”,”An error has occurred.”]}} followed by a client request ID. Any ideas?
Thank you
Thank you so much!! Also used this page to troubleshoot: https://powerusers.microsoft.com/t5/Using-Flows/Setting-MS-Teams-status-message/m-p/1324683#M26613
Super helpful man, thank you. Just a heads up, the instructions for “Reset your Status?” do not specify which URI to use, and the screenshot shows the wrong one (at least from my tests).
Screenshot shows “/v1/me/forceavailability/” but I only found success using “/v1/me/publishnote” with the rest of the settings unchanged (headers and empty body) to reset my status.
Good morning, I’ve been using your code for some time to set my status to offline/connected in Teams, but a few days ago it started to fail. Could something have changed in the API?
This is the error message I get:
{
“status”: 400,
“message”: “{\”$\”:{\”errors\”:[{\”errorMessage\”:\”The JSON object contains a trailing comma at the end which is not supported in this mode. Change the reader options. Path: $ | LineNumber: 3 | BytePositionInLine: 0.\”}],\”validationState\”:1}}\r\nclientRequestId: xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”,
“source”: “https://presence.teams.microsoft.com/v1/me/forceavailability/”,
“errors”: []
}
Thank you very much for sharing it, it has been very useful.
Hi, I have the same issue.
From December 13th, one flow started to fail. Yesterday I changed it from:
“availability”: “Offline”,
“activity”: “OffWork”
to
“availability”: “Away”
and it started to work.
My assumption is that some naming changed in Offline Status, but I couldn’t find anything related to this.
After read your message, I reviewed again the flow.
I think I found the problematic comma. The Body was:
{
“availability”: “Offline”,
“activity”: “OffWork”,
}
I removed the comma after Offwork, and now it’s working…
{
“availability”: “Offline”,
“activity”: “OffWork”
}
But this comma was there from the beginning… something has changed in teams.
I would agree that your first example is invalid json because of the comma. Can you check your flow history. I would have thought that would always fail.
It was working with the comma until December 13th… I can’t attach and image, but here is the flow history:
https://pasteboard.co/OARz4ldIkT2q.png
106 / 5.000
Resultados de traducción
Resultado de traducción
Something would change that day, that before it let the comma pass and now it doesn’t. Thanks anyway for answering.
I never had the Comma at the end, and the flow still fails:
{“$”:{“errors”:[{“errorMessage”:”‘0xE2’ is an invalid start of a property name. Expected a ‘\”‘. Path: $ | LineNumber: 1 | BytePositionInLine: 0.”}],”validationState”:1}}
clientRequestId: e886d36b-a908-452c-81d0-6996e72a27d5
I solved my issue. It turned out I had left and right double quotes (disallowed) rather than standard double quotes. looks like these characters came from copying from the web browser into an editor when creating the configuration file. Swapping left and right with standard double quotes fixed the issue.
Thanks a lot!
{
“message”: “Recording a new video, please leave me alone”,
}
The Pinned Note option is not working. I have the code above with comma at the end, the flow fails with error
{“$”:{“errors”:[{“errorMessage”:”The JSON object contains a trailing comma at the end which is not supported in this mode. Change the reader options. Path: $ | LineNumber: 2 | BytePositionInLine: 0.”}],”validationState”:1}} clientRequestId: 28be303a-3730-4177-9c5a-c13e724a3fdb
Very good spot 👍 the comma has now been removed.
Hey Folks!
I am still getting 301 error for all 3 URLS:
https://presence.teams.microsoft.com
https://presence.gcc.teams.microsoft.com
https://noamdf.presence.teams.microsoft.com
Please let me know if there are any other URLs we are familiar with.
Any further guidance would be much appreciated!
This is still working in the US as of 3/11/2024. Used the URL
https://presence.teams.microsoft.com
This flow stopped working for me on March 20th, tried all 3 URLs listed above. It just fails as “{“message”:”Authorization has been denied for this request.”}”.
Changed my connections and still same issue. Any suggestions?
I just had the same issue and resolved it by going into the flow Send HTTP request and clicking “Change connection” at the bottom. I then chose “Add New” to create a new connection and now it works.
Thanks John C. Mine also stopped working and adding a new connection also worked for me as it allowed me to sign in again. To clarify for others you find this setting by clicking on the elipses (…) at the top right of the Send HTTP request.
Same here as-of 8/19/24. Thanks All!
I too just got the same error.. I have been using your instructions with https://presence.gcc.teams.microsoft.com and this week it started failing… I have a separate flow for each day of the week and a 6th one for “Off-Work”… I will have to create a new connection for each one, I guess… I am not looking forward to updating 5 more flows, three connections each…
I think the issue may be because Microsoft is killing off the “Classic” Teams and replacing it with “New” Teams. The website in this guide is: https://presence.teams.microsoft.com/v1/me/forceavailability
but neither https://presence.teams.microsoft.com/v1
nor https://teams.microsoft.com/v1
go anywhere anymore. I think Microsoft is shutting down the v1 Teams sites.
However, if you browse to:
https://teams.microsoft.com/v2
It will open the New Teams in your web browser. Unfortunately, there is not a site for:
https://presence.teams.microsoft.com/v2
I’m not sure if there is a “presence” site for the v2 (NEW) Teams. I think we need to find a presence website for the New Teams for this method to work in the future. Otherwise, we may need to come up with a different approach for tackling this goal.
Seems that as of this week, this no longer works. Been getting 401 errors, my company’s IT is clueless as to why but I’ve seen a couple posts on StackOverflow noticing the same so it must be a Microsoft thing.
Hi, replied above this does still seem to work. Sounds like some folks in comments have had to reset something in the flow to get back in gear.
After finding this post and getting it to work, was looking for a way to also set myself available at login. I don’t have premium and the auth/token/etc stuff is rather complicated.
Figured out a hacky way to do it by using Sharepoint – “When a file is created or modified (properties only)” trigger and same HTTP request as here as the action. I then linked a Sharepoint folder with Onedrive and use task scheduler at login event to repeatedly overwrite a txt file, rather than accumulate them.
I can provide specific steps but think most folks here can figure it out. Thanks!
How do you do this under the New Teams? My flow no longer works.
Using Change Connection worked for me as well – thank you!!! Flows are updating my status once again.
Woops, after 2 years of successful running I’m facing same issue as others “Unauthorised” “statusCode”: changed from 200 to 401 in the Output 🙁 I tried to recreate the connection but it doesn’t solve it for me. I’m UK based.
Yes Sir,
Same problem with me. Think they patched this.
And.. same with me, It failed as unauthorized after having this running everyday for almost1.5 years lol
Could you try the updated link in the blog post- just added for EMEA. See if that works?
Same for me in Denmark. From both logic apps and Power Automate. Same behavior.
Happened between 12th and 13tg of september for me
Am able to authenticate without client-id using the Power Shell cmdlets locally (Set-MgUserPresence) and make a call without error responses, but does not seem to change my presence in my logged in Teams-instance. The call through the SharePoint connector could do that
Could you try the updated link in the blog post- just added for EMEA. See if that works?
After using it for a year, the flow stopped working at 20/Sep/2024 reporting unauthorized.
I’m Australia based.
Guess they patched it now.
Could you try the updated link in the blog post- just added for EMEA. See if that works?
same here, it stopped working yesterday, error status code is: 401
Could you try the updated link in the blog post- just added for EMEA. See if that works?
Stopped working for me too. Tried noamdf, gcc, and emea. Still getting 401
Hi, a test with https://emea.presence.teams.microsoft.com fails with error: clientRequestId: 092b7859-1822-44e6-bf3d-75925700117e
US Tenant-Stopped working on the 17th in production tenant and 18th in Dev tenant. Same 401 others have described. Tried the updated link in blog post. Same result.
Hello, Started failing for me in the US yesterday. I tried changing the host name as you suggested with emea.presence.teams.microsoft.com and I get the same unauthorized error. I am using this for the publishnote capability.
Is there anyway now to do this via graph?
Same as others have reported but I am in the US. Stopped working today with 401 and I’ve tried all the updated links above with no luck.
hello i also start getting 401 since sept 20, in eu.
any alternative without graph? i get my teams presence status from this!
thanks
Good shout, maybe try https://learn.microsoft.com/en-us/graph/api/presence-setstatusmessage?view=graph-rest-1.0&tabs=http
no access to graph as end user 🙁
Hi,
Is there a way to do this with Graph inside Power Automate at all? I’ve never used Graph before.
This does look possible https://learn.microsoft.com/en-us/graph/api/presence-setstatusmessage?view=graph-rest-1.0&tabs=http and I hope to explore with a new post and video soon 👍
That would be great, thank you.
My flow also started failing on Sept 19th (I was using noam.presence.teams.microsoft.com) and no other site has worked for me.
I tested the Graph Explorer (https://developer.microsoft.com/en-us/graph/graph-explorer) and the call to https://graph.microsoft.com/v1.0/me/presence/ works (which I use for my BusyLight), so I seem to have the right permission, but I can’t get it to work in Power Automate.
I get a lovely 400 message:
URI path is not a valid Graph endpoint, path is neither absolute nor relative or resource/object is not supported for this connector. Resources: teams,me,users Objects: channels,chats,installedApps,messages,pinnedMessages. Uri: https://graph.microsoft.com/v1.0/me/presence/
I can’t decode this, not able to find a resource that explains me what I need to do, but I get the sneaky suspicion that using Graph requires more work, like registering an app within Azure or so. This would probably put an end to my busy light, as I won’t get my company allow this… so a solution that gets me back the status quo, without having to organize a ton of work to authorize, would be very much appreciated
Would appreciate an updated post as well.
But I am afraid it’s not going to work since a common user will usually not have required permissions for Graph API. 🙁
But I hope that you find a way.
I explored this API but my organizations restrictions prevent me from setting the necessary consent to utilize this.
I also needed to use the generic HTTP request out to Graph as the other two options built into Power Automate to handle authorization.
As it stands now, I’m dead in the water… oh well.
I’m devastated, haha! After having this work for over a year in here in Australia, it has failed since 20/09 for me, same error as other users. I tried emea, which didn’t work either. *sigh*
Okay, I have it working for me again, not getting the same detail as with the presence object before, but it works without any kind of app registration on Azure, so I’m happy for now.
1. Step: Go to the Graph Explorer (https://developer.microsoft.com/en-us/graph/graph-explorer), click on “Access token” directly below the Query area and copy the lengthy string into a notebook
2. Step: Within Power Automate, where you need it, create an action using the HTTP Request from “Office 365 Users”. There are several others, not all allow the calls to the presence functions, but this one worked for me. I only tested getting the presence
3. Step: In the HTTP request I set the URI to “https://graph.microsoft.com/v1.0/me/presence/”, I left Method on “GET” and Content-Type on “application/json”. Add a new CustomHeader below and enter “Authorization: “.
Done, save it, test it, my BusyLight works again.
Caveat though, I think the labels for the states might be a bit different, need to find a reference with all the variants, and it doesn’t have flags like “forced” anymore.
Okay, the token times out after a while, and getting a new one might require an oauth2 with Azure or through a registered app. I think this might be a dead end for people that are restricted by their organizations, like myself.
I agree that you would need an app reg, as the graph explorer bearer will expire after 3600s. The alternative is to use the entra id pre-auth. It currently works, albeit no guarantee it will continue.
If i try to add a block of “HTTP with Microsoft Entra ID (preauthorized) and set both fields to https://presence.teams.microsoft.com i get this error:
Failed to create connection for connection id ‘ …’
Connection creation/edit of ‘shared_webcontents’ has been blocked by Data Loss Prevention (DLP) policy ‘GLOBAL – DLP Personal Productivity env’.
That is your org blocking the connector. You would need to speak to governance / IT. They might allocate another environment.
Pre-auth requests want Premium Power automate subscription to be run.
For people who is using PA just to switch Teams status it is a little bit excessive)
I think access tokens also come with refreshtokens, which have a lifetime of 90 days.
Thus in theory you could write some logic to get refreshtoken from specific place, generate new access token from that, and use that. Also refresh the refreshtoken periodically. It’s the same as for Secure App model with PartnerCenter.
If you need to go that far just for presence, that’s a decision on it’s own. But I think it’s doable if you really want.
It’s an interesting solution for an end user. I wouldn’t want to encourage folk down this route though.
Thank you for looking for an alternative option. Look forward to seeing an update.
Any Solution found?
Thank you for resolving this for us. Very much appreciated.
I am new here and I am trying to change my Teams status daily during off hours to offline. I would like this run daily from Monday through Friday during 6pm to 6am. Any help would be appreciated
Hi @DamoBird365!
Like all the others on this post/forum, I have had failed flows that used to work after several years of success. After browsing the http actions, I noticed there is a “Send a Microsoft Graph HTTP request” for “Microsoft Teams” application – is there potentially an available solution here? I don’t know how to use Microsoft Graph, so I am unsure how it would work.
Any help is very much appreciated!
The action you mention, whilst it supports graph, is limited to specific endpoints and I don’t believe it supports this use case sadly https://www.linkedin.com/posts/damobird365_have-you-ever-used-the-sharepoint-http-action-activity-7247173322881298432-Sr3k
So I kind of got this working with the free tier power automate.
* Go here and Graph Explorer should automatically open, https://learn.microsoft.com/en-us/graph/api/presence-setuserpreferredpresence?view=graph-rest-1.0&tabs=http#code-try-1
* Go to Modify permissions and give it necessary consent.
* Change {userId} to your own, you can find it in Azure Entra ID’s user page.
* Then run query.
This is for setting preferred presence, but seems to update my status right away.
I cannot get setPresence to work because I don’t know how to find my sessionId, or the “application with ID”. If anyone knows, please let me know.
I misspoke, this works in Graph Explorer. How to translate that power automate flows is where I’m stuck.
Did you make any progress on this?
successfully working using “HTTP with Microsoft Entra ID (preauthorized)” method now!
if it helps anyone, i got 301 error repeatedly even after trying the 2 extra suggested base paths for US tenants. fix is simple – if you get 301 error, look at the OUTPUT code in your failed run, in my case i could see:
“`
{
“statusCode”: 301,
“headers”: {
“Location”: “https://apac.presence.teams.microsoft.com/v1/me/forceavailability?redirect=1”,
…
“`
whatever you have in that location section, copy that base path (eg. https://apac.presence.teams.microsoft.com ) and go to your Connections tab on the power automate home page, edit the connection you set up to use that new url, then it will work.
Hi both,
I’m in Belgium and I have the same issue since Sept 20th
Is anyone have a structural solution for this issue ? Not via Graph or Entra (who requires permissions….) Just sending a SharePoint HTTP request like previously (e.g. url: https://presence.teams.microsoft.com method: PUT URI: /v1/me/workLocation body: {“Location”: “1”}…)
Any help would be very appreciated 🙂
Thank you
The SharePoint http action no longer supports this endpoint. You would need to look at graph or entra.
Thank you but I think these options would require admin privileges, right?