Skip to content

Emmynem/telegram-session-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Telegram StringSession Generator (Node.js)

This script allows you to securely authenticate a Telegram user account using the GramJS MTProto client and generate a StringSession. This session string can be stored in a database for use in automated Telegram operations like group management, messaging, etc.


πŸ“¦ Requirements

  • Node.js (v14 or higher recommended)
  • Telegram App credentials (from my.telegram.org)

πŸ”§ Setup

1. Clone the Project

git clone https://github.com/Emmynem/telegram-session-generator
cd telegram-session-generator

2. Install Dependencies

npm install

3. Create a .env File

Create a .env file in the root of the project with the following:

API_ID=your_telegram_api_id
API_HASH=your_telegram_api_hash

Get your API_ID and API_HASH from https://my.telegram.org.


πŸš€ Usage

Run the index script to generate your Telegram StringSession:

node index.js

You will be prompted to enter:

  • πŸ“± Your phone number (with country code)
  • πŸ” Your 2FA password (if enabled)
  • πŸ”‘ The Telegram code you receive

After successful login, a StringSession will be printed to your terminal:

πŸ‘‰ Save this stringSession securely in your database:
1A0B...<your-session-string>

πŸ’Ύ Store the Session

Save this session string securely in your database. It can be used to:

  • Avoid logging in again
  • Authenticate Telegram actions in other scripts (sending messages, inviting users, etc.)

Example usage in another script:

const stringSession = new StringSession("your_saved_session_string");

⚠️ Security Notice

  • Treat the session string like a password.
  • Do not share or commit it to version control.
  • Store it securely in an encrypted database field or secret manager.

πŸ“„ License

MIT

About

Telegram StringSession Generator (Node.js).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published