More on the topic...
Generating detailed summary...
Failed to generate summary. Please try again.
To connect a Telegram bot to Claude Code, you need to set up an MCP server that acts as an intermediary. This server logs into Telegram as a bot, allowing for message replies, reactions, and edits. When you send a message to the bot, it forwards that message to your Claude Code session. The MCP server operates on Bun, and installation can be done via a simple curl command.
The setup process begins by creating a bot through BotFather on Telegram. You need to provide a display name and a unique username that ends with “bot.” After BotFather generates a token for you, this token is crucial for configuring the server. You'll install the Telegram plugin using specific Claude Code commands and then input the bot token into the server's configuration file. Each bot requires its own directory if you plan to run multiple instances on one machine. Once configured, you must relaunch the server with a channel flag to establish the connection.
After starting the server, you can pair the bot with your Claude Code session by sending it a direct message on Telegram. The bot will respond with a pairing code, which you enter back into Claude Code to enable communication. Unlike Discord, you don’t need to invite anyone; the bot accepts direct messages right away. To enhance security, switch from pairing mode to allowlist mode, preventing unauthorized access from others.
The Telegram bot supports several tools for interaction. You can send messages, react with emojis from a fixed set, or edit previous messages sent by the bot. Inbound messages trigger a typing indicator, and photos received are downloaded automatically to a specified directory. However, it’s important to note that the bot cannot access message history or search previous conversations. If context from earlier messages is needed, the assistant will ask you to provide it directly.
Questions about this article
No questions yet.