Search code examples
microsoft-graph-apimicrosoft-teamsmicrosoft-graph-teams

How to send messages as replies in 1:1 chat using graph API?


I was trying to send messages as replies in teams using graph API's. In teams channels I was able to send messages using below endpoint.

https://graph.microsoft.com/v1.0/teams/{group_id}/channels/{channel_id}/messages/{message_id}/replies

But in case of 1:1 chats I used below endpoint, and it didn't work.

https://graph.microsoft.com/v1.0/chats/{user_id}/messages/{message_id}/replies

response got is given below:

{'error': {'code': 'UnknownError', 'message': '', 'innerError': {'date': '2023-07-12T14:44:27', 'request-id': '4420e38b-29f3-452c-8d2b-d1cb541f6a87', 'client-request-id': '4420e38b-29f3-452c-8d2b-d1cb541f6a87'}}}

I am using delegated access token for these API's and required permissions are added. I am able to send messages in chats, but my requirement is to add messages as replies to previous messages using the message id.

Is there any way to do this using graph API?


Solution

  • Teams doesn't actually support "threading" in 1-1 chat, which would essentially be "replying" to a specific message. When you click the "reply" button in a personal chat, all it's doing is creating a kind of "quoted" text in the main chat. That's why you can't access the "/replies" endpoint, it doesn't exist. It -does- exist in Channels though (hence threaded conversations), which is why that endpoint is working fine for you.