A TypeScript-based tool using GramJS to export Telegram chats from a specific folder.
- Selective Export: Export all chats from a specific Telegram folder.
- Structured Output: Messages are saved in
.txt
files, with separate files for each conversation.
- Node.js: Install Node.js if not already available on your system. Download Node.js
- Telegram API Credentials: Obtain your API ID and API Hash from Telegram:
- Visit my.telegram.org.
- Log in with your Telegram account.
- Navigate to API Development Tools.
- Create a new application (name it anything you like).
- Save the API ID and API Hash securely.
Clone the repository to your local machine:
git clone https://github.com/robbiekruszynski/TG_Folder_Export.git
cd tg_folder_pull
- Install Dependencies Install the required packages:
npm install
npm i dotenv
- Configure Environment Variables Create a .env file in the project's root directory:
touch .env
Add the following keys to your .env file:
API_ID=your_api_id_here
API_HASH=your_api_hash_here
SESSION_STRING=your_session_string_here
HUGGINGFACE_API_KEY=your_huggingface_api_key_here
EXPORT_DIR=./hidden_exports
SUMMARY_DIR=./hidden_summary
Replace your_api_id_here
and your_api_hash_here
with the credentials obtained from my.telegram.org. You will generate the SESSION_STRING
in the next step.
- Generate Session String Authenticate and generate the session string:
npx ts-node generateSessionString.ts
Follow the on-screen prompts to log in. Once complete, add the session string to your .env file.
- Run the Export Script To export chats:
npx ts-node src/exportChats.ts
Follow the on-screen instructions to select a folder, then enter yes
, and the hidden exports
folder will populate with TXT files for each conversation within the folder.
Working on adding a LLM to summarize the conversations after they have been exported to the hidden exports
folder in a hidden summary
folder.
To generate a summary of the conversations:
npx ts-node src/summarizeChats.ts
Contributions Welcome: Feel free to submit issues or pull requests to improve the project.