3
votes

I read from here that getting a user's Teams chats that occurred outside the scope of a team or channel (1-to-1 chat conversation), you need to use this request

GET /users/id/messages

and Teams chat messages have "IM" as their subject.

My question now is whether it is possible to send a new message to this conversation via the Graph API and that the message will be displayed on the Teams application?

I tried to reply to this message via the graph API, but the reply message was sent to Outlook, not in the Microsoft Teams application.

2
I do not have sufficiente reputation to comment on above answer, so here goes : If you are testing with the Graph Explorer, just remember to use POST: I was going crazy trying to send a message, just to discover I was always sending GET requests :-pPhilippe Morange

2 Answers

5
votes

It is now possible to send messages to personal chat(1:1) or to group chat in Microsoft Teams using Microsoft Graph API. And yes, the messages will be displayed in the Teams application using Microsoft Graph API.

Please refer the "1:1 and group chat messages" section from the below microsoft documentation link:

chatMessage resource type

Also, below is the graph API to send a message to any conversation you want using Post HTTP method :

https://graph.microsoft.com/beta/users/{user-id}/chats/{chat-id}/messages

To fetch {user-id} and {chat-id}, please follow the below steps using Get HTTP method:

  1. Fetch the user id of a logged-in user or user id of other user using below graph API's:

    https://graph.microsoft.com/v1.0/me
    https://graph.microsoft.com/v1.0/users

  2. Fetch the conversation/chat id of a user:

    https://graph.microsoft.com/beta/me/chats
    https://graph.microsoft.com/beta/users/{id}/chats

As of now, there is no graph API to reply to a personal chat but we can reply to any team's channel message using Microsoft Graph API.

3
votes

The answer, for now, is no. The docs have stated

"In both the v1 and beta endpoints, the response of GET /users/id/messages includes the user's Microsoft Teams chats that occurred outside the scope of a team or channel. These chat messages have "IM" as their subject."

You may submit/vote an feature request in the UserVoice or just wait the update from the Product Team.