I ran some quick tests and you can achieve it by using Graph API. It's possible that there is an easier strategy - let's see what the other users say.
If you are not very familiar with Power Automate, the following description may sound a little confusing. Feel free to ask for further clarification - I'm short on time right now, so cannot provide you with some screenshots of the process.
You could work with a design like this:
- Trigger (manual, recurrent, or whatever makes more sense for your use case)
- Initialize variable - Create an array variable to store all the messages from the group chat.
- List chats - Set Chat Types to "Meeting", so you retrieve all meetings from your MS Teams. We need this step to get the id of the Teams group chat.
- Filter array - Filter the List chats body/value by "topic" property, so you can isolate the record related to your group chat. You might have problems with this approach if there are any duplicated chat topics (two meetings with the exact same name).
- Send a Microsoft Graph HTTP request (Teams connector) - Send a request to the /me/chats/{chat-id}/messages endpoint. To define the chat-id, use an expression to reference the id property of the first record of the Filter array (something like body('Filter_array')[0]['id']). This step will retrieve all events that happened in the chat, and not only messages. AFAIK, it is not possible to apply any query filters to the endpoint.
- Set variable Use an expression to assign the body/value from the Graph request to the existing variable.
- Do until - Add a do until loop, since the graph request will retrieve only the first 20 results. Since the endpoint supports pagination, you can keep sending requests for the next pages, until you get all results. Set the condition of the Do until to odata.nextLink equals to null. Inside the loop, include the Send a Microsoft Graph HTTP request (Teams connector) and an Append to array variable action, so you can add the body/value results to the existing array variable.
- Filter array - Out of the loop, add a Filter array and set the messageType property equals to mesasge. It will keep only the actual messages, filtering out the meetings and other events that happened in the group chat.
- Select - Now you can use a Select action to format the outputs of your .csv (I believe this is the easiest format to export). Map the Filter array body and add fields only for the relevant properties (e.g., author, date, content), using expressions to match the respective properties from the results retrieved in the HTTP request (e.g., item()['from']['user']['displayName'] for author, or item()['body']['content'] for the message content).
- Create CSV table - Use the output of the Select, so you can convert the JSON object to a CSV format.
- Create file (or other action that makes more sense) - Finally, you can use a Create file action to save the CSV wherever you want. If you prefer to, you can also send the CSV via email, or take any other action to store this otuputs.
Let me know if it works for you or if you need any additional help!
✅
If this solved your issue, please mark it as Accepted Answer.
👍
If it helped, feel free to give it a like!
🌐 Explore more Power Platform content on my
Website or on my ▶️
YouTube
💼 Find me on
LinkedIn