一句話結論
setChatMenuButton 只設定聊天輸入框左側選單按鈕(commands / web_app / default),不會建立或移除右側 Reply Keyboard。省略 chat_id 為全域預設;帶 chat_id 時覆寫已與 Bot 互動過的私訊。
總覽
輸入框左右是兩套獨立控件:左側 Menu Button(本文)與右側 Reply Keyboard 切換(見底部自訂鍵盤指南)。參數級權威以 core.mp.net/bots 為準。
左側選單 vs 右側 Reply Keyboard
左側 — Menu Button:用
setChatMenuButton/getChatMenuButton。類型:commands、web_app、default。右側 — Reply Keyboard:只能透過訊息
reply_markup(ReplyKeyboardMarkup/ Remove)下發。選單 API 不會展開或隱藏它。改一側不會影響另一側。
類型:commands / web_app / default
type | 效果 |
| 左側展示 Bot 指令清單。 |
| 左側展示帶文案的按鈕,點擊開啟 HTTPS URL(text + |
| 清除該作用域的顯式覆寫(省略 |
同一作用域下 commands 與 web_app 互斥。
作用域:省略 chat_id vs 私訊 chat_id
省略
chat_id:設定該 Bot 的全域選單。帶
chat_id:必須是已與本 Bot 互動過的私訊,對該會話覆寫。用
getChatMenuButton回讀(作用域規則相同)。回傳值不會描述右側 Reply Keyboard 是否可見。
web_app:任意 HTTPS ≤ 2048
以官方為準(覆蓋 PRD 表述)
Menu Button 的 web_app 接受 text 加上任意合法 HTTPS URL(最長 2048)。不要求本 Bot 已登記 MiniApp、不要求 MiniApp ID。(內嵌鍵盤 / Reply Keyboard 的 web_app 歸屬規則另論,勿照搬到這裡。)
按鈕文案
text最長 64。URL 必須是 HTTPS。
BotFather 路徑(簡述)
也可在 BotFather 的 Bot「選單按鈕 / Menu Button」設定裡配置左側選單。與 setChatMenuButton 控制的是同一側控件;需要依會話覆寫或自動化時優先用 API。
最小請求範例
POST https://call.mp.net/bot/bot<token>/setChatMenuButton
{
"menu_button": {
"type": "web_app",
"text": "Open App",
"web_app": { "url": "https://example.com/app" }
}
}
相關
底部自訂鍵盤:下發、切換、一次隱藏與移除(本欄目)
核心訊息方法詳解:getMe、getUpdates、sendMessage(reply_markup)
