Telegram private chat logger (using telegram business chatbots API) on cloudflare workers.
- Prevent data loss when users delete the chat for both sides.
- Maintain an organized and searchable record of all conversations.
const BOT_TOKEN = "BOT_TOKEN"; // Insert your bot token.
const BOT_WEBHOOK = "/endpoint"; // Let it be as it is.
const BOT_SECRET = "BOT_SECRET"; // Insert a powerful secret text (only [A-Z, a-z, 0-9, _, -] are allowed).
const BOT_OWNER = 123456789; // Insert your telegram account id.- Get
BOT_TOKENfrom @botfather.- Enable business mode from botfather
bot settings > business mode. - Add your bot as third-party chatbot in your telegram account
settings > telegram business > chatbots.
- Enable business mode from botfather
- Change
BOT_WEBHOOKwith your preferred webhook. - Change
BOT_SECRETwith a powerful secret text (only[A-Z, a-z, 0-9, _, -]are allowed). - Get
BOT_OWNERfrom @idbot.
- Create a Cloudflare account.
- Navigate to
Workers & Pages > Create > Create Worker. - Deploy the worker by clicking Deploy.
- Edit the code by clicking Edit Code.
- Upload
worker.jsinto Cloudflare. - Modify the variables.
- Finally, Deploy.
- Once you deployed the bot on Cloudflare.
- Check
XXX.XXXX.workers.dev/getMeto verify your bot authorization. - Open
XXX.XXXX.workers.dev/registerWebhookto register your bot webhook. - Now your bot will log every type of private message.
Contributions are welcome! Feel free to submit a pull request or report an issue.
MIT License
Copyright (c) 2025 Vauth
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.