'How to remove (not to hide) ReplyKeyboardMarkup in Telegram.Bot using C#?

I'm using Telegram.Bot library in C# for developing telegram bots.

I post a text message using SendTextMessageAsync() method and sent a Keyboard with it :

bot.SendTextMessageAsync(chatId, "sample msg", ParseMode.Default, false, false, 0, new InlineKeyboardMarkup(keyboardData));

I want to remove (not to hide) the keyboard, after click of any user on one of the keyboard buttons, so I use this instruction :

int msgId = bot.SendTextMessageAsync(chatId, "sample msg", ParseMode.Default, false, false, 0, new InlineKeyboardMarkup(keyboardData)).Result;
...
bot.EditMessageReplyMarkupAsync(chatId, msgId, new ReplyKeyboardRemove());

But it doesn't work. Please help me about it.

Meanwhile if I set oneTimeKeyboard to true in ReplyKeyboardMarkup, the keyboard will be hide after user click, but it doesn't removed, only it will be hide and user can make it visible using keyboard button of telegram.



Solution 1:[1]

I'm afraid, it's too late, but you can use ReplyKeyboardRemove

var send = new SendMessage(update.Message.Chat.Id, "your_text")
{
    ReplyMarkup = new ReplyKeyboardRemove() { RemoveKeyboard = true }
};
await bot.MakeRequestAsync(send);

Solution 2:[2]

You can use ReplyKeyboardRemove method to do that.

Solution 3:[3]

Maybe this will help someone.

new TelegramBotClient("<token>").SendTextMessageAsync(chat_id, text, replyMarkup: new ReplyKeyboardRemove());

Solution 4:[4]

It works for me :

public async Task RemoveRequestContactButton(string chatId, string text)
        {
            var tgBot = GetClient();
            await tgBot.SendTextMessageAsync(chatId, text, replyMarkup: new ReplyKeyboardRemove()).ConfigureAwait(false);
        }

where function GetClient() returns TelegramBotClient;

Solution 5:[5]

For Python users, according to Sean`s comment (telegram documentation):

    import telebot
    bot = telebot.TeleBot('YOUR TELEGRAM API CODE HERE')
    bot.send_message(message.chat.id, text="YOUR MESSAGE HERE", reply_markup=telebot.types.ReplyKeyboardRemove())

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mehdi Khademloo
Solution 2 Sean
Solution 3 StelX
Solution 4 PhiseySt
Solution 5