Telegraf: wait for a user reply and use it right after

Viewed 1180

I would like my bot to wait for a user's message after he entered a specific command and then use it like this:


const { Telegraf } = require('telegraf')
const app = new Telegraf(process.env.BOT_TOKEN);

app.command('request', async(ctx) => {
   ctx.reply("Hi user, what is your request?");
   //Wait for the user response and use it
   ctx.reply("Your answer was: ${user_answer}");
});

1 Answers

You need to use a callback_query like the code below.

   app.on('callback_query', async (ctx) => {
    ctx.reply(`Your answer was: ${ctx.update.callback_query.data}`);
   })
Related