Use this message to set normal keypad menus to Chat Menu. This message will overwrite the existing Chat Menus. If the bot wants to update a specific item in the Chat Menus, it must send the entire menus again to the target chat. On success, setChatMenu_ack will be returned.
Field
Type
Required
Description
method
String
Yes
"setChatMenu"
menus
Yes
New or updated Menus.
chat_id
String
Yes
Unique identifier for the target Chat or User_id.
to_user_id
String
Optional
Unique identifier of the target user will be displayed if the user replies or sends a message to the target user within a group Chat or Channel.

Requests

json
{ "method": "setChatMenu", "chat_id": "14568521459875552", "menus": [ { "menu_ref": "KEY1", "rows": [ { "row_order": "5", "buttons": [ { "next_menu": null, "button_span": "6", "button_order": "3", "button_textcolor": "black", "button_callback": "B2", "button_bgcolor": "white", "button_label": "32D", "button_url": "ffgt", "button_query": "kom" } ] } ] } ] }
java
// SEND CHAT MENU else if (incomingMsg.getText().toLowerCase().equals("chatmenu")) { String chatId = incomingMsg.getChat().getId(); new Utils().setNavigationButton(chatId, "mainMenu", api); Button menuBtn1 = createButton("Ų…ØĩØąØ§ŲˆŲŠ", "mainCB", 1, "Gray", "Red", null, null); menuBtn1.setButtonIcon("ic_smoke_free_24dp"); menuBtn1.setButtonIconBgColor("#00FFFF"); Button menuBtn2 = createButton("Funny", "funnyCB", 1, "Gray", "Red", null, null); menuBtn2.setButtonIcon("ic_timeline_24dp"); Button menuBtn3 = createButton("Option", "optionCB", 1, "Gray", "Red", null, null); menuBtn3.setButtonIcon("ic_pregnant_woman_24dp"); menuBtn3.setButtonIconBgColor("orange"); SetChatMenuOutMessage outmsg = new SetChatMenuOutMessage(); Row firstRow = new Row(); firstRow.setRowOrder(1); firstRow.setButtons(new Button[] { menuBtn1, menuBtn2, menuBtn3 }); Menu chatMenu = new Menu(); String menuRef = "mainMenu"; chatMenu.setMenuRef(menuRef); chatMenu.setRows(new Row[] { firstRow }); outmsg.setChatId(incomingMsg.getChat().getId()); outmsg.setMenus(new Menu[] { chatMenu }); api.send(outmsg); }
javascript
let outmsg = new SetChatMenuOutMessage(); let chat_id = incomingMsg.chat.id; Utility.setNavigationButton(chat_id, "mainMenu", api); let menuBtn1 = createButton( "No Smoking", "mainCB", 1, "Gray", "Red", null, null ); menuBtn1.button_icon = "ic_smoke_free_24dp"; menuBtn1.button_icon_bgcolor = "#00FFFF"; let buttons = []; buttons.push(menuBtn1); let rowOrder = 1; let firstRow = new Row(buttons, rowOrder); let rows = []; rows.push(firstRow); let menuRef = "mainMenu"; let chatMenu = new Menu(rows, menuRef); let menus = []; menus.push(chatMenu); outmsg.chat_id = incomingMsg.chat.id; outmsg.menus = menus; api.send(JSON.stringify(outmsg));
python
Utils.set_navigation_button(chatId, "mainMenu", napi) menuBtn1 = create_button(label="Ų…ØĩØąØ§ŲˆŲŠ", callback="mainCB", order=1, bg_color="Gray", txt_color="Red") menuBtn1.button_icon = "ic_smoke_free_24dp" menuBtn1.button_icon_bgcolor = "#00FFFF" menuBtn2 = create_button(label="Funny", callback="funnyCB", order=1, bg_color="Gray", txt_color="Red") menuBtn2.button_icon = "ic_timeline_24dp" menuBtn3 = create_button(label="Option", callback="optionCB", order=1, bg_color="Gray", txt_color="Red") menuBtn3.button_icon = "ic_pregnant_woman_24dp" menuBtn3.button_icon_bgcolor = "orange" outMsg = SetChatMenuOutMessage() firstRow = Row() firstRow.row_order = 1 firstRow.buttons = [menuBtn1, menuBtn2, menuBtn3] menuRef = "mainMenu" chatMenu = Menu() chatMenu.menu_ref = menuRef chatMenu.rows = [firstRow] outMsg.chat_id = chatId outMsg.menus = [chatMenu] napi.send(outMsg)

Responses

ChatMenuCallback
json
{ "method": "chatMenuCallback", "chatMenuCallback": { "date": 7456984123741, "button_callback": "VCB0", "next_menu": null, "button_query_result": null, "chat": { "id": "874125364412589741", "type": "Mobile" }, "from": { "id": "741254123980325800", "type": "Mobile" }, "menu_ref": "FourthMenu", "button_label": "Food" } }
SetChatMenu Ack
json
{ "method": "setChatMenu_ack", "chat": { "id": "4522291356145774" } }