This project is a simple yet robust Telegram bot designed to process incoming messages and echo them back in a readable JSON format. The bot can handle various types of messages, including text, media, notes, and more. It also supports splitting long messages to comply with Telegram's character limits and ensures smooth operation with robust error handling.
The bot is designed to run seamlessly on Cloudflare Workers, offering a free and scalable environment for hosting.
- Support for All Message Types: Handles text, media, notes, and other message formats gracefully.
- JSON Formatting: Converts incoming messages into a well-formatted JSON structure for easier debugging or analysis.
- Message Splitting: Automatically splits long messages into chunks to meet Telegram's 4096-character limit.
- Error Handling: Prevents crashes and logs meaningful errors for easier troubleshooting.
- Free Hosting: Compatible with Cloudflare Workers, enabling free and scalable deployment.
- Lightweight: Minimal dependencies, making it fast and efficient.
- Telegram Bot Token: Obtain a bot token by creating a bot through BotFather.
- Cloudflare Account: Set up a free Cloudflare account to use their Workers platform.
git clone https://github.com/MrDevAnony/SendJsonBot.git
cd SendJsonBot
Replace the placeholder bot token in the script with your actual Telegram bot token:
const token = 'YOUR_TELEGRAM_BOT_TOKEN';
- install Wrangler CLI:
npm install -g wrangler
- Authenticate with Cloudflare:
wrangler login
- Deploy the bot:
wrangler publish
Note the generated Worker URL and set it as your bot's webhook using the following command:
curl -X POST "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook?url=<YOUR_WORKER_URL>"
Done!
- Start a conversation with your bot on Telegram.
- Send any type of message (text, media, etc.).
- The bot will echo back the message content in JSON format.
- Free Plan: Cloudflare Workers provides 100,000 free requests per day.
- Scalability: Automatically scales with traffic.
- Low Latency: Serves requests from the edge, ensuring fast responses globally.
- No Server Management: Eliminate the need for managing servers or infrastructure.