Baileys/libsignal logs "Closing open session in favor of incoming prekey bundle" and similar messages that are normal Signal Protocol key renegotiation - not errors. Changes: - Remove our own crypto error logging (line 810) - Add console filter to suppress Baileys crypto patterns: - prekey bundle messages - session renegotiation - bad mac errors - ratchet/key details These are harmless noise that confused users into thinking something was wrong. Addresses LET-7275 Written by Cameron ◯ Letta Code "Silence is golden." - Thomas Carlyle
5.2 KiB
Telegram Setup for LettaBot
This guide walks you through setting up Telegram as a channel for LettaBot.
Overview
LettaBot connects to Telegram using the Bot API with long-polling:
- No public URL required (no webhook needed)
- Works behind firewalls
- Automatic reconnection handling
Prerequisites
- A Telegram account
- LettaBot installed and configured with at least
LETTA_API_KEY
Step 1: Create a Bot with BotFather
-
Open Telegram and search for @BotFather
-
Start a chat and send
/newbot -
Choose a display name for your bot (e.g.,
LettaBot) -
Choose a username ending in
bot(e.g.,my_letta_bot) -
BotFather will respond with your bot token
Important
: Copy this token immediately. It looks like
123456789:ABCdefGHIjklMNOpqrsTUVwxyz
Step 2: Configure LettaBot
Run the onboarding wizard and select Telegram:
lettabot onboard
Or add directly to your lettabot.yaml:
channels:
telegram:
enabled: true
token: "123456789:ABCdefGHIjklMNOpqrsTUVwxyz"
dmPolicy: pairing # or 'allowlist' or 'open'
Or use environment variables:
export TELEGRAM_BOT_TOKEN="123456789:ABCdefGHIjklMNOpqrsTUVwxyz"
export TELEGRAM_DM_POLICY="pairing"
Step 3: Start LettaBot
lettabot server
You should see:
Registered channel: Telegram
[Telegram] Bot started as @your_bot_username
[Telegram] DM policy: pairing
Step 4: Test the Integration
- Open Telegram and search for your bot's username
- Click Start or send
/start - If using pairing mode, you'll receive a pairing code
- Approve the code:
lettabot pairing approve telegram ABCD1234 - Send a message:
Hello! - The bot should respond
Access Control
LettaBot supports three DM policies for Telegram:
Pairing (Default)
dmPolicy: pairing
- New users receive a pairing code
- Approve with:
lettabot pairing approve telegram <CODE> - Most secure for personal use
Allowlist
dmPolicy: allowlist
allowedUsers:
- 123456789 # Telegram user IDs
- Only specified users can interact
- Find your user ID: Message @userinfobot or check the bot logs
Open
dmPolicy: open
- Anyone can message the bot
- Not recommended for personal bots
Bot Commands
LettaBot responds to these Telegram commands:
| Command | Description |
|---|---|
/start |
Welcome message and help |
/help |
Show available commands |
/status |
Show current bot status |
/heartbeat |
Trigger a heartbeat (silent) |
Features
Voice Messages
Send a voice message to have it transcribed and processed:
- Requires
OPENAI_API_KEYfor transcription - The bot transcribes and responds to the content
- Configure in
lettabot.yaml:transcription: provider: openai apiKey: sk-... # Optional: uses OPENAI_API_KEY env var
Attachments
The bot can receive and process:
- Photos
- Documents
- Videos
- Audio files
- Stickers
- Animations (GIFs)
Attachments are downloaded to /tmp/lettabot/attachments/telegram/ and the agent can view images using its Read tool.
Reactions
LettaBot can react to messages using the lettabot-react CLI:
# React to the most recent message
lettabot-react add --emoji "eyes"
# React to a specific message
lettabot-react add --emoji "thumbsup" --channel telegram --chat 123456789 --message 42
Telegram supports a limited set of reaction emojis. Common ones:
thumbsup, heart, fire, eyes, clap, tada
Troubleshooting
Bot not responding
- Check the token: Make sure you copied the full token from BotFather
- Check pairing: If using pairing mode, approve new users with
lettabot pairing list telegram - Check logs: Look for errors in the console output
"Unauthorized" error
Your bot token is invalid:
- Go back to @BotFather
- Send
/mybotsand select your bot - Click API Token to see the current token
- If needed, use Revoke current token to generate a new one
Bot responds slowly
This is normal - the bot needs to:
- Receive your message
- Send it to the Letta agent
- Wait for the agent to respond
- Send the response back
First responses may take longer as the agent "wakes up".
Voice messages not working
- Make sure
OPENAI_API_KEYis set - Check the logs for transcription errors
- Verify your OpenAI account has API access
Rate limiting
If the bot stops responding temporarily, Telegram may be rate-limiting requests. Wait a few minutes and try again.
Security Notes
- Bot tokens should be kept secret - never commit them to git
- Use
dmPolicy: pairingorallowlistin production - The bot can only see messages sent directly to it
- Group functionality is not currently supported
Cross-Channel Memory
Since LettaBot uses a single agent across all channels:
- Messages you send on Telegram continue the same conversation as Slack/Discord
- The agent remembers context from all channels
- You can start a conversation on Telegram and continue it on another channel