{"id":43121615,"url":"https://github.com/codeforkjeff/teams-chats-export","last_synced_at":"2026-01-31T19:37:24.576Z","repository":{"id":234271077,"uuid":"788551173","full_name":"codeforkjeff/teams-chats-export","owner":"codeforkjeff","description":"export chats from Microsoft Teams into html files","archived":false,"fork":false,"pushed_at":"2024-09-13T16:22:21.000Z","size":69,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-14T10:06:43.569Z","etag":null,"topics":["backup","chats","export","microsoft-teams","microsoft365","msgraph","msteams"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeforkjeff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-18T16:28:42.000Z","updated_at":"2024-09-13T16:22:24.000Z","dependencies_parsed_at":"2024-05-01T18:25:26.326Z","dependency_job_id":null,"html_url":"https://github.com/codeforkjeff/teams-chats-export","commit_stats":null,"previous_names":["codeforkjeff/teams-chats-export"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codeforkjeff/teams-chats-export","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeforkjeff%2Fteams-chats-export","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeforkjeff%2Fteams-chats-export/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeforkjeff%2Fteams-chats-export/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeforkjeff%2Fteams-chats-export/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeforkjeff","download_url":"https://codeload.github.com/codeforkjeff/teams-chats-export/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeforkjeff%2Fteams-chats-export/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28951705,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T18:30:42.805Z","status":"ssl_error","status_checked_at":"2026-01-31T18:30:19.593Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup","chats","export","microsoft-teams","microsoft365","msgraph","msteams"],"created_at":"2026-01-31T19:37:24.515Z","updated_at":"2026-01-31T19:37:24.570Z","avatar_url":"https://github.com/codeforkjeff.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# teams-chats-export\n\nScript to export your Microsoft Teams [chats](https://learn.microsoft.com/en-us/graph/api/resources/chat?view=graph-rest-1.0)\nand view them as .html files. Chats are conversations separate from those on Teams channels. These include one-on-one chats,\ngroup chats, and meeting chats.\n\n## Design Goals\n\nUnlike similar export tools, this does NOT require using Windows or PowerShell. The only requirement is Python.\n\nOriginally you did not need to register an application with the Microsoft Identity Platform or Microsoft Entra ID,\nbut as of Sept 9th, 2024, [that is no longer the case](https://pnp.github.io/blog/post/changes-pnp-management-shell-registration/).\n\nThis was created specifically in response to a new retention policy for Teams chats\nimplemented at my workplace.\n\n## Instructions\n\n\n### Create an Entra ID application if needed\n\nYou'll need either an existing Entra ID application with permissions to access Teams,\nor you'll need to create a new one.\n\nIf you have an existing application, find its application/client ID.\n\nIf you need to create one, the steps are [here](https://pnp.github.io/powershell/articles/registerapplication.html#manually-create-an-app-registration-for-interactive-login).\nIn a nutshell:\n\n- Log into https://entra.microsoft.com/\n- Navigate to Applications -\u003e App Registrations\n- Click \"New registration\" and give it a name like \"Teams API\"\n- Navigate to Authentication for the new app\n- Click \"Add a platform\" and select \"Mobile and desktop applications\"\n- Enter the following custom redirect URI: http://localhost:8400\n- Save your changes\n\nYou don't need to configure specific API permissions. The default \"User.Read\" delegated\npermission will give users access to their own Teams data.\n\nCopy your new application's \"Application (client) ID\" from the Overview screen. It should look\nsomething like \"31359c7f-bd7e-475c-86db-fdb8c937548e\" (that's the ID for the old built-in\nPnP Management Shell Entra App that Microsoft has disabled, it won't work).\n\n### Install the script\n\nDo this once:\n\n```sh\n# set up and activate a virtual environment\npython -m venv teams-chats-export-env\n. ./teams-chats-export-env/bin/activate\n\n# install dependencies\npip install -r requirements.txt\n```\n\n### Run the script\n\nTo archive your chats:\n\n```sh\n# activate the virtual env every time you want to use it\n. ./teams-chats-export-env/bin/activate\n\n# run two steps to download and generate html files in the './archive' directory\n# to use another dir, set --output-dir=/some/other/dir\n\n# step one: download\n# replace value for CLIENT_ID with your own ID\nCLIENT_ID=\"31359c7f-bd7e-475c-86db-fdb8c937548e\" python teams_chats_export.py download\n\n# step two: generate html files\npython teams_chats_export.py generate_html\n```\n\nThe download step will open a browser window for you to authenticate.\n\nFiles will be written to directories named `data` and `html` within the output directory.\nThe `html` directory includes an `index.html` containing a listing of the chats.\n\nYou can run the download step on your archive directory periodically to update the data.\nPreviously downloaded data, including anything deleted on Teams since the last time you\nran the script, will be retained in the directory. (If you want to be really safe, consider\nmaking a backup copy of the archive directory from time to time.)\n\nOnly \"new\" messages are downloaded, but this logic may not catch certain edge cases.\nIf you're missing messages or you don't see edits, or you just want to be absolutely sure\nyou're downloading everything, run `python teams_chats_export.py download --force`\nto re-process all the available messages on Teams.\n\nIf you want to customize the html outputs, edit the files in `templates/` to your\nliking and re-run the generate_html step above.\n\n## Limitations\n\n- Doesn't render reactions in the .html\n\n- Not all attachment types are handled properly. (Meta)data for unhandled attachments\n  is written directly to the .html file with the string prefix \"Attachment (raw data):\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeforkjeff%2Fteams-chats-export","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeforkjeff%2Fteams-chats-export","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeforkjeff%2Fteams-chats-export/lists"}