Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Telegram bot API: Can I mix a custom keyboard and a force_reply?

Tags:

telegram-bot

I have a custom keyboard but to process the answer i need a force reply so i get the question back in the next message. I have done this:

var opts = {
    reply_markup: JSON.stringify({ 
        keyboard: [['OK','Cancel']],
        one_time_keyboard: true,
        resize_keyboard: true,
        force_reply: true
    })
};

The keyboard works but not the force_reply. Force reply on its own works? Can i not use it in combination with a custom keyboard?

like image 507
Peter Newman Avatar asked Jul 18 '15 21:07

Peter Newman


1 Answers

It may be late to help you, but here it goes.

Currently only one reply_markup field is allow and this field must contain only one of the following types: ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply (see docs)

In any case, you can use ReplyKeyboardMarkup that will pop up a custom keyboard in the user app directly and code your bot so it only accept one of the answer in your own custom keyboards.

Furthermore, if you really want to force that the user reply, you can keep sending the same ReplyKeyboardMarkup after each user's invalid answer.

like image 108
Ruben Bermudez Avatar answered Oct 27 '22 10:10

Ruben Bermudez