{"id":21827882,"url":"https://github.com/dev0x13/telegram-chat-summarizer","last_synced_at":"2025-04-14T05:43:08.418Z","repository":{"id":230117941,"uuid":"763113602","full_name":"dev0x13/telegram-chat-summarizer","owner":"dev0x13","description":"Telegram app which automates manual scanning through tons of Telegram messages looking for valuable information","archived":false,"fork":false,"pushed_at":"2025-01-06T15:50:50.000Z","size":35,"stargazers_count":55,"open_issues_count":0,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T19:41:27.973Z","etag":null,"topics":["chatgpt","gpt","llm","summarization","telegram","telegram-bot"],"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/dev0x13.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-02-25T15:43:13.000Z","updated_at":"2025-03-27T05:55:11.000Z","dependencies_parsed_at":"2024-06-18T18:05:30.813Z","dependency_job_id":"0ed1fa0a-ddd7-4845-9cdc-03a0c3f7204b","html_url":"https://github.com/dev0x13/telegram-chat-summarizer","commit_stats":null,"previous_names":["dev0x13/telegram-chat-summarizer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev0x13%2Ftelegram-chat-summarizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev0x13%2Ftelegram-chat-summarizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev0x13%2Ftelegram-chat-summarizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev0x13%2Ftelegram-chat-summarizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dev0x13","download_url":"https://codeload.github.com/dev0x13/telegram-chat-summarizer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248830420,"owners_count":21168272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["chatgpt","gpt","llm","summarization","telegram","telegram-bot"],"created_at":"2024-11-27T18:14:33.168Z","updated_at":"2025-04-14T05:43:08.399Z","avatar_url":"https://github.com/dev0x13.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Telegram Chat Summarizer App\n\n**Are you sick of skimming through tons of Telegram messages daily looking for the valuable info? The salvation is here!**\n\nThis repository hosts an implementation of a Telegram application which monitors and summarizes group chats. Initially\ncreated for personal usage, it's intended for people who need to gather information from one or several live massive\nTelegram group chats which generate way too many messages to be reviewed manually.\n\nBased on the given configurations it:\n\n1. Monitors a set of given Telegram group chats using [Telegram API](https://core.telegram.org/#telegram-api).\n2. Summarizes the monitored chats over the defined lookback period (i.e. if you set the lookback period to 12 hours,\n   you'll be receiving summaries for the last 12 hours twice a day). **Only text message are analyzed as of now.**\n3. Sends the summaries to a given set of Telegram users using the [Bot API](https://core.telegram.org/#bot-api).\n4. For each sent summary the app preserves the summarization context until the next summarization so that the user can\n   ask clarifying questions on the summary.\n\n## Installation\n\n1. Obtain `api_id` and `api_hash` values for the Telegram API\n   using [this](https://core.telegram.org/api/obtaining_api_id#obtaining-api-id) guide.\n2. Create a Telegram bot and obtain its token\n   using [this](https://core.telegram.org/bots/tutorial#obtain-your-bot-token) guide.\n3. Obtain the OpenAI API key from [here](https://platform.openai.com/api-keys). For now the app has OpenAI backend\n   hard-coded (`gpt-4-turbo-preview` model), but it's pretty easy to replace it with the backend of your choice as it's\n   used via the [LangChain library](https://github.com/langchain-ai/langchain) calls.\n4. Write a prompt for the chat summarization. Use the one in the `examples/` folder as a reference.\n5. Define the configuration and save it to the `config.json` file:\n\n```json\n{\n  \"telegram_api_id\": \u003capi_id\u003e,\n  \"telegram_api_hash\": \"\u003capi_hash\u003e\",\n  \"openai_api_key\": \"\u003ckey\u003e\",\n  \"telegram_bot_auth_token\": \"\u003ctoken\u003e\",\n  \"chats_to_summarize\": [\n    {\n      \"id\": \"\u003cgroup chat ID or name\u003e\",\n      \"lookback_period_seconds\": 86400,\n      \"summarization_prompt_path\": \"prompts/example_summarization_prompt.txt\"\n    }\n  ],\n  \"telegram_summary_receivers\": [\n    \"\u003cTelegram username\u003e\"\n  ]\n}\n```\n\n5. Install Python requirements defined in the requirements.txt file or build the Docker image:\n\n```shell\npython3 -m pip install -r requirements.txt\n```\n\nor\n\n```shell\ndocker build -t tcsa:latest .\n```\n\n6. Run the app:\n\n```shell\npython3 app.py config.json\n```\n\nor\n\n```shell\ndocker run -it tcsa:latest\n```\n\nAt the first run the app will ask you to log in to the used Telegram account, like this:\n\n```shell\nuser@pc:~/telegram-chat-summarizer $ python3 app.py config.json\n2024-03-27 23:03:11,618 - INFO - Started!\nPlease enter your phone (or bot token): \u003cphone number\u003e\nPlease enter the code you received: \u003cOTP\u003e\nPlease enter your password:\n```\n\nThen the session will be stored on the disk, and the subsequent runs won't require authentication.\n\n## Usage\n\nOnce the app is up and running, each summary subscriber needs to send the `/verify` message to the bot so that it can\nregister the user.\n\nThe bot can switch conversation context by being provided with the command `/\u003csummarized chat name\u003e` (the chat name can\nbe any of the ones defined in the config). This mechanism is used if you have more than one chat being summarized: by\ngiving the corresponding command you can switch the LLM context to a different chat and discuss that chat's summary.\n\n## Implementation details and limitations\n\nThe implementation is very simplistic, and there is definitely a room for improvement. Some immediate nice-to-haves (PRs\nare\nwelcome!):\n\n1. Disk storage persistence for user verification and chat contexts.\n2. Getting rid of the summary subscription mechanism in favor of something less inconvenient.\n3. Basic app management (chats to summarize, summary subscribers etc.) through the bot as an alternative to the config\n   file.\n4. Supporting messages other than text ones: voice messages, images, videos.\n\nThere is a [step-by-step guide on Habr (RU)](https://habr.com/ru/articles/804111/) written after this implementation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev0x13%2Ftelegram-chat-summarizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdev0x13%2Ftelegram-chat-summarizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev0x13%2Ftelegram-chat-summarizer/lists"}