I want to develop a guessing game using botkit.
The game is easy, guess a number from 0-100. And users have infinite chance to make a guess
The bot will keep ask the user until they get it.
the code is like
bot.startConvo((convo)=>{
convo.ask('what is your guess?',(response)=>{
if(guess==answer){
convo.say('congrat'); convo.stop();
} else {
convo.ask('what is your guess?',(response)=>{...}
}
}
}
You can imagine the infinite callback pyramid is coming.
How should i implement chatflow like this using botkit.
Check out passing an array of callbacks to convo.ask()
You can use threads to move between asking for user input and success state. A non-success answer could send a "Nope that's not it" message and then run convo.repeat to ask again and wait for input
true. thread did solve this situation.
One more question, what if I want to queue some question in series. Like I want to ask 10 questions in sequence. Do I build up 10 thread to solve it or I can have a more convenient API to do so?
Interested in the answer to @wingliu0 question
Here is a simple example.
This example assumes you want to ask however many questions all in a row, without branching logic like "if user says NO then go to NO thread", which would be done the same way but with an array of callbacks as shown in the link above.
A more convenient way to build conversations is to do so visually using a Content Management System like studio.botkit.ai which is in beta right now.
@jonchurch I just applied for studio.botkiti.ai
lets see what can it do!
Most helpful comment
Here is a simple example.
This example assumes you want to ask however many questions all in a row, without branching logic like "if user says NO then go to NO thread", which would be done the same way but with an array of callbacks as shown in the link above.
A more convenient way to build conversations is to do so visually using a Content Management System like studio.botkit.ai which is in beta right now.