logo
Use this message to provision a Menus within a Chat. Chat Menus, it must send the entire menus again to the target chat. This method will replace any existing chat Menu.

Field
Type
Required
Description
method
String
Yes
"setChatMenu"
app_id
String
Yes
Unique identifier for App.
chat_id
String
Yes
Unique identifier for the target Chat or User_id.
to_user_id
String
Optional
Unique identifier of the target user within a chat. Used to respond to user replies or send a message to a specific user within a chat Group or Channel. The message will be displayed to them only.
menus
Yes
An array of new menus to be provisioned in the chat. πŸ”Ή Note: For chatMenu, the currently supported cell form is "button" only.
reference
String
Optional
Unique identifier for the request. This reference will be echoed in the response.

Preconditions for API Functionality

The following table outlines the preconditions that must be met for the API to function correctly. Failure to meet these conditions may result in errors or unexpected behavior.
Condition
Description
API must have "Manage Chats" permission
The API needs "Manage Chats" permission to manage chats within the app.
API must be a moderator or an admin in the chat
The API requires admin privileges in the chat to execute view or creation actions.

Response:

setChatMenu_ack

βœ… "On success, the setChatMenu_ack method is returned to acknowledge the receipt of the chatMenu."
Let me know if you need further refinements! πŸš€
Field
Type
Returned
Description
method
String
Yes
"setChatMenu_ack"
app_id
String
Yes
Unique identifier for App.
chat
Yes
Chat Object.
reference
String
Optional
Unique identifier echoed from the request.

SDK Mapping β€” setChatMenu

SDK
Request Method
Response Callback
Java
SetChatMenuOutMessage outMessage = new SetChatMenuOutMessage(); String jsonString = "MENU JSON"; JSONParser parser = new JSONParser(-1); JSONArray menus = (JSONArray) parser.parse(jsonString); outMessage.setMenus(menus); outMessage.setChatId(chatId); outMessage.setApp_id(appId); outMessage.setReference(reference); api.send(outMessage);
onRecieving(JsonObject obj)
JavaScript
let outmsg = new SetChatMenuOutMessage(); let jsonString = "MENU JSON"; let menus = JSON.parse(jsonString); outmsg.menus=menus; outmsg.chat_id= chat_id; outmsg.appId =appId outmsg.reference = reference api.send(JSON.stringify(outmsg));
onReceiveObj(obj)
Python
json_string = "MENU JSON" decoder = json.JSONDecoder() menus, _ = decoder.raw_decode(json_string) out_msg = SetChatMenuOutMessage() out_msg.menus = menus out_msg.chat_id = chat_id out_msg.app_id = app_id out_msg.reference = reference napi.send(out_msg)
on_receive_obj(self, obj)

Requests

json
{ "method": "setChatMenu", "chat_id": "90090684438172188", "menus": [ { "menu_id": "PBw7HmDu5FAWjFm", "cat": "menu", "menu_name": "First Menu", "menu_group": "TgKB8yDHKv4ZBOc", "menu_version": "04oTrLih73KeqCke", "menu_order": 0, "rows": [ { "row_id": "r_bMCvsAZ5ZVkMx2C", "row_order": 0, "menu_id": "PBw7HmDu5FAWjFm", "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_version": "FoLSTFJYg48eXrDp" }, { "row_id": "r_DAetbJyRzpFUwSI", "row_order": 1, "menu_id": "PBw7HmDu5FAWjFm", "cells": [ { "cell_id": "b_oScCagIGQmaHjNQ", "form": "button", "style": "outlined", "cell_order": 0, "version": "dl609ppkJkkfRdUL", "callback": "b_oScCagIGQmaHjNQ", "label": "Cancel" } ], "row_version": "QU6FfL9gyHSAiw8m" } ], "api_id": "90091783822039252" } ], "app_id": "90090684293000559", "reference": "123456789" }
java
{ 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 }); outmsg.setApp_id(incomingMsg.getAppId()); api.send(outmsg); }
javascript
{let outmsg = new SetChatMenuOutMessage(); let chat_id = incomingMsg.chat.id; let buttons = []; buttons.push(menuBtn1); buttons.push(menuBtn2); buttons.push(menuBtn3); 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; outmsg.appId=incomingMsg.appId; api.send(JSON.stringify(outmsg)); }
python
{ 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] outMsg.app_id=incoming_msg.app_id napi.send(outMsg) }

Response

SetChatMenu Ack
json
{ "reference": "123456789", "method": "setChatMenu_ack", "chat": { "id": "90090684438172188" }, "app_id": "90090684293000559" }

Powered by Notaku