You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

node-telegram-bot-api频道添加Web App按钮报错400:BUTTON_TYPE_INVALID

问题解决:Telegram频道无法添加Web App按钮

核心原因

Telegram官方限制:Web App类型的内联按钮仅支持在私聊(一对一对话)和群组中使用,公开频道不允许使用该类型按钮,这就是你遇到BUTTON_TYPE_INVALID错误的直接原因。

解决方案

如果需要在频道中引导用户打开网页,改用普通的URL内联按钮即可,代码调整如下:

createTournament = async () => {
  const arrayButton = []
  // 将web_app替换为url字段
  arrayButton.push([{ text: "打开Google", url: "https://google.com" }])

  const options = {
    reply_markup: JSON.stringify({ inline_keyboard: arrayButton }),
    parse_mode: 'HTML',
  }
  await bot.sendMessage(idChanel, '点击按钮打开Google', options)  
}

补充说明

  • 你之前使用callback_data按钮正常,是因为该类型按钮在频道中是被允许的;
  • 若必须使用Web App功能,只能引导用户通过私聊机器人的方式触发,无法直接在频道消息中添加。

内容的提问来源于stack exchange,提问作者Андрей Гросу

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 19:17:34