A modern Telegram bot for managing Twilio phone numbers and retrieving OTPs, built with Pʏᴛʜᴏɴ 3.8+ and Pʏʀᴏɢʀᴀᴍ. This bot allows users to purchase phone numbers, receive OTP messages, and manage their Twilio accounts directly through Telegram with a sleek and intuitive interface. ❄️
- Uꜱᴇʀ Aᴜᴛʜᴇɴᴛɪᴄᴀᴛɪᴏɴ: Secure login and logout with Twilio SID and Token. ⭐️
- Nᴜᴍʙᴇʀ Mᴀɴᴀɢᴇᴍᴇɴᴛ: Purchase, list, and delete phone numbers (Puerto Rico numbers supported). 💫
- OTP Rᴇᴛʀɪᴇᴠᴀʟ: Fetch and display the latest OTP messages. 🌐
- Aᴅᴍɪɴ Cᴏɴᴛʀᴏʟꜱ: Authorize/unauthorize users via commands. ✅
- Cᴜꜱᴛᴏᴍ Nᴜᴍʙᴇʀ Sᴇʟᴇᴄᴛɪᴏɴ: Choose numbers by area code for personalized purchases. 💀
- MᴏɴɢᴏDB Iɴᴛᴇɢʀᴀᴛɪᴏɴ: Persistent storage for user data and numbers. ☠️
- Mᴏᴅᴇʀɴ UI: Markdown-based messages with inline keyboards for a seamless user experience. ⭐️
- Eʀʀᴏʀ Hᴀɴᴅʟɪɴɢ: Robust logging and user-friendly error messages. 💫
- Aꜱʏɴᴄʜʀᴏɴᴏᴜꜱ Dᴇꜱɪɢɴ: Built with Pyrogram and aiohttp for high performance. ❄️
- Pʏᴛʜᴏɴ 3.8+: Ensure Python is installed.
- MᴏɴɢᴏDB: A running MongoDB instance (local or cloud-based, e.g., MongoDB Atlas).
- Tᴇʟᴇɢʀᴀᴍ Bᴏᴛ: A bot token from BᴏᴛFᴀᴛʜᴇʀ.
- Tᴡɪʟɪᴏ Aᴄᴄᴏᴜɴᴛ: Twilio SID and Token for number purchasing and OTP retrieval.
- VPS (Oᴘᴛɪᴏɴᴀʟ): For deployment (e.g., Ubuntu 20.04+).
git clone https://github.com/TheSmartDevs/TwilioSMSBot.git
cd TwilioSMSBot
Create a virtual environment and install the required packages:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Edit config.py
with your credentials:
API_ID = YourAPIID # From https://my.telegram.org
API_HASH = "YourAPIHash" # From https://my.telegram.org
BOT_TOKEN = "YourBotToken" # From BotFather
ADMIN_IDS = [7303810912, 5991909954, 6249257243] # Your Telegram user IDs
MONGO_URI = "Your_Mongo_Url" # MongoDB connection string
- API_ID and API_HASH: Obtain from Tᴇʟᴇɢʀᴀᴍ'ꜱ API ᴘᴀɢᴇ.
- BOT_TOKEN: Create a bot via BᴏᴛFᴀᴛʜᴇʀ.
- MONGO_URI: Use MongoDB Atlas or a local MongoDB instance (
mongodb://localhost:27017
). - ADMIN_IDS: Add Telegram user IDs of admins who can authorize users.
Start the bot:
python3 bot.py
The bot will log its status and respond to commands in Telegram. ✅
- Use a provider like DigitalOcean, AWS, or Linode.
- Recommended: Ubuntu 20.04+ with at least 1GB RAM.
sudo apt update
sudo apt install python3 python3-venv python3-pip git screen mongodb -y
If using MongoDB Atlas, skip local MongoDB installation.
git clone https://github.com/TheSmartDevs/TwilioSMSBot.git
cd TwilioSMSBot
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Copy and edit config.py
as described in the setup section.
Use screen
to keep the bot running in the background:
screen -S twilio_bot
source venv/bin/activate
python3 bot.py
Detach from the screen session by pressing Ctrl+A
then D
. To reattach:
screen -r twilio_bot
/start
: Welcome message with bot instructions./login <SID> <TOKEN>
: Log in to your Twilio account./buy
: Purchase a phone number (supports custom area codes)./get
: Retrieve OTP messages./del <PhoneNumber>
: Delete a purchased number./my
: List your active numbers./logout
: Log out from your Twilio account./auth <useridOrusername>
: (Admin only) Authorize a user./unauth <useridOrusername>
: (Admin only) Unauthorize a user.
- Start the bot:
/start
- Log in:
/login ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx YourTwilioToken
- Buy a number:
/buy
(follow prompts to select a number). - Get OTPs:
/get
- Delete a number:
/del +1234567890
TwilioSMSBot/
├── bot.py # Main bot logic
├── app.py # Bot client setup
├── config.py # Configuration file
├── core/ # MongoDB collections
│ ├── __init__.py
│ └── mongo.py
├── utils/ # Logger and utilities
│ ├── __init__.py
│ └── LOGGING.py
├── requirements.txt # Dependencies
└── README.md # This file
Contributions are welcome! Please:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature
). - Commit your changes (
git commit -m 'Add your feature'
). - Push to the branch (
git push origin feature/your-feature
). - Open a Pull Request.
For issues or questions, contact the developer:
- Tᴇʟᴇɢʀᴀᴍ: @TʜᴇSᴍᴀʀᴛDᴇᴠ
- GɪᴛHᴜʙ: TʜᴇSᴍᴀʀᴛDᴇᴠꜱ
Rᴇᴘᴏꜱɪᴛᴏʀʏ: https://github.com/TheSmartDevs/TwilioSMSBot