{"id":7006,"date":"2020-09-10T20:49:26","date_gmt":"2020-09-11T01:49:26","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=7006"},"modified":"2020-09-18T09:10:11","modified_gmt":"2020-09-18T14:10:11","slug":"exporting-a-microsoft-teams-chat","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=7006","title":{"rendered":"Exporting A Microsoft Teams Chat"},"content":{"rendered":"<div>There&#8217;s no export functionality in MS Teams chats and conversations. From Microsoft&#8217;s standpoint, this makes sense &#8212; customer retention. From the customer standpoint, however? There are times I really want to transfer a conversation elsewhere for some reason. You <em>can<\/em> copy\/paste individual text bubbles. If you only need to get one or two bubbles, manually copying the text is going to be quicker. And, for those <em>with<\/em> special access, there&#8217;s the Security &amp; Compliance discovery export stuff as well as an approach using the Graph API. But for the rest of us general users, there&#8217;s no easy way to export the bunch of little chat bubbles that comprise a MS Teams chat.\u00a0 There is, however, a not-too-hard way to do it in the Teams web client.<\/div>\n<p>I\u2019ll prefix these instructions with a disclaimer \u2013 your company may have document retention in Teams. When you export your chat content, you\u2019ll need to maintain appropriate retention policies yourself. In IT, we had a few information categories where retention was \u201cuseful life\u201d \u2013 we could retain system documentation as long as the system was used. If you\u2019re exporting a chat to keep something you are allowed to keep and then keep it outside of Teams \u2026 that\u2019s awesome. If you are trying to keep something the company\u2019s retention policy says should be removed \u2026 that\u2019s probably <em>not<\/em> awesome.<\/p>\n<p>Once you\u2019ve determined that the info you are exporting is OK <em>to<\/em> export and maintain elsewhere, here\u2019s how to export a Teams chat from within the Teams web client. Step 1, of course, is to lot into Teams at https:\/\/teams.microsoft.com and go to the chat you want to export. Scroll up to the top of the chat. If you have a <em>really<\/em> long chat, it may not be possible to export the entire thing using this approach. I might play around with it in the future, by most of my conversations are in Teams channels so I don&#8217;t <em>have<\/em> a chat that&#8217;s more than 30 or so messages.<\/p>\n<p>Once you are at the top of the chat, open the developer tools (ctrl-shift-i in Chrome). Clear the errors &#8212; they clutter up the screen.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"954\" height=\"180\" class=\"wp-image-7008\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/09\/word-image-1.png\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/09\/word-image-1.png 954w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/09\/word-image-1-300x57.png 300w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/09\/word-image-1-768x145.png 768w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/09\/word-image-1-750x142.png 750w\" sizes=\"auto, (max-width: 954px) 100vw, 954px\" \/><\/p>\n<p>Paste the following script into the console and hit enter:<\/p>\n<pre>var strRunningText = \"\";\r\nvar collectionMessageBubbles = document.querySelectorAll('.message-body-content, .message-datetime');\r\n\r\nfor (let objMessageBubble of collectionMessageBubbles) {\r\n     strRunningText = strRunningText + \"\\n\" + objMessageBubble.textContent;\r\n}\r\n\r\nconsole.log(strRunningText);<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"802\" height=\"249\" class=\"wp-image-7009\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/09\/word-image-2.png\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/09\/word-image-2.png 802w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/09\/word-image-2-300x93.png 300w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/09\/word-image-2-768x238.png 768w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/09\/word-image-2-800x249.png 800w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/09\/word-image-2-750x233.png 750w\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" \/><\/p>\n<p>If you have a long series of chat messages, you\u2019ll get <em>some<\/em> of the chat displayed and a button to copy the entire chat content to your clipboard.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"172\" class=\"wp-image-7010\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/09\/word-image-3.png\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/09\/word-image-3.png 720w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2020\/09\/word-image-3-300x72.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/p>\n<p>If you have a shorter series of chat messages, you\u2019ll have the text of the chat in the console window. You can highlight it and copy\/paste the text elsewhere.<\/p>\n<p>There\u2019s a little cleanup that can be done \u2013 the content of the message-datetime elements have a beginning and trailing newline character along with a bunch of whitespace. You can get a cleaner timestamp (but, if you embed code within your messages \u2026 which I do \u2026 the code sections have a lot of extraneous newlines):<\/p>\n<pre>var strRunningText = \"\";\r\nvar collectionMessageBubbles = document.querySelectorAll('.message-body-content, .message-datetime');\r\n\r\nfor (let objMessageBubble of collectionMessageBubbles) {\r\n     strRunningText = strRunningText + \"\\n\" + objMessageBubble.innerText;\r\n}\r\n\r\nconsole.log(strRunningText);<\/pre>\n<p>The same JavaScript works in the Teams channel conversations <em>except<\/em> the channel conversations tend to be longer &#8230; so you&#8217;re going to export some subset of the channel conversation around where you are in the web browser.<\/p>\n<p>* I realized, during a multi-person chat last week, that I don&#8217;t grab the name of the individual who posted the message to the chat. Grabbing the person&#8217;s name should just entail adding the identifier for the name element into the querySelectorAll list &#8230; but that&#8217;s not something I&#8217;ve had an opportunity to check yet.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There&#8217;s no export functionality in MS Teams chats and conversations. From Microsoft&#8217;s standpoint, this makes sense &#8212; customer retention. From the customer standpoint, however? There are times I really want to transfer a conversation elsewhere for some reason. You can copy\/paste individual text bubbles. If you only need to get one or two bubbles, manually &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[677],"tags":[856,691,729,666,686,265,705,665],"class_list":["post-7006","post","type-post","status-publish","format-standard","hentry","category-office-365","tag-javascript","tag-microsoft-office","tag-microsoft-office-365","tag-microsoft-teams","tag-ms-teams","tag-office-365","tag-office365","tag-teams"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/7006","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7006"}],"version-history":[{"count":5,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/7006\/revisions"}],"predecessor-version":[{"id":7041,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/7006\/revisions\/7041"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7006"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7006"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}