More on the topic...
Generating detailed summary...
Failed to generate summary. Please try again.
To connect a Telegram bot with Claude Code using an MCP server, you start by creating a bot through Telegram's BotFather. This involves sending the command `/newbot` to BotFather, who prompts you for a display name and a unique username ending with "bot." Once created, you'll receive a token, which is essential for the bot to communicate with Claude Code.
After setting up the bot, you need to install the Telegram plugin in your Claude Code session. Use the command `/plugin install telegram@claude-plugins-official`, followed by `/reload-plugins`. Next, configure the server with the bot token by running the command `/telegram:configure` and inputting the token. This step is critical as it writes the token to the appropriate environment file. To handle multiple bots, ensure you set the `TELEGRAM_STATE_DIR` to different directories for each instance. Relaunch the session with the channel flag to establish the connection.
Once your session is active, you can pair your bot by sending it a direct message on Telegram. The bot will reply with a 6-character pairing code. Use this code in your Claude Code session with the command `/telegram:access pair <code>`. This process allows the bot to identify your user ID without requiring numeric IDs. For security, it's recommended to switch to an allowlist policy after pairing to prevent unauthorized access. The bot can then reply to messages, add emoji reactions, and edit its own previous messages. Inbound messages trigger a typing indicator, but the bot can't access message history or fetch earlier messages, meaning it relies on real-time communication.
Questions about this article
No questions yet.