answer_callback_query
Respond to inline keyboard button presses in Telegram bots by sending notifications to users, either as toast messages or alert popups.
Instructions
Answer a callback query from an inline keyboard button press.
Args: callback_query_id: ID of the callback query (from the event). text: Optional notification text shown to the user. show_alert: Show as alert popup instead of toast notification.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| callback_query_id | Yes | ||
| text | No | ||
| show_alert | No |
Implementation Reference
- aiogram_mcp/tools/interactive.py:220-242 (handler)Implementation of the 'answer_callback_query' tool, which wraps the aiogram bot's answer_callback_query method.
async def answer_callback_query( callback_query_id: str, text: str | None = None, show_alert: bool = False, ) -> AnswerCallbackResult: """Answer a callback query from an inline keyboard button press. Args: callback_query_id: ID of the callback query (from the event). text: Optional notification text shown to the user. show_alert: Show as alert popup instead of toast notification. """ try: if ctx.rate_limiter: await ctx.rate_limiter.acquire() await ctx.bot.answer_callback_query( callback_query_id=callback_query_id, text=text, show_alert=show_alert, ) result = AnswerCallbackResult(ok=True, callback_query_id=callback_query_id) except (TelegramBadRequest, TelegramForbiddenError) as exc: result = AnswerCallbackResult(ok=False, error=str(exc))