Keyboards & Interactive Elements¶
CodeMeet supports interactive keyboards to simplify user inputs and navigation:
1. Inline Keyboards (InlineKeyboardMarkup): Buttons embedded directly underneath message bubbles that send instant callback queries or open URLs.
2. Reply Keyboards (ReplyKeyboardMarkup): Custom buttons rendered in place of the user's software keyboard.
3. Remove Keyboards (ReplyKeyboardRemove): Hides the custom reply keyboard.
4. Force Reply (ForceReply): Prompts the user to reply directly to the bot's message.
1. Inline Keyboards (InlineKeyboardMarkup)¶
Inline keyboards are passed as a reply_markup object when sending or editing messages.
Structure of InlineKeyboardButton¶
Each button must have a text property and exactly one action field:
| Field | Type | Description |
|---|---|---|
text |
String |
Label text rendered on the button (up to 128 characters). |
callback_data |
String |
Data delivered to your bot via callback_query updates (1–64 UTF-8 bytes). |
url |
String |
URL opened when the user clicks the button (https://, http://, or codemeet://). |
switch_inline_query |
String |
Switches the chat into inline query mode. |
/// note | Grid Dimensions - Maximum rows: 100 rows per keyboard. - Buttons per row: 1 to 8 buttons. ///
Example Inline Keyboard¶
{
"chat_id": "e9b2a1c0-4411-4fa3-9f88-d4508671b122",
"text": "Please choose an action:",
"reply_markup": {
"inline_keyboard": [
[
{"text": "Confirm Order", "callback_data": "order_confirm_102"},
{"text": "Cancel", "callback_data": "order_cancel_102"}
],
[
{"text": "View Invoice Online", "url": "https://example.com/invoice/102"}
]
]
}
}
2. Responding to Button Clicks (answerCallbackQuery)¶
When a user clicks a button with callback_data, the client shows a loading state and an update.callback_query event is generated. The bot must respond via answerCallbackQuery to dismiss the loading spinner and optionally show a toast or alert modal:
Parameters¶
| Parameter | Type | Status | Description |
|---|---|---|---|
callback_query_id |
String |
Required | Unique query ID from update.callback_query.id. |
text |
String |
Optional | Text notification displayed to the user (up to 200 characters). |
show_alert |
Boolean |
Optional | If true, shows a modal alert dialog instead of a small notification banner. |
url |
String |
Optional | URL to open on client. |
cache_time |
Integer |
Optional | Cache duration in seconds. |
Request Example¶
{
"callback_query_id": "a90f12d83b4c",
"text": "Order confirmed successfully!",
"show_alert": true
}
3. Custom Reply Keyboards (ReplyKeyboardMarkup)¶
Renders interactive buttons in place of the standard text input:
{
"chat_id": "e9b2a1c0-4411-4fa3-9f88-d4508671b122",
"text": "Main Navigation:",
"reply_markup": {
"keyboard": [
[
{"text": "My Profile"},
{"text": "Orders"}
],
[
{"text": "Settings"},
{"text": "Support"}
]
],
"resize_keyboard": true,
"one_time_keyboard": false
}
}
4. Removing Reply Keyboards (ReplyKeyboardRemove)¶
Removes the custom keyboard from the user's interface: