Telegram Bot
Introduction to Telegram Bot integration
Overview
SuperTele provides a complete Telegram Bot integration based on grammY, supporting command handling, inline queries, payments, and more.
Configuration
Environment Variables
Configure the following environment variables in your .env.local file:
# Telegram Bot Token (get from @BotFather)
TELEGRAM_BOT_TOKEN=your_bot_token
# Webhook secret for security verification
TELEGRAM_BOT_WEBHOOK_SECRET=your_webhook_secret
# Your website URL (for webhook setup)
NEXT_PUBLIC_APP_URL=https://your-domain.comDevelopment Mode
In development, use long polling mode:
pnpm bot:devProduction Mode
In production, set up webhook:
pnpm bot:webhookBot Commands
The template includes the following built-in commands:
| Command | Description |
|---|---|
/start | Start the bot and show welcome message |
/help | Show help information |
/buy | Purchase credits |
/balance | Check credit balance |
/invite | Get invitation link |
/support | Contact support |
Telegram Stars Payment
SuperTele supports Telegram Stars as a payment method:
User Initiates Payment
User clicks buy button or uses /buy command.
Display Invoice
Bot sends an invoice with product details.
Process Payment
Handle pre_checkout_query and successful_payment events.
Deliver Product
Add credits or unlock features for the user.
File Structure
src/telegram/
├── bot/
│ ├── bot.ts # Bot instance
│ ├── commands/ # Command handlers
│ └── i18n.ts # Internationalization
├── stars/
│ └── payment-service.ts # Stars payment service
├── miniapp/ # MiniApp utilities
└── invite/ # Invitation system
TeleTemplate Docs