Pages Menu
TwitterRssFacebook

Posted by on Nov 21, 2021 in Development, Microsoft Teams | 0 comments

You can now hide and unhide Microsoft Teams chats via Graph API calls

You can now hide and unhide Microsoft Teams chats via Graph API calls

Two new API calls have quietly been added to the Microsoft Graph in the past few days, giving developers the ability to hide (and then un-hide) user chats.

Applications will need Chat.ReadWrite permission (Delegated permission only, no Application permission at this time) and if they have the Chat ID can POST the following to hide a chat:

POST /chats/{chatsId}/hideForUser

What’s interesting is that it’s also required to send a JSON payload in the body, containing the tenantID and also the user identity of the user the application want to hide the chat from. Because the only supported permission is delegated, this would seem to be unnecessary, and in fact, the documentation even says this: In delegated mode, users can only hide a chat for themselves.

My guess is that Application support is coming soon, and this is then where this information comes in handy.

Here’s an example payload body for the above call:

POST https://graph.microsoft.com/beta/chats/19:7d.../hideForUser
Content-Type: application/json

{
  "user": {
    "id" : "11e2d645-63db-4c8c-9b8f-5f7023d929b5"
  },
  "tenantId": "d78d296e-5dc9-443a-8091-cecc3bb5b401"
}

There is a corresponding unhide command as well, with all the same permissions and body:

POST /chats/{chatsId}/unhideForUser

It’s worth noting as well that already this will hide the chat for the user, if a Send Message command happens on the chat, this will un-hide it.

Ref:
chat: hideForUser
chat: unhideForUser

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.
Tom is currently writing a book: Building and Developing Apps & Bots for Microsoft Teams. Register your interest today and be the first to know when it's ready to read.

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.