This is a simple Telegram bot built with Node.js that forwards all its messages to a specific group, ensuring the privacy of your users.
The bot can be hosted on Netlify and is free to use forever in this case. To set up the bot, you only need to configure two environment variables:
BOT_TOKEN
andGROUP_ID
.
Before setting up the Telegram Anonymous Forwarding Bot, make sure you have the following:
- Node.js installed on your local machine.
- A Telegram bot created and its API token (BOT_TOKEN).
- A Telegram group or channel where you want the messages to be forwarded (GROUP_ID).
- Clone this repository to your local machine.
git clone https://github.com/SharafatKarim/AnonymousForwardingBot
- Change your working directory to the project folder.
cd AnonymousForwardingBot
- Install the required dependencies.
npm i
- Create a
.env
file in the project root directory and set the following environment variables:
BOT_TOKEN=XXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
GROUP_ID=-XXXXXXXXX
Replace BOT_TOKEN
and GROUP_ID
with the actual values you obtained from your Telegram bot and group.
- And finally, deploy the bot in your local machine using the following command.
node index.js
Deploy to Netlify by linking to this repository. And don't forget to fill in the environment variables on netlify.
BOT_TOKEN=XXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
GROUP_ID=-XXXXXXXXX
Thereafter, you need to specify and tell telegram where your bot should direct the messages it received to. Do so by simply visiting this url (without the {, })
https://api.telegram.org/bot{your_bot_token}/setWebhook?url={your_netlify_domain_url}/api/bot
If it is set up correctly, it should respond back with,
{
"ok": true,
"result": true,
"description": "Webhook was set"
}
And that's it!
Try typing /start to your bot!
-
Go to the BotFather on Telegram and create a new bot.
-
Copy the API token (BOT_TOKEN) provided by the BotFather.
-
Set the bot's profile and add a username if required.
-
Start a conversation with your bot, so you have a chat ID for the bot.
Now that your bot is deployed and ready, follow these steps to start forwarding messages:
-
Add your bot to the Telegram group where you want the messages to be forwarded.
-
Make your bot an administrator of the group to ensure it has the necessary permissions to forward messages.
-
Start a chat with your bot, and you can start sending messages to the bot. The bot will automatically forward these messages to the group without revealing the sender's identity.
-
The Telegram Anonymous Forwarding Bot is designed to maintain the privacy of your users. It forwards messages without disclosing the original sender's identity.
-
Remember to keep your
BOT_TOKEN
andGROUP_ID
environment variables secret. Do not expose them in public repositories or share them with unauthorized users. -
Netlify offers free hosting, but be mindful of any usage limitations or terms of service changes that may apply.
If you would like to contribute to this project, feel free to open issues or submit pull requests on the GitHub repository.
This project is licensed under the MIT License. Please review the LICENSE file for more details.