Closed lucasansei closed 6 years ago
We have a lot of approaches using state to achieve step control. How about this one:
bot.setInitialState({
step: 1,
});
bot.onEvent(async context => {
switch (context.state.step) {
case 1:
// ...do something in step 1
context.setState({ step: context.state.step + 1 });
break;
case 2:
// ...do something in step 2
context.setState({ step: context.state.step + 1 });
break;
case 3:
// ...do something in step 3
break;
}
});
Thanks! This worked perfectly!
Hi, Sir @chentsulin. I'm new to Bottender.js. I've successfully created a simple Messenger chatbot using Express.js (+ngrok) with MongoDB database, but I have a little problem. How I can make a multi-step conversation flow in Bottender 1.4? I've tried use state, but still stucked. Thanks in advance.
Hi @LintangWisesa, you can find some latest examples there using the bottender-proposal-conversation module to make multi-step conversations. You may try and see if it works in your use case.
Great, thanks Sir @chentsulin
Can someone give me an example on how to build a multi-step conversation flow?