@frogbotai/piece-telegram-bot

中文文档
0.42.0发布于 2026/11/15MITTypeScriptES Module近 30 天下载 2940

telegram-bot tools for FrogBot.

原始使用文档
文档目录4 节
  1. Usage
  2. Setup
  3. Actions
  4. Triggers

@frogbotai/piece-telegram-bot

Send Telegram Bot API requests and receive bot updates through FrogBot.

Usage

import { createTelegramBot } from '@frogbotai/piece-telegram-bot';

export const telegramBot = createTelegramBot({
  auth: { botToken: process.env.TELEGRAM_BOT_TOKEN! },
  webhookSecret: process.env.TELEGRAM_WEBHOOK_SECRET!,
  botUsername: 'frogbot',
});

Setup

  1. Create a bot with BotFather and copy its bot token.
  2. Choose a webhook secret containing only letters, numbers, underscores, or hyphens. Keep it private.
  3. Register https://<your-host>/api/webhooks/<piece-instance-slug> with Telegram's setWebhook method and pass the same value as secret_token.
  4. Add message, edited_message, channel_post, edited_channel_post, and callback_query to allowed_updates. Add any other update types used by newUpdate.
  5. Disable privacy mode with BotFather when the bot must receive ordinary group messages. Add the bot to each group or channel with the permissions needed to read and reply.
  6. Mount the instance in the agent's channels: [telegramBot] and explicitly configure the agent's access callback to permit the intended anonymous participants.

Telegram does not use a webhook challenge handshake. FrogBot verifies every delivery with the X-Telegram-Bot-Api-Secret-Token header. Set allowedUserIds to restrict channel conversations to known Telegram user IDs; omitted or empty values allow every Telegram user to reach the bot, subject to your FrogBot agent access rules.

Allowlisting does not authenticate a FrogBot user. Telegram channel identity always returns null, so default agent access denies even allowlisted users. For an intentionally public agent, access: () => true permits anonymous use on every agent entry point. For restricted access, use a callback that checks the intended channel and participant through req.context.channel; keep allowedUserIds configured as the Telegram-side filter.

Telegram permits one webhook per bot token. The channel adapter and newUpdate share the instance webhook above; do not register a separate subscription URL. Direct messages, groups, and each forum topic remain separate conversations.

The Start button (/start) and other direct-message commands reach the agent with their command text and arguments intact. Group commands addressed to @<botUsername> use the same mention and conversation routing as ordinary messages.

Actions

Upstream action slugPrevious wrapper exportNative actionNotes
send_text_messagesendTextMessagesendTextMessage
send_mediasendMediasendMediaAccepts a Telegram file ID or URL.
send_documentsendDocumentsendDocumentAccepts a Telegram file ID or URL.
send_audiosendAudiosendAudioAccepts a Telegram file ID or URL.
send_locationsendLocationsendLocation
send_media_groupsendMediaGroupsendMediaGroupAccepts Telegram file IDs or URLs.
send_pollsendPollsendPoll
send_chat_actionsendChatActionsendChatAction
edit_message_texteditMessageTexteditMessageText
delete_messagedeleteMessagedeleteMessage
forward_messageforwardMessageforwardMessage
pin_messagepinMessagepinMessage
unpin_messageunpinMessageunpinMessage
get_chatgetChatgetChat
get_chat_membergetChatMembergetChatMember
get_filegetFilegetFileReturns Telegram file metadata.
create_invite_linkcreateInviteLinkcreateInviteLink
answer_callback_queryanswerCallbackQueryanswerCallbackQuery
custom_api_callcustomApiCallcustomApiCall

Triggers

Upstream trigger slugNative triggerTypeNotes
new_telegram_messagenewUpdateappFilters update types received by the shared channel webhook.

版本与发布记录

@frogbotai/piece-telegram-bot 共发布 38 个版本,首次发布于 2026/07/27;过去 12 个月发布了 38 个版本。

版本发布日期距今
0.42.0latest2026/11/15今天
0.41.02026/11/097 天前
0.40.02026/11/069 天前
0.39.02026/11/0213 天前
0.38.02026/11/0115 天前
0.37.02026/10/2917 天前

关于 @frogbotai/piece-telegram-bot 的常见问题

@frogbotai/piece-telegram-bot 是什么?

telegram-bot tools for FrogBot.

如何安装 @frogbotai/piece-telegram-bot?

在项目目录运行 npm install @frogbotai/piece-telegram-bot,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:frogbot(0.42.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@frogbotai/piece-telegram-bot 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@frogbotai/piece-telegram-bot 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@frogbotai/piece-telegram-bot 可以商用吗?

@frogbotai/piece-telegram-bot 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@frogbotai/piece-telegram-bot 的下载量有多少?

根据 npm 官方下载统计,@frogbotai/piece-telegram-bot 在 2026/10/16 – 2026/11/14 这 30 天内被下载 2,940 次,日均约 98 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@frogbotai/piece-telegram-bot 还在维护吗?

最新版本 0.42.0 发布于 2026/11/15(今天);至今共发布 38 个版本,其中过去 12 个月发布了 38 个;首次发布于 2026/07/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。