I would like to wait for the user to send a message, then assign the new message to a variable.
How can I wait for a message reply using Telegraf on Node.js?
const Telegraph = require("telegraf");
const APIKEY = 'LADLADJLDAKJLAK;LAKS;LSAKLDA,MDALJDALJLDAJLDAJLDAJDALDAJLADJ'
const bot = new Telegraph(APIKEY);
const loginMessage = `
PLEASE ENTER YOUR EMAIL:
`;
bot.command("login", (ctx) => {
ctx.reply("You Entered Login");
ctx.reply(loginMessage);//login message:Please Enter EMAIL
//wait for user to send message
//ASSIGN MESSAGE TO VARIABLE
});
bot.launch();
2
Answers
There are few ways:
"123" : "login_step"
and check state of user first.reply_markup
of sendMessage. And checkreply_to_message
for your commandYou should consider using Scenes. but not just a normal scene but use WizardScene for better usage especially since you want your bot to kind of have an interview-like thing with users to get their info. To store user data use Session. Out of the boxes its stores its data on memory I think to be able to persist your data even after restart use this telegraf-session.
Check out this tutorial it helped me out a lot How to build OCR Bot