save_prepared_keyboard_button()

async Client.save_prepared_keyboard_button()

Store a keyboard button that can be used by a user within a Mini App.

Stores a keyboard button with type requestPeer or requestWebView that a Mini App user can use. The stored result can be retrieved by the user using the web_app_send_prepared_message Web App event.

Note

This is a Bot API concept that maps to the same MTProto endpoint as save_prepared_inline_message(). The button must be an InputBotInlineResult object that wraps the keyboard button content.

Usable by Users Bots
Parameters:
  • user_id (int | str) – Unique identifier (int) or username (str) of the Mini App user to whom the web_app_send_prepared_message event will be sent.

  • button (KeyboardButton) – A keyboard button object of type keyboardButtonRequestPeer or keyboardButtonSimpleWebView to prepare.

Returns:

BotPreparedInlineMessage – The prepared message object containing an id and expiration date.

Example

from pyrogram.raw.types import KeyboardButtonRequestPeer, RequestPeerTypeUser

button = KeyboardButtonRequestPeer(
    text="Pick a user",
    button_id=1,
    peer_type=RequestPeerTypeUser(),
    max_quantity=1,
)
prepared = await app.save_prepared_keyboard_button(user_id=user_id, button=button)