I've created a bot using mysql+node.js+telegraf. I've also made use of stages,wizardscenes and steps. I'm using telegraf-mysql-session to store sessions.
Problem:
The problem I'm encountering is when a user enters the wrong input, example sends a text instead of selecting a button. The bot does not respond to inform the user that the wrong input has been inserted.
Could you please give me sample code/suggestions/links on how I could go about this.
What happens:
1.bot hears 'enter details' button and enters the scene.
2.Normally the user is expected to select a button to trigger the next step, but if the user enters a text like 'yes I would' the bot won't be able to move to next step thus not responding.
const startStep=new Composer()
startStep.hears("enter details",async(ctx)=>{
try{
await ctx.replyWithHTML("Hello, Would you like to proceed?",Markup.inlineKeyboard([
Markup.button.callback('Yes','okay'),
Markup.button.callback('No','cancel'),
]))
return ctx.wizard.next()
}
catch(e)
{
console.log(e)
}
})
const nextStep=new Composer()
nextStep.action("okay",async(ctx)=>{
try{
ctx.wizard.state.data={}
await ctx.replyWithHTML("Please enter your number")
return ctx.wizard.next()
}
catch(e)
{
console.log(e)
}
})
Desired outcome:
I would like for the bot to detect wrong input and give feedback telling user that the 'input is incorrect. select a button' The bot must not allow the user to proceed unless the 'back to main menu' button is selected.
if(user input ==correct)
{
//perform everything in the scene/step
}
else
{
ctx.reply(wrong input. Select button)
//ctx.wizard.back()
}
I would love for this to be available throughout entire bot process.
Your assistance would be highly appreciated