A simple, clean, and modern UI for composing and sending posts to Telegram groups using your bot, with support for authorized users and message forwarding.
- Compose text messages with formatting
- Upload and preview images and videos
- Manage multiple bots
- Edit bot credentials
- Configure destination group and topic IDs
- Save all settings to MongoDB
- Manage authorized users for each bot
- Forward messages from authorized users to groups
- Direct message interface for sending as authorized users
- Automatic Twitter/X link conversion to fxtwitter.com for better previews
- PM2 integration for running as a service
- Node.js (v14 or higher)
- MongoDB (local or Atlas)
-
Clone this repository:
git clone <repository-url> cd telegram-post-composer -
Install server dependencies:
cd server npm install -
Configure your environment:
- Copy
server/.env.sampletoserver/.env - Edit the
.envfile to set your MongoDB connection string and Telegram credentials:MONGODB_URI=mongodb://localhost:27017/TgServices PORT=3001 TELEGRAM_BOT_TOKEN=your-bot-token-here CHAT_ID=your-chat-id-here TOPIC_ID=your-topic-id-here - If you're using MongoDB Atlas, replace the connection string with your Atlas URI
- Copy
Tg-creds.sample.txttoTg-creds.txtand add your Telegram credentials
- Copy
-
Start the server:
npm startOr use PM2 for production:
./start-pm2.sh -
Open the application:
- Open
telegram-composer.htmlin your browser - Or navigate to http://localhost:3001 if using the server
- Open
-
Default Bot: The application comes with a default bot using your credentials
- Click "Edit" to modify the default bot's name and token
- Changes are saved to MongoDB
-
Adding Bots: Click "Add New Bot" to add additional bots
- Enter a name and token for the new bot
- The bot will be saved to MongoDB
-
Bot Status: Toggle bots between active and inactive states
- Inactive bots cannot be selected for sending messages
- Write your message in the text area
- Add media (optional):
- Click "Add Media" to upload an image or video
- Preview your media in the composer and preview panels
- Remove media by clicking the "×" button
- Click "Edit" in the Destination section
- Enter your Group ID and Topic ID
- Click "Save Changes" to update the destination
Click "Send Post" to send your message to the selected Telegram group/topic using the selected bot.
The application uses MongoDB with two collections:
-
Bots:
name: Bot nametoken: Bot tokenisActive: Whether the bot is activeisDefault: Whether this is the default bot
-
Destinations:
groupId: Telegram group/chat IDtopicId: Telegram topic ID (optional)name: Destination nameisDefault: Whether this is the default destination
This application uses environment variables for sensitive information. Make sure to:
- Never commit your
.envfile orTg-creds.txtto Git (they are included in .gitignore) - Keep your Telegram bot token secure
- Use the provided sample files as templates
- Revoke and regenerate your bot token if you suspect it has been compromised
- If the MongoDB connection fails, the application will fall back to local storage
- Check the browser console for error messages
- Ensure MongoDB is running and accessible
- Verify that the server is running on port 3001 (or update the API_URL in the HTML file)
- README-PM2.md: Instructions for running with PM2
- README-FORWARDING.md: Details about the message forwarding feature
- AUTHORIZED-USERS-GUIDE.md: Guide for managing authorized users
The application supports two methods of message forwarding:
- Web Interface: Use the direct message interface at http://localhost:3001/direct-message to send messages as authorized users
- Direct to Bot: Authorized users can send messages directly to the bot, which will be forwarded to the configured group/topic
To use the direct message feature:
- Add users to the authorized users list for a bot
- Have them send messages to your bot on Telegram
- The messages will be automatically forwarded to the configured group/topic
- Any Twitter/X links in the messages will be automatically converted to fxtwitter.com for better previews