Home > Mobile >  MS Teams API without MS MS Graph
MS Teams API without MS MS Graph

Time:12-24

I am wondering to know. is there method to Create automatic chat on MS teams that triggered some event ?

I am assuming there is some API on MS teams, but I don't know where is it.

I got some article, for fulfill my requirement we can use MS graph. but before I go to buy MS Graph License.

is there any way to answers my requirement without MS Graph.

CodePudding user response:

In MS teams, there is an API called 'Create chat' to create one-on-one chat or group chat. One of the following permissions is required to call this API:

Delegated (work or school account): Chat.Create, Chat.ReadWrite

Create a one-on-one chat:

POST https://graph.microsoft.com/v1.0/chats
Content-Type: application/json

{
  "chatType": "oneOnOne",
  "members": [
    {
      "@odata.type": "#microsoft.graph.aadUserConversationMember",
      "roles": ["owner"],
      "[email protected]": "https://graph.microsoft.com/v1.0/users('8b081ef6-4792-4def-b2c9-c363a1bf41d5')"
    },
    {
      "@odata.type": "#microsoft.graph.aadUserConversationMember",
      "roles": ["owner"],
      "[email protected]": "https://graph.microsoft.com/v1.0/users('82af01c5-f7cc-4a2e-a728-3a5df21afd9d')"
    }
  ]
}

Create a group chat:

POST https://graph.microsoft.com/v1.0/chats
Content-Type: application/json

{
  "chatType": "group",
  "topic": "Group chat title",
  "members": [
    {
      "@odata.type": "#microsoft.graph.aadUserConversationMember",
      "roles": ["owner"],
      "[email protected]": "https://graph.microsoft.com/v1.0/users('8c0a1a67-50ce-4114-bb6c-da9c5dbcf6ca')"
    },
    {
      "@odata.type": "#microsoft.graph.aadUserConversationMember",
      "roles": ["owner"],
      "[email protected]": "https://graph.microsoft.com/v1.0/users('82fe7758-5bb3-4f0d-a43f-e555fd399c6f')"
    },
    {
      "@odata.type": "#microsoft.graph.aadUserConversationMember",
      "roles": ["owner"],
      "[email protected]": "https://graph.microsoft.com/v1.0/users('3626a173-f2bc-4883-bcf7-01514c3bfb82')"
    }
  ]
}

Refer this doc for more details: https://docs.microsoft.com/en-us/graph/api/chat-post?view=graph-rest-1.0&tabs=http

  • Related