摘要
通过 Telegram Bot API,从任意 AI 代理发送 Telegram 消息、照片、相册、文档、音频、视频、动画、贴纸、联系人、地点、位置和投票。33 个工具,使用机器人令牌认证。以发送为主,另可轻量读取最近的更新(不使用长轮询)。
引导式设置
2 分钟将 Telegram Bot 连接到 Claude、ChatGPT 或 Copilot
开始 AnythingMCP Cloud 免费试用,在引导式设置中连接 Telegram Bot,再把你的 MCP URL 添加到你的 AI 助手。无需代码,也无需自行运行服务器。
无需信用卡 · 7 天试用 · 提供自托管方案
试试这样问
Telegram Bot 的示例提示
点击任意提示即可复制,然后粘贴到 Claude、ChatGPT、Cursor、Gemini、Copilot 或 OpenClaw 中,在该连接器上运行。
Claude 是 AI,可能会出错。请核对回答。
💡 无需安装? 直接使用 cloud.anythingmcp.com。 登录、点击 Connectors → Telegram Bot、粘贴凭证、生成 MCP API key,即可完成。无 Docker、无
git clone、无本地服务器。
Telegram Bot
通过 Telegram Bot API,从任意 AI 代理发送 Telegram 消息、照片、相册、文档、音频、视频、动画、贴纸、联系人、地点、位置和投票。33 个工具,使用机器人令牌认证。以发送为主,另可轻量读取最近的更新(不使用长轮询)。
设置
- 在 Telegram 中打开与 @BotFather 的对话,发送
/newbot,然后设置显示名称和以bot结尾的用户名。 - BotFather 会回复一个类似
123456789:ABCdef...的令牌。请把它当作密钥保管:任何拿到它的人都能以你的机器人身份发送消息。 - 将完整令牌粘贴到
TELEGRAM_BOT_TOKEN,然后安装连接器。Telegram 要求令牌出现在请求地址中,连接器会自动帮你放进去。 - 先运行
telegram_bot_get_me,确认令牌可用。
机器人能联系谁:每个聊天都有一个数字 chat_id。用户必须至少给你的机器人发送过一次 /start,群组和频道则需要先把机器人加进去。公开频道也接受 @channelusername;私有频道需要数字 id,以 -100 开头。telegram_bot_get_updates 会显示最近收到的消息及其 chat id。
能发送什么:文本消息(HTML 格式最稳妥)、照片、相册、文档、音频文件、语音消息、视频、GIF 动画、贴纸、联系人名片、地点、位置(包括实时位置)以及投票或测验。它还可以编辑和删除自己发出的消息,并读取聊天详情。
相册:telegram_bot_send_album 可将 2 到 10 张照片和视频作为一条分组消息发送,也可发送 2 到 10 个文档或 2 到 10 个音频文件;文档和音频不能与其他类型混合。说明文字放在第一项上。如果 Telegram 对某一项报告 WEBPAGE_CURL_FAILED,说明它无法下载该文件:链接必须公开,并直接指向文件本身,而不是网页。
文件:媒体通过 HTTPS 链接发送(照片最大 5 MB,其他文件最大 20 MB),或使用之前发送过的内容的 file_id。不支持在同一次调用中从你的电脑上传文件。
表情回应、置顶和聊天管理:机器人可以用表情回应一条消息,并修改它发送的照片、视频或文档的说明文字。在机器人作为管理员并拥有相应权限(置顶消息、修改聊天信息、邀请用户、管理话题)的群组和频道中,它可以置顶和取消置顶消息、重命名聊天、修改聊天简介、创建额外的邀请链接(可命名、设有效期或限制加入人数),并在论坛群组中创建话题。它还可以把现有图片打包成一个归用户所有的新贴纸集,并继续添加贴纸。telegram_bot_get_webhook_info 显示机器人是否设置了 webhook;设置了 webhook 时,telegram_bot_get_updates 会返回 409 Conflict。telegram_bot_remove_webhook 用于删除 webhook,安装时默认关闭,因为删除后接收 webhook 的服务(聊天机器人、自动化流程)将不再收到消息:请在连接器页面上有意开启它;每次更改前 AI 都会先询问你。
已经安装过? 之前安装的连接器可通过目录更新获得新工具:在 AnythingMCP 中打开该连接器,在 Catalog update available 下查看新工具列表,然后点击 Apply update。你的机器人令牌和你自己添加的工具保持不变,telegram_bot_remove_webhook 添加后为关闭状态,与新安装时一致。
速率限制:不同聊天之间每秒约 30 条消息,同一聊天每秒 1 条,同一群组每分钟 20 条。遇到 429 时,Telegram 会告知需要等待多久。
连接器只在被要求时读取最近的更新,不会运行自动回复的聊天机器人,那需要你自己托管的 webhook。不支持支付、内联模式和游戏。
前提条件: TELEGRAM_BOT_TOKEN
本地安装连接器
curl -fsSL https://raw.githubusercontent.com/HelpCode-ai/anythingmcp/main/docker-compose.quickstart.yml -o docker-compose.yml
printf 'JWT_SECRET=%s\nENCRYPTION_KEY=%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
docker compose up -d
打开 http://localhost:3000/connectors/store,选择 Telegram Bot 并填入前提条件中列出的环境变量。
可用工具
| Tool | What it does |
|---|---|
telegram_bot_get_me | Return the bot's own user info: id, username, first_name, can_join_groups, can_read_all_group_messages, supports_inline_queries |
telegram_bot_send_message | Send a text message to a chat |
telegram_bot_send_photo | Send a photo (JPG/PNG, ≤5MB via URL) by HTTPS URL or by reusable file_id |
telegram_bot_send_document | Send a document (any type, ≤20MB via URL) by HTTPS URL or file_id |
telegram_bot_send_audio | Send an audio file (MP3, M4A, ≤20MB via URL) |
telegram_bot_send_voice | Send a voice note (OGG-Opus encoded) |
telegram_bot_send_video | Send a video (MP4, H.264, AAC, ≤20MB via URL) |
telegram_bot_send_location | Send a location point |
telegram_bot_send_poll | Send a poll (regular or quiz) |
telegram_bot_edit_message_text | Edit the text of a previously-sent message (your bot's own messages only) |
telegram_bot_delete_message | Delete a message the bot sent (within ~48 hours for groups, anytime for own DMs) |
telegram_bot_get_chat | Fetch chat info: title, type (private/group/supergroup/channel), photo, description, invite_link, member_count, permissions |
telegram_bot_get_updates | Long-poll recent inbound messages (one-shot: pulls all updates since the last offset+1) |
telegram_bot_send_album | Send 2 to 10 photos or videos as one album (sendMediaGroup), or 2 to 10 documents, or 2 to 10 audio files; documents and audio cannot be… |
telegram_bot_send_animation | Send a GIF or a silent MP4 animation by HTTPS URL or file_id; Telegram plays it on a loop |
telegram_bot_send_sticker | Send a sticker by file_id (any sticker the bot has seen, e.g. from telegram_bot_get_updates) or by HTTPS URL of a .WEBP image |
telegram_bot_send_contact | Send a phone contact card that the recipient can save or call |
telegram_bot_send_venue | Send a venue: a map pin with a name and address, e.g. a shop or meeting point |
telegram_bot_get_file | Look up a file the bot received (photo, document, voice note, video) by its file_id, from a message in telegram_bot_get_updates |
telegram_bot_download_file | Download a file by the file_path telegram_bot_get_file returned |
telegram_bot_fetch_sticker_set | Read a sticker set (or custom emoji set) by its name: title, sticker_type (regular, mask, custom_emoji) and every sticker with its emoji… |
telegram_bot_react_to_message | Set the bot's reaction on a message (the emoji under a message), or remove it with an empty list |
telegram_bot_pin_message | Pin a message in a chat, so it shows at the top |
telegram_bot_unpin_chat_message | Unpin a pinned message in a chat; without message_id the most recently pinned message is unpinned |
telegram_bot_rename_chat | Change the title of a group, supergroup or channel (1 to 128 characters); not possible for private chats |
telegram_bot_update_chat_description | Change the description of a group, supergroup or channel (0 to 255 characters; empty removes it) |
telegram_bot_add_forum_topic | Create a topic in a forum supergroup (a group with topics enabled) |
telegram_bot_edit_message_caption | Edit the caption of a photo, video, document, audio or animation message the bot sent (an empty caption removes it) |
telegram_bot_create_chat_invite_link | Create an additional invite link for a group, supergroup or channel, optionally named, expiring, limited to a number of joins, or requiring… |
telegram_bot_create_sticker_set | Create a new sticker set owned by a user, with 1 to 50 first stickers from existing image files |
telegram_bot_extend_sticker_set | Add one sticker to a sticker set the bot created (telegram_bot_create_sticker_set) |
telegram_bot_get_webhook_info | Show whether the bot has a webhook: its url (empty when none), pending_update_count, the last error date and message, and allowed_updates |
telegram_bot_remove_webhook | Remove the bot's webhook so updates can be read with telegram_bot_get_updates again |
示例提示
- “把这四个链接里的照片作为一个相册发到我们的团队频道,说明文字写‘新系列,今日上线’。”
- “在销售群里发一个投票:季度回顾安排在周二还是周四?”
- “把我们店的地址作为地点发到客户聊天里,方便他们在地图应用中打开。”
- “给我看看机器人在过去一小时收到的消息,以及是谁发的。”
- “在客户群里置顶节假日营业时间的那条消息,并给它点个赞。”
- “为测试群创建一个邀请链接,周五过期,最多允许 50 人加入。”
下一步
这份指南对你有帮助吗?