Pages Menu
TwitterRssFacebook

Posted by on Dec 19, 2022 in Development, Microsoft Teams

Microsoft Teams Developers can now set presence status messages via Microsoft Graph API

Microsoft Teams Developers can now set presence status messages via Microsoft Graph API

Developers have been able to change user presence programmatically for a while now, but this has been limited to just the presence availability state. In the Teams UI there is an additional place for status messages which allows a user to provide more details, and which is given prominence when communicating with that user:

Now though, there is a new API call, just for updating the status message. It’s only available in the beta endpoint and is called presence: setStatusMessage:

It’s a little confusing that this API call is separate from the setPresence call, but we’ll take it!

Note that (for now anyway) this call only accepts delegated user permissions: meaning it’s not possible to write a headless back-end application which updates 1 or more user status messages. The user will need to be present and logged in for this to work. The permission scope is the same as the one used to update presence: Presence.ReadWrite.

This might be useful for integrating into applications where the user will be dedicating a set amount of time on a certain task and doesn’t want to be disturbed – the application could automatically update the user’s presence to Busy and provide a status message explaining why the user is busy.

As well as the status message, it’s also possible to provide an expiry time after which the status message is removed. This maps to the existing functionality in the Teams UI. Note the slightly odd way of specifying the date/time and timezone separately:

It can take a little while for the status to update in the the Microsoft Teams client, but you should eventually see it reflected in the user’s status:

You can also use /me/presence/setStatusMessage

This isn’t in the documentation page anywhere, but you can also use the endpoint /me/presence/setStatusMessage to set the status message. This is actually more natural for many developers, because the permission set means that this only works against the /me user anyway!

Written by Tom Morgan

Tom is a Microsoft Teams Platform developer and Microsoft MVP who has been blogging for over a decade. Find out more.
Buy the book: Building and Developing Apps & Bots for Microsoft Teams. Now available to purchase online with free updates.

Post a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.