the above URL, conversation id would you pass the id, you will be able to generate the complete conversation history to a CSV. You can easily get the Chat Id of any conversation by opening the Teams Conversation in a browser # Method which retrieves a particular Teams Conversation and Exports to CSV function getMessagesFromConversation #Chat Conversations which needs to be retrieved $ChatId = getMessagesFromConversation -AccessToken $AccessToken -ChatID $ChatId
Download microsoft teams chat history how to#
If you already have an AAD App which you have created before, you can refer the documentation where it has explained how to configure the needed settings.įor logging in to CLI for Microsoft 365, we use the following command Since we have already created an AAD App in section Add AAD App using CLI for Microsoft 365, we will just be logging into Microsoft 365 using CLI for M365. But CLI for Microsoft 365 provides a way where you can use your own Azure AD identity for leveraging the commands which CLI for Microsoft 365 uses. But while writing this blog, App does not have the API permission ( Chat.Read, Chat.ReadWrite) assigned. Login to Azure AD using CLI for Microsoft 365īy default CLI for Microsoft 365 uses an App named PnP Management Shell for connecting to Microsoft 365. Once we have the App created in place, in the next step, we will be connecting to CLI for Microsoft 365 using the newly created app. $AddedApp = ( m365 aad app add -manifest $AppManifestJSONFile -redirectUris "" -platform publicClient -apisDelegated ", " -output > json ) | ConvertFrom-Json Manifest file which I have used is given here.
Download microsoft teams chat history code#
If you want to understand various ways to create Azure AD App, you can refer brilliant blog post by Waldek where he has explained with various use cases.įollowing is the code snippet which creates a new AAD App. This approach provides a way to create an app using a Manifest file and also providing the API permission while creating the app. We will be using the command m365 aad app add for the same. Login to Azure AD using CLI for Microsoft 365.ĬLI for Microsoft 365 provides an easy way to create an Azure AD App with single command. If you already have an App with the needed API permission assigned, you can ignore the below step and can head directly to 2. That being the case, here will be creating an AAD App and will be assigning the permission. Since we will be using Graph API for Listing the messages in a chat, we need the Delegated Permissions Chat.Read, Chat.ReadWrite, for the same.
If you are interested only in the complete script, you can head straight to Complete Scripts section 1. Use the access token and call the Graph API which to export the conversation Get the Access Token for Graph API using CLI for Microsoft 365Ĥ. Login to Azure AD using CLI for Microsoft 365ģ. Add AAD App using CLI for Microsoft 365Ģ. Export Microsoft Teams Chat approach in a nutshellġ. But you can easily extend it to any other shells based on your convenience. Do keep an eye on CLI for Microsoft 365 release notes.īut till that time, you can refer this blog post where we use Combination of CLI for Microsoft 365 and Graph API calls for getting the result. This blog post explains how you do that using a simple script built using PowerShell in combination with CLI for Microsoft 365.ĭuring the time of writing this blog, there are no commands available which you can leverage directly.īut there is a new command which is getting brewed in the backyard of CLI for Microsoft 365 which will give you the feature directly. If we are able to get a way where we can export the raw conversations into an CSV and then you can slice, dice, or format the details as per your requirement.
A typical example is our PnP Calls where moderator needs to get the questions asked by the attendees easily. Or if you want to document a QnA session after a Technical event. Imagine a case where you want to export a chat conversation which you had with a colleague. For conversation or messages in a Teams team, there are commands available in CLI for Microsoft 365 through which you can export the conversations easily. Have you been looking out for a scenario where you want to export Microsoft Teams Chat conversation, could be a 1 on 1 chat, Group Chat or a meeting conversation to a CSV format.