I’m working on a Telegram bot and facing an issue with keyboard management. Here’s what I’m trying to achieve:
Current workflow:
First, I send a message containing ReplyKeyboardMarkup with some options (like ["Accept", "Decline"])
When the user taps a button (say “Accept”), I need to show a new message that has an inline keyboard while simultaneously removing the custom keyboard from step 1
The problem: Each message can only have one reply_markup parameter, which means I can either use InlineKeyboardMarkup or ReplyKeyboardRemove, but not both at once.
Right now my only option seems to be sending two separate messages - one to remove the keyboard and another with the inline keyboard. However, this creates a poor user experience since users see multiple messages.
I’m fine with making multiple API calls if needed, but I want only one message to be visible to the user in the end. Has anyone found a clean solution for this scenario?
there’s another approach - send a message with your inline keyboard and set reply_markup to ReplyKeyboardRemove in a dummy message, then quickly delete it. it’s hacky but works. or just go with the two-message flow and delete the first one after sending the second - users won’t notice if you’re quick enough.
Send the inline keyboard message first, then immediately use deleteMessage on the original custom keyboard message. Users only see the final result that way. Or you can use editMessageReplyMarkup to swap the ReplyKeyboardMarkup with ReplyKeyboardRemove, then send your inline keyboard separately. Both methods hide the custom keyboard while keeping your inline buttons - no messy chat. I prefer deleting the original message since it cuts down visual clutter.
Been there! Here’s what works for me: send your inline keyboard message first, then quickly edit the previous message to include ReplyKeyboardRemove in the reply_markup. This kills the custom keyboard but keeps your new inline message clean. Or just edit the original message completely - swap out the text and change ReplyKeyboardMarkup to InlineKeyboardMarkup using editMessageText. Everything stays in one thread and feels way smoother. The trick is you don’t need new messages for everything. Edit existing ones and remove old keyboards - gives you control without spamming the chat.