Step 1: Create a Bot
Message BotFather
Open Telegram and message @BotFather. Send
/newbot and follow the prompts:- Name: The display name (e.g., “My Spacebot”)
- Username: Must end in
bot(e.g.,my_spacebot_bot)
Step 2: Configure Privacy (Optional)
By default, bots in groups only see messages that mention them directly, reply to them, or start with a/command.
If you want the bot to see all messages in a group:
Step 3: Add Token to Spacebot
- TOML Config
config.toml
config.toml
Step 4: Add the Bot
Add the bot to a group, or start a DM with it by searching for its username in Telegram.Verify It’s Working
Send a message to the bot. You should see:- A typing indicator while it processes
- A reply from the bot
Filtering
Restrict to Specific Chats
By default the bot responds in any chat it’s added to. To limit it, add chat IDs to your binding.config.toml
chat_id, the bot responds in all chats.
Finding Chat IDs
- DMs: The chat ID is the user’s Telegram user ID. You can find it by messaging @userinfobot.
- Groups: Add the bot to the group, send a message, and check the Spacebot logs — the
conversation_idwill show astelegram:<chat_id>. Group IDs are negative numbers (e.g.,-100123456789).
DM Filtering
By default, DMs from anyone are accepted. To restrict to specific users:config.toml
Multiple Chats, Multiple Agents
Route different Telegram chats to different agents.config.toml
Media Attachments
Telegram supports sending and receiving:- Images (JPEG, PNG, WebP)
- Documents (PDF, ZIP, any file type)
- Audio files
- Video files
MessageContent::Media variant with authenticated URLs.
Telegram has a 20MB file size limit for bots. Larger files must be sent as URLs instead.
Rich Messages
Telegram supports:Markdown Formatting
Use standard Markdown syntax:**bold***italic*`code`code blocks
Inline Keyboards
Interactive buttons attached to messages. Spacebot convertsOutboundResponse::RichMessage with interactive elements to Telegram inline keyboards.
Polls
Create polls with:- Up to 10 options
- Anonymous or non-anonymous
- Quiz mode with correct answer
Limitations
- Message length: 4096 characters. Longer messages are automatically split.
- File size: 20MB for bot uploads
- Reaction support: Limited to emoji reactions supported by the specific chat
- Streaming: Message edits have a 1-second minimum interval to avoid rate limits
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
401 Unauthorized on startup | Invalid token | Get a fresh token from BotFather |
| Bot doesn’t respond in group | Privacy mode | Send /setprivacy → Disable to BotFather, then remove and re-add the bot |
| Bot doesn’t respond to DMs | DM filtering | Add user ID to dm_allowed_users, or clear the list to allow all |
| Reaction fails silently | Unsupported emoji | Telegram limits reactions to each chat’s configured emoji set |
| Edits fail with rate limit | Too frequent updates | Streaming edits are throttled to 1 second intervals automatically |
Next Steps
Configure Permissions
Set up chat filters and access control
Media Handling
Learn how file attachments work
Agent Configuration
Create multiple agents for different chats