npm install- Go to https://my.telegram.org/apps
- Log in with your phone number
- Create a new application
- Copy your
api_idandapi_hash
Create a .env file:
API_ID=your_api_id_here
API_HASH=your_api_hash_here
SESSION_NAME=session
POST_INTERVAL_MS=60000Create config/message.txt file with your message:
mkdir -p config
echo "Hello! This is an automated message." > config/message.txtNote: The config/message.txt file takes priority over the MESSAGE environment variable.
npm run devnpm run build
npm startOn first run, the bot will:
- Ask for your phone number (with country code, e.g., +1234567890)
- Send you a verification code via Telegram
- Ask you to enter the code
- Save your session to
config/{SESSION_NAME}.sessionfor future runs
After authentication, the session is saved in the config/ directory and you won't need to authenticate again.
- The bot fetches all groups you're a member of
- For each group, it posts your message immediately
- Then it schedules periodic posts based on
POST_INTERVAL_MS - Before each new post, it deletes the previous message
- All actions are logged to the console in real-time
Press Ctrl+C to gracefully stop the bot.
- "No groups found": Make sure you're a member of at least one group
- "Failed to post": Check that you have permission to send messages in the groups
- Authentication errors: Make sure your API_ID and API_HASH are correct
- Session issues: Delete the
.sessionfile and re-authenticate