1
votes

we are working on MS Bot Framework bot. We are integrating with directline and MS teams. In certain cases we need to download conversation history. Within directline we are using standard DL endpoints to retrieve the conversation. However these are not available for teams channel. Therefore we are trying to get chat messages using Graph API by using

/me/chats/{id}/messages

And here's our issue - to get the chat ID we are trying to iterate through chats returned by

/me/chats

And then look up conversation members by

/me/chats/{id}/members

However chat with Bot contains only user and not the bot so it appears it is a single member chat. As workaround we always sort chats by last updated timestamp descending and assuming first single member conversation is the one we are looking for however this is tricky and unreliable and also very slow some times. Is there some better way to get conversation history from MS teams channel?

1

1 Answers

2
votes

Using Graph API, you can access information related to channels in Microsoft Teams. You can refer to list channel messages which retrieves the list of messages (without the replies) in a channel of a team. If you want to get the replies for the message, then you need to call list message replies or get message reply API.

GET /teams/{id}/channels/{id}/messages

One more way is to subscribe to the channel using change notifications API which makes you get all the messages of the channel to the notification endpoint.