I
I
Ivan2019-06-22 20:03:19
JavaScript
Ivan, 2019-06-22 20:03:19

How to ask sequential questions in telegram bot?

How to implement a poll-dialogue? that is, I ask a question, the person answers briefly, perhaps only yes / no, and the bot continues to hang questions?

const Telegraf = require('telegraf');
    const bot = new Telegraf(...);

    bot.command('start', (ctx) => {
      ctx.reply("Привет, хочешь пообщаться?")
      bot.hears('Да', (ctx) => ctx.reply('Классно, слушай, а ты мальчик или девочка? Да/Нет'))
      bot.hears('Да', (ctx) => ctx.reply('Да/Нет'))
    })

    bot.launch();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dik_Nik, 2019-06-22
@Dik_Nik

Write a state machine

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question