Provisions the keypad menus for a chat.
💡 This replaces the chat's entire menu set. To change one button, resend every menu you want the chat to keep.
method is "setChatMenu".
| Field | Type | Required | Description |
|---|---|---|---|
menus |
Array of Menu | Yes | The complete menu set for the chat. For chat menus the only supported cell form is "button". |
chat_id |
String | Yes | The target chat or user id. |
app_id |
String | Yes | The app the chat belongs to. |
to_user_id |
String | Optional | Show the menu to one member only. Use inside a group or channel to respond to a single user. |
reference |
String | Optional | Your id for this request. Echoed back in the response. |
| Requirement | Why |
|---|---|
"Manage Chats" permission |
Needed to modify chats in the app. |
| Bot is admin or moderator in the chat | Menu provisioning is an admin action. |
| Field | Type | Returned | Description |
|---|---|---|---|
method |
String | Yes | "setChatMenu_ack" |
chat |
Chat | Yes | The chat the menus were applied to. |
app_id |
String | Yes | Echoed from the request. |
reference |
String | Optional | Echoed from the request. |
The acknowledgement confirms receipt only — button presses arrive later as menuCallback events.
The SDKs send the menu set as raw JSON, so build it as a JSON array and attach it to the out message.
| SDK | Call | Callback |
|---|---|---|
| Java | api.send(outMessage); after outMessage.setMenus(menus) |
onRecieving(JSONObject obj) |
| JavaScript | api.send(JSON.stringify(outmsg.toJsonObject())); |
onReceiveObj(obj) |
| Python | napi.send(obj) after obj, _ = out_msg.to_json_obj() |
on_receive_obj(self, obj) |
{
"method": "setChatMenu",
"chat_id": "90090684438172188",
"app_id": "90090684293000559",
"reference": "123456789",
"menus": [
{
"menu_id": "PBw7HmDu5FAWjFm",
"cat": "menu",
"menu_name": "First Menu",
"menu_group": "TgKB8yDHKv4ZBOc",
"menu_version": "04oTrLih73KeqCke",
"menu_order": 0,
"api_id": "90091783822039252",
"rows": [
{
"row_id": "r_bMCvsAZ5ZVkMx2C",
"row_order": 0,
"menu_id": "PBw7HmDu5FAWjFm",
"row_version": "FoLSTFJYg48eXrDp",
"cells": [
{
"cell_id": "b_BKwMwhIVbBFw634",
"form": "button",
"style": "filled",
"cell_order": 1,
"version": "7fOkiEWlDadvyOIE",
"callback": "b_BKwMwhIVbBFw634",
"label": "Save"
},
{
"cell_id": "b_b2ZRG1YmHStEPo5",
"form": "button",
"style": "tonal",
"cell_order": 1,
"version": "Gk4E9kpy4KG1yDij",
"callback": "b_b2ZRG1YmHStEPo5",
"label": "Delete"
}
]
},
{
"row_id": "r_DAetbJyRzpFUwSI",
"row_order": 1,
"menu_id": "PBw7HmDu5FAWjFm",
"row_version": "QU6FfL9gyHSAiw8m",
"cells": [
{
"cell_id": "b_oScCagIGQmaHjNQ",
"form": "button",
"style": "outlined",
"cell_order": 0,
"version": "dl609ppkJkkfRdUL",
"callback": "b_oScCagIGQmaHjNQ",
"label": "Cancel"
}
]
}
]
}
]
}
String menusJson = "[ ... the menus array shown above ... ]";
JSONArray menus = (JSONArray) new JSONParser(-1).parse(menusJson);
SetChatMenuOutMessage outMessage = new SetChatMenuOutMessage();
outMessage.setMenus(menus);
outMessage.setChatId("90090684438172188");
outMessage.setApp_id("90090684293000559");
outMessage.setReference("123456789");
api.send(outMessage);
const menusJson = "[ ... the menus array shown above ... ]";
let outmsg = new SetChatMenuOutMessage();
outmsg.menus = JSON.parse(menusJson);
outmsg.chat_id = "90090684438172188";
outmsg.appId = "90090684293000559";
outmsg.reference = "123456789";
api.send(JSON.stringify(outmsg.toJsonObject()));