Skip to main content
Glama

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
NameRequiredDescriptionDefault
callback_query_idYes
textNo
show_alertNo

Implementation Reference

  • 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))

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Py2755/aiogram-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server