A real starter project for a Telegram voice chat music bot using Python, Pyrogram, PyTgCalls, FFmpeg, and yt-dlp.
- Play music in Telegram voice chats
/playusing song names, YouTube URLs, and Spotify links- Queue support
/skip,/stop,/pause,/resume/queue,/nowplaying- Inline control buttons
- Dockerized deployment
This bot is a starter project for a real VC music bot. Telegram voice chat bots usually require:
- A bot token from BotFather
- A Telegram API ID and API HASH from https://my.telegram.org
- An assistant account string session so the assistant user can join voice chats reliably
- The assistant account and bot must both be added to your group
- The assistant account may need admin permissions in the group depending on your setup
- A voice chat must already be started in the target group
telegram-vc-music-bot/
├── bot/
│ ├── handlers.py
│ ├── keyboards.py
│ ├── logger.py
│ ├── models.py
│ ├── player.py
│ ├── queue_manager.py
│ └── search.py
├── .env.example
├── Dockerfile
├── docker-compose.yml
├── config.py
├── main.py
└── requirements.txt
/play <query or playlist URL>/skipadmin only/stopadmin only/pauseadmin only/resumeadmin only/queue/nowplaying/ping
- Get
API_IDandAPI_HASHfrom https://my.telegram.org - Get
BOT_TOKENfrom @BotFather - Generate a Pyrogram
STRING_SESSIONfor an assistant Telegram account
Copy the example file:
cp .env.example .envThen fill in your real values.
This project is prepared for Railway using nixpacks.toml so FFmpeg is installed automatically.
- Push this project to GitHub
- Create a new Railway project
- Choose Deploy from GitHub repo
- Select this repository
- In Railway Variables, add:
API_IDAPI_HASHBOT_TOKENSTRING_SESSIONLOG_LEVEL=INFO
- Deploy the service
- Check logs to confirm the bot started
API_IDAPI_HASHBOT_TOKENSTRING_SESSIONCOMMAND_PREFIXoptionalLOG_LEVELoptional
- FFmpeg is installed through
nixpacks.toml - The bot runs with
python main.py - Session files are not required because this template uses a string session for the assistant account
- If Railway restarts the service, the bot should reconnect automatically on the next deploy/start
docker compose up --build -dTo view logs:
docker compose logs -fInstall FFmpeg first.
Ubuntu/Debian:
sudo apt update
sudo apt install ffmpeg python3 python3-pip -yInstall dependencies:
pip install -r requirements.txtRun the bot:
python main.py- Add the bot to your group
- Add the assistant account to your group
- Promote them if needed
- Make sure the users who should control playback are admins
- Start a Telegram voice chat in that group
- Send
/play never gonna give you up
Spotify links are not streamed directly from Spotify. This starter resolves Spotify links as search metadata and tries to find a matching result on YouTube.
A deploy review file has been added at:
bot/compatibility_notes.md
Main likely issues before deploy:
- Import paths can differ between PyTgCalls versions
join_group_call/change_streamsignatures may vary- Stream-end event decorator behavior may vary by release
- Assistant auto-join using exported invite links may fail in some group setups
If Railway logs show PyTgCalls import or runtime errors, the next fix is usually to pin a known-good version and adjust imports to that exact version.
Start a voice chat in the group before using /play.
Make sure the assistant account is valid, not restricted, and can join the group.
Your bot/assistant may need admin permissions depending on the group settings.
Some source URLs may expire. In a production bot, you may want automatic refresh/re-resolution of streams.
- Auto-play next track when the current stream ends
- Better startup and shutdown logging
- Stream refresh retry when a source URL expires
- Railway-friendly process files (
Procfile,runtime.txt,nixpacks.toml) - Safer callback and command error handling
/pingcommand for quick health checks- Basic concurrency lock around playback state changes
- Better Spotify parsing for playlists/albums
- Playlist support
- Persistent queue storage
- Admin-only controls
- Volume controls
- Thumbnail-rich now playing cards
- Multi-group access control and moderation tools
This project is provided as a starter template. Telegram VC library APIs can change over time, so you may need small compatibility updates depending on your installed versions.