Accessing and creating Teams Chats via Graph API

守給你的承諾、 提交于 2021-01-28 14:19:38

问题


I'm going over the Microsoft Teams section of the Graph API and trying to find out how to do two things:

  1. Create a new chat, giving it a topic that correlates to an entity in our app (essentially creating a chat around an entity), invite specific users into it, and send messages to the chat.

  2. Access the currently logged-in user's private chats, filtered by their topic, and show their contents inside our app.

For #2, it looks like it should be possible using beta endpoint of the Graph API, but I get 403 Forbidden errors both in the Graph Explorer when trying to access https://graph.microsoft.com/beta/me/chats, and in my own app, after enabling the Chat.Read permissons for it.

For #1, it looks like the API doesn't officially support creating new chats at all.

Is there any approach we can use to create and manage chats? Is there an alternative, perhaps not MicrosoftGraph-based API?


回答1:


as you mention, the ms graph doesn't yet support initiating group chat. You would use the MS Bot Framework for this: https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/bots/bot-conversations/bots-conv-proactive

I see the docs on these Chat api do exist, but they are not present in the Graph Explorer. I tired testing them in the OfficeApiEditor tool with a v2.0 App Registration and Delegated permissions (Chat.Read) and i get this:

Failure - Status Code 500
"code": "InternalServerError",
"message": "Error while processing response.",

so maybe it will take some time before they are really available in beta.




回答2:


In MS teams, there is a api called ChatMessage to post a message to a chat(only if the chat already exist or started). But, there is no api to create/start a new chat. I have raised a feature request. Do vote for this to suggest this idea to Microsoft. https://microsoftteams.uservoice.com/forums/913786-microsoft-teams-free/suggestions/38776681-it-would-be-awesome-l-if-there-is-an-api-functiona



来源:https://stackoverflow.com/questions/56371462/accessing-and-creating-teams-chats-via-graph-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!