Skip to content

btecu/teams-chat-backup

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microsoft Teams Chat Backup

This project retrieves a full chat history (messages and uploaded files) and renders it as an HTML.

Requirements

Node.js 12 (or higher). Tested on macOS and Windows, but will most likely run on Linux too.

Setup

Like any other JS project, clone this repo and run the following command to install dependencies:

npm install

Run

To backup a chat, run:

npm run start

This will ask several questions:

Chat ID - this is the identifier of the conversation. To find it:

  1. Go to https://teams.microsoft.com
  2. Go to the chat you'd like to export.
  3. Copy chat ID from URL. It looks like 19:<uuid of one user>-<uuid of other user>@unq.gbl.spaces or 19:<some uuid>@thread.skype
  4. Add it to the Conversations array in index.js as a chatId and set the target property with the name of the conversation / folder

Auth token (JWT) - this is needed for calling Microsoft Graph APIs.

  1. Go to https://developer.microsoft.com/en-us/graph/graph-explorer. At the left side, under Authentication, click "Sign In with Microsoft"
  2. After having logged in, on the left side (where you clicked for login), click "modify permissions". Enable Chat.Read and re-login (like it states).
  3. The URL contains the token (#access_token=<long token goes here>). Copy this value or make any random call in the sandbox and copy the Authorization from the "Access token" tab of the Graph Explorer page.

Target directory name - is the name to use for the export (will be created in the out directory in this project).

Output

An exported chat contains:

  • messages-#####.json: these are the pages of messages. Page 0000 is the most recent one (pages and messages within are in reverse order).
  • image-#####: these are images uploaded in the chat
  • index.html: is the full history rendered into a simple HTML template, referring to the downloaded images. This is the file you want for viewing.

To Do

  • Make an easier way of obtaining a token.
  • Add support for bot messages (for example a form).

About

Microsoft Teams chat backup

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 95.9%
  • CSS 4.1%