skip to Main Content

I have used dialogflow for telegram bot. Now I need to remove or delete after a user clicks on the button.
Here my custom payload code

{
  "telegram": {
    "text": "🛒 STOREnn💵 BANK ACCOUNTS 💵",
    "parse_mode": "HTML",
    "reply_markup": {
      "inline_keyboard": [
        [
          {
            "text": " LOG, PASS, ACC, ROUT",
            "callback_data": "REFUND POLICY"
          }
        ],
        [
          {
            "text": " AUSTRALIAN BANKS",
            "callback_data": "REFUND POLICY"
          }
        ],
        [
          {
            "text": "Back",
            "callback_data": "Store"
          }
        ]
      ]
    }
  }
}

Please check sceer shot
enter image description here

when a user clicks on back button need to remove the inline keyboard

I’ve tried “hide_keyboard: true”

But it didn’t work.

2

Answers


  1. There is no hide_keyboard option in Telegram bot API. The ReplyKeyboardRemove method is present, but it is used for hiding reply keyboards, not inline keyboards like yours.


    There is no explicit hide method for inline keyboards in Telegram bot API. You can either change previously sent keyboard or simply delete message which contains keyboard.

    To change inline keyboard of sent message, use editMessageReplyMarkup method. Just provide a new version of inline keyboard in reply_markup parameter, which will replace the current one.

    To delete the entire message use deleteMessage method.

    Login or Signup to reply.
  2. You can simply use something like this:

    def button(update: Update, context: CallbackContext):
        query = update.callback_query
        query.answer()
        query.edit_message_text(text=f"Selected option: {query.data}")
    

    Also don’t forget to add CallbackQueryHandler in main function:

    updater.dispatcher.add_handler(CallbackQueryHandler(button))
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search