Telegram Channel
Connect your Moxxy agent to Telegram as a bot.
Prerequisites
- A Telegram account
- Access to @BotFather on Telegram
Setup
Step 1: Create a Bot
- Open Telegram and search for @BotFather
- Send
/newbot - Follow the prompts:
- Choose a bot name (e.g., "My Moxxy Bot")
- Choose a username (e.g., "mymoxxy_bot")
- Save the bot token you receive:
1234567890:ABCdefGHIjklMNOpqrsTUVwxyz-123456
Step 2: Connect to Moxxy
moxxy channel telegram --agent defaultYou'll be prompted for:
- Bot token - From @BotFather
- Pairing code - After sending /start
Step 3: Pair Your Account
- Open your bot in Telegram
- Send
/start - You'll receive a 6-digit pairing code
- Enter the code in the terminal:
? Pairing code: 123456
Step 4: Done!
Your agent is now connected. Send a message to your bot to test.
Bot Commands
| Command | Description |
|---|---|
/start | Pair your account with the bot |
/skills | List available skills |
/new | Start a fresh conversation session |
/help | Show help message |
Voice Messages
Telegram voice messages are automatically transcribed:
- Send a voice message to your bot
- Moxxy uses OpenAI Whisper to transcribe
- Agent responds to the transcribed text
Configure Whisper Model
moxxy run --agent default --prompt "Store 'whisper-1' in vault as whisper_model"Configuration Options
CLI Options
moxxy channel telegram --agent <name> [--token <token>] [--pair-code <code>]| Option | Description |
|---|---|
--agent, -a | Agent to connect (default: "default") |
--token | Bot token (prompts if omitted) |
--pair-code, -c | Pre-entered pairing code |
Vault Configuration
| Key | Description |
|---|---|
telegram_token | Bot token from @BotFather |
telegram_admin_id | Allowed Telegram user ID |
whisper_model | Whisper model for voice |
Environment Variables
export TELEGRAM_BOT_TOKEN="1234567890:ABC..."Security
Pairing Mechanism
The pairing system ensures only you can use your bot:
- Unpaired: Bot only accepts
/start - Pairing: 6-digit code verification
- Paired: Full bot access
Admin Restrictions
Limit bot access to specific users:
moxxy run --agent default --prompt "Store '123456789' in vault as telegram_admin_id"Get your Telegram user ID from @userinfobot.
Security Best Practices
- Never share your bot token
- Set admin_id to restrict access
- Use HTTPS webhook in production
- Monitor logs for suspicious activity
- Regenerate token if compromised
Webhooks vs Polling
Polling (Default)
Bot actively fetches new messages:
Telegram Server ← Bot: "Any new messages?"
Telegram Server → Bot: "Yes, here they are"Pros:
- Simple setup
- Works behind NAT
- No public URL needed
Cons:
- Higher latency
- More API calls
Webhooks
Telegram pushes messages to your server:
User → Telegram → Your Server → BotSetup:
moxxy run --agent default --prompt "Store 'https://your-domain.com/telegram/webhook' in vault as telegram_webhook_url"Pros:
- Lower latency
- Fewer API calls
- Real-time updates
Cons:
- Requires public HTTPS URL
- More complex setup
Advanced Features
Custom Commands
Define custom bot commands via @BotFather:
- Send
/setcommandsto @BotFather - Enter:
start - Pair your account skills - List available skills new - Start new session help - Show help
Bot Description
Set bot info via @BotFather:
/setdescription
/about
/setavatarInline Mode
Enable inline queries:
moxxy run --agent default --prompt "Store 'true' in vault as telegram_inline_enabled"Users can then: @your_bot search query
Group Chats
Add your bot to groups:
- Add bot to group
- Give it permissions
- Mention or reply to trigger
Note: Bot only responds to mentions/replies in groups.
Troubleshooting
Bot Not Responding
Check gateway status:
bashmoxxy gateway statusCheck logs:
bashmoxxy logs | grep -i telegramVerify token:
bashmoxxy run --agent default --prompt "What is my telegram_token?"
Pairing Failed
- Ensure you sent
/startfirst - Check code is 6 digits
- Try again (code expires in 5 minutes)
Rate Limited
Telegram limits: ~30 messages/second
If rate limited:
- Reduce message frequency
- Add delays between messages
- Check for broadcast loops
Voice Transcription Failed
Verify Whisper API key:
bashmoxxy doctorCheck OpenAI API status
Verify audio format (OGG expected)
API Reference
Webhook Endpoint
POST /api/webhooks/telegramPayload: Telegram Update Object
Send Message
curl -X POST http://localhost:17890/api/agents/default/telegram/send \
-H "Content-Type: application/json" \
-d '{
"chat_id": "123456789",
"text": "Hello from Moxxy!"
}'Send Photo
curl -X POST http://localhost:17890/api/agents/default/telegram/send \
-H "Content-Type: application/json" \
-d '{
"chat_id": "123456789",
"photo": "https://example.com/image.jpg",
"caption": "Check this out!"
}'Examples
Basic Interaction
User: Hello!
Bot: Hi! I'm your Moxxy assistant. How can I help you today?
User: What's the weather?
Bot: Let me check the weather for you.
[Uses web_crawler skill]
The current weather in your area is sunny, 72°F.Using Skills
User: Check my server status
Bot: I'll check your server status.
[Uses host_shell skill]
Your server is up and running:
- CPU: 23%
- Memory: 4.2GB / 16GB
- Disk: 120GB / 500GBScheduled Notifications
User: Send me a daily summary at 9am
Bot: I'll schedule a daily summary for you.
[Uses scheduler skill]
Done! You'll receive a daily summary at 9am.