Deploy Telegram Bot
Launch your Telegram bot with an admin UI, then make the code your own.
Just deployed
/var/lib/postgresql/data
telegram-bot-studio
Just deployed
Deploy and Host Telegram Bot Studio on Railway
Telegram Bot Studio is a ready-to-use Telegram bot with a built-in web dashboard for managing commands, replies, media responses, and reply keyboards without editing code.
This template deploys the bot together with PostgreSQL, so user data and dynamic commands are stored persistently. Developers can also customize the source code later by ejecting the upstream repository and modifying the bot, FastAPI dashboard, handlers, integrations, or business logic.
About Hosting Telegram Bot Studio
This template deploys two connected services:
- Telegram Bot Studio — runs the Telegram bot and password-protected administration dashboard
- PostgreSQL — stores bot users and dynamic command configuration
The bot uses Telegram long polling, while the administration panel runs in the same application process and is exposed through Railway's public HTTPS domain.
PostgreSQL is connected automatically through Railway private networking. Database migrations run automatically when the application starts, so there is no manual database initialization step required.
Included Architecture
| Service | Purpose |
|---|---|
| Telegram Bot Studio | Telegram bot, FastAPI dashboard, command runtime |
| PostgreSQL | Persistent users and dynamic command storage |
| Railway Private Networking | Internal application-to-database connectivity |
| Railway Public Networking | HTTPS access to the administration dashboard |
| Alembic Migrations | Automatically prepares and updates the database schema |
Telegram Users
│
▼
Telegram API
│
▼
┌─────────────────────┐
│ Telegram Bot Studio │
│ │
│ Bot Poller │
│ FastAPI Admin UI │
│ Dynamic Commands │
└──────────┬──────────┘
│
Private Network
│
▼
┌─────────────────┐
│ PostgreSQL │
│ │
│ Users │
│ Commands │
└─────────────────┘
Common Use Cases
- Launch a Telegram bot without building the entire project from scratch
- Manage bot commands from a web dashboard
- Add or update replies without redeploying
- Create text, photo, and document responses
- Add Telegram reply keyboards
- Track Telegram users persistently
- Build an internal support or information bot
- Create a community or utility bot
- Use the included project as a starting point for a custom Telegram application
- Extend the bot with external APIs, automation platforms, databases, or business logic
Built-In Bot Features
Telegram Bot Studio includes several commands out of the box:
| Command | Purpose |
|---|---|
/start | Displays the welcome response and persistent menu |
/help | Shows available commands |
/about | Displays bot information |
/ping | Checks whether the bot is responding |
Normal text messages can also be handled by the default echo functionality.
Unknown commands fall through to the dynamic command registry, allowing commands created from the Studio dashboard to work without modifying the source code.
Telegram Bot Studio Dashboard
The administration dashboard runs in the same service as the Telegram bot.
From the dashboard you can:
- Add commands
- Edit existing commands
- Enable or disable commands
- Delete commands
- Create text replies
- Send photos
- Send documents
- Use media URLs or Telegram
file_idvalues - Configure reply keyboards
- Apply command changes without redeploying
Changes are loaded into the running bot and the Telegram command menu is refreshed when configurations are saved.
Getting Started
Before deployment, you only need to provide:
BOT_TOKEN
To obtain it:
- Open Telegram.
- Start a conversation with
@BotFather. - Create a new bot.
- Copy the generated bot token.
- Paste the token into the
BOT_TOKENvariable. - Deploy the template.
After deployment:
- Wait until Telegram Bot Studio and PostgreSQL are online.
- Open the public Railway URL assigned to Telegram Bot Studio.
- Open the service Variables page.
- Copy:
PANEL_USERNAME
PANEL_PASSWORD
- Sign in to the dashboard.
- Add or customize bot commands.
- Open Telegram and start your bot.
PostgreSQL Persistence
PostgreSQL is included by default in this template.
The database stores:
- Telegram users
- Telegram usernames
- First names
- Last activity information
- Dynamic commands
- Command settings
- Reply configuration
- Media responses
- Keyboard configuration
When a user runs /start, their information can be inserted or refreshed in PostgreSQL.
Database connections use asyncpg connection pooling and are closed cleanly during application shutdown.
Automatic Database Migrations
No manual database migration command is required.
On startup, the application checks whether a database connection exists and automatically runs:
alembic upgrade head
before starting the bot process.
This allows schema updates to follow application updates without requiring the user to enter the Railway Console manually.
Ready to Use, Ready to Customize
Telegram Bot Studio is designed to work immediately after deployment, but the source code is also available if you want to build something more advanced.
The Railway template uses the GitHub repository:
https://github.com/codestorm-official/telegram-bot-studio
The project is open source under the MIT License.
If you want to customize the application after deployment, you can eject the upstream repository from Railway and create your own copy.
You can then modify:
- Telegram handlers
- Built-in commands
- FastAPI routes
- Dashboard pages
- Authentication
- Database models
- Business logic
- External API integrations
- AI integrations
- Webhooks
- Automation workflows
This gives you two ways to use the template:
| Mode | Best For |
|---|---|
| Dashboard Mode | Managing commands without coding |
| Developer Mode | Building a fully customized Telegram application |
Project Stack
Telegram Bot Studio is built using:
- Python
python-telegram-bot- FastAPI
- PostgreSQL
- asyncpg
- Alembic
- Docker
- Railway
The web dashboard and Telegram bot run in the same application service, so no additional frontend or backend container is required.
Deployment Behavior
The project already includes Railway configuration using its Dockerfile.
The configured start process is:
sh start.sh
The startup script:
- Runs database migrations when PostgreSQL is configured.
- Starts the Telegram bot application.
This means no custom Railway start command needs to be configured separately.
Replica and Scaling Considerations
This template should run with:
1 replica
The bot currently uses Telegram long polling.
Telegram's getUpdates model only allows one active polling consumer for a bot token, so running multiple replicas would cause conflicts.
Horizontal scaling would require moving to a webhook-based architecture or implementing coordination between instances.
Security Considerations
The administration panel can change bot behavior and should be treated as an administrative interface.
For production deployments:
- Keep
BOT_TOKENprivate. - Use a strong dashboard password.
- Keep PostgreSQL on Railway private networking.
- Do not expose PostgreSQL publicly unless necessary.
- Keep the panel secret key persistent.
- Keep secure cookies enabled.
- Rotate credentials if they are exposed.
- Review custom commands before enabling them publicly.
The dashboard includes signed sessions and CSRF protection for state-changing forms.
Dependencies for Telegram Bot Studio Hosting
- Telegram Bot Studio — Telegram bot runtime and administration dashboard
- PostgreSQL — persistent users and dynamic command storage
- Railway Private Networking — internal database communication
- Railway Public Networking — HTTPS access to the Studio dashboard
- Telegram Bot Token — provided by the user from
@BotFather - Alembic — automatic database schema migrations
No Redis or persistent application volume is required.
Deployment Dependencies
- Telegram Bot Studio GitHub: https://github.com/codestorm-official/telegram-bot-studio
- python-telegram-bot: https://python-telegram-bot.org/
- Telegram Bot API: https://core.telegram.org/bots/api
- Railway PostgreSQL: https://docs.railway.com/databases/postgresql
- Railway Networking: https://docs.railway.com/networking
Why Deploy Telegram Bot Studio on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying Telegram Bot Studio on Railway, you get a ready-to-use Telegram bot, PostgreSQL persistence, a password-protected administration dashboard, automatic database migrations, and full access to the source code when you want to customize the project further.
Template Content
telegram-bot-studio
codestorm-official/telegram-bot-studioBOT_TOKEN
Required: Telegram bot token generated from @BotFather
