I’m thinking about creating two Telegram bots and I’m wondering if it’s okay to handle them in the same project. Here are my main concerns:
Can I use a single application to manage both bots?
Will there be any issues with webhooks if I do this?
Are there any best practices for running multiple bots in one codebase?
I’m new to Telegram bot development, so any advice would be really helpful. Has anyone here done something similar before? What was your experience like?
I’ve been running multiple Telegram bots in a single application for a while now, and it’s definitely manageable. The key is proper organization and separation of concerns. I use a modular architecture, with each bot having its own dedicated module. This keeps the codebase clean and makes it easier to maintain and scale.
One thing I learned the hard way is to be careful with shared resources. Initially, I had some global variables that caused unexpected behavior when both bots tried to access them simultaneously. I solved this by implementing a proper dependency injection system and ensuring each bot had its own isolated state.
For webhooks, I use a reverse proxy to route incoming requests to the appropriate bot handler based on the URL path. This setup has been rock-solid and allows for easy addition of new bots without conflicting with existing ones.
Performance-wise, I haven’t noticed any significant issues running multiple bots in one app. Just make sure your server can handle the combined load of all bots during peak times. Overall, it’s been a positive experience, and I’d recommend this approach for managing multiple bots efficiently.
yep, totally doable! i’ve managed multiple bots in one app before. just use different tokens for each bot and handle their stuff separately. for webhooks, set up different endpoints. keep the code organized - maybe use classes for each bot. watch out for rate limits if they get busy tho. good luck with ur project!
Yes, it’s absolutely possible to manage multiple Telegram bots within a single application. I’ve done this myself for a client project. The key is to use separate API tokens for each bot and handle their updates independently. For webhooks, you’ll need to set up distinct endpoints for each bot to avoid conflicts. In terms of best practices, I’d recommend organizing your code into modules or classes for each bot to keep things clean and maintainable. One challenge I encountered was managing different conversation states for each bot simultaneously. Implementing a robust state management system helped tremendously. Also, be mindful of rate limits if your bots are high-traffic. Overall, it’s a straightforward process with proper planning. Just ensure you’re keeping each bot’s functionality and data separate within your codebase.