This project is a Telegram support bot that answers frequently asked questions and auto-connects users to a human support agent when needed. Built with:
python-telegram-bot(v20+ async)FastAPI(for webhook)- Deployed on Railway
- Features automated session management, fuzzy matching for FAQs, and admin chat routing.
- ✅ Welcomes users with a guided message
- 📋 Supports
/faq,/ping,/chat,/stopchatcommands - 🤖 Auto-replies to common questions using fuzzy matching
- 🧠 Escalates to admin if no suitable answer is found
- 🔄 Allows direct admin-user communication
- 🕒 Auto-reminder if admin hasn't replied in 2 minutes
- ⏳ Auto-closes inactive chats after 10 minutes
User: /start
Bot: Sends a welcome message with instructions.
User: "How do I fund?"
Bot: Sends a predefined markdown guide.
User: asks an unrecognized question
Bot: Escalates to admin + invites admin to reply directly.
├── main.py # Main bot + FastAPI logic
├── requirements.txt # Python dependencies
├── Procfile # For Railway deployment
├── .env # Environment config (not committed)
git clone https://github.com/yourusername/telegram-faq-bot.git
cd telegram-faq-botBOT_TOKEN=123456789:ABCdefGhIjkLmNoPQRstuVWXyz
ADMIN_CHAT_ID=123456789
WEBHOOK_DOMAIN=https://your-app-name.up.railway.appUse @userinfobot on Telegram to find your user ID.
pip install -r requirements.txtuvicorn main:app --host 0.0.0.0 --port 8000Use a tool like ngrok to expose your local port:
ngrok http 8000Set WEBHOOK_DOMAIN=https://xxxx.ngrok.io in your .env
- Push code to GitHub
- Connect to Railway
- Set the
.envvariables - Railway will detect the
Procfileand run:web: uvicorn main:app --host 0.0.0.0 --port 8000
start - 🚀 Start support session
faq - 📋 View frequently asked questions
chat - 👤 Connect to human support
stopchat - 🔕 Stop support chat
ping - 🧪 Test bot connection
python-telegram-bot[fast]==20.6fastapiuvicorn- Deployed via Railway
- Add database logging for chats
- Admin panel with chat history
- Rate limiting
- Satisfaction survey after chat
Having issues? Feel free to DM the admin in Telegram after typing /chat inside the bot.