Skip to content
Mahdi Dibaiee edited this page Jul 3, 2015 · 1 revision

Question

Asks a question, and validates the answer.

The way it works under the hood:

  1. Sends a message with a keyboard taken from answers
  2. Waits for an answer from user, if in group, expects a reply
  3. Validates the answer, resolves if it's valid, else rejects

Here is the chainable method equivalent of each option:

  • answers => An array of arrays of strings, same as Keyboard keys option
  • to => chat_id
  • text => text
  • preview => disable_web_page_preview (The option is inversed, e.g. preview(false) will set the option to true, therefore disabling previews)
  • reply => reply_to_message_id
const q = new Question()
              .text('What type of music do you prefer?')
              .answers([['Rock'], ['Pop'], ['Hip-Hop']])
              .to(chat.id);

bot.send(q).then(message => {
  console.log('Valid Answer:', message.text);
}, message => {
  console.log('Invalid:', message.text);
});
Clone this wiki locally