Guides
Inline Keyboard
Attach buttons; clicks arrive as callback_query — answer them with answerCallbackQuery.
When to use
Show tappable buttons under a bot message. Clicks deliver callback_query. Use url / action for links or in-app navigation without a callback.
Steps
- Send/edit with
reply_markup.inline_keyboard. - Receive
callback_queryvia webhook or polling. - Call
answerCallbackQuery. Duplicate answers for the same id are idempotent success; invalid id →400.
Example
curl -X POST "$API/bots/sendMessage" \
-H "Authorization: Bearer $SOCHAT_BOT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"chat_id": "<chat_id>",
"text": "Pick one",
"reply_markup": {
"inline_keyboard": [[
{ "text": "OK", "callback_data": "ok" },
{ "text": "Docs", "url": "https://example.com/docs" }
]]
}
}'
curl -X POST "$API/bots/answerCallbackQuery" \
-H "Authorization: Bearer $SOCHAT_BOT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"callback_query_id":"<id>","text":"Done"}'
Limits & errors
- Max 8×8;
text1–64;callback_data≤64 UTF-8 bytes. - Each button: exactly one of
callback_data|url|action. - Missing answer may leave the client spinner; there is no server-side 5s deadline. Duplicate answer → idempotent success.
See Interactive APIs for full field lists.
