Reputation: 6194
Hi I have a proactive quiz bot where I send a message every few hours and people get a chance to participate in the quiz. There are 2 ways to begin a dialog in node.js using the bot framework if I am not mistaken
bot.send()
bot.beginDialog()
The 1st one doesnt end the current dialog while the second one does. I want to give the user a question like What is 1500 + 450 and 4 choices 1800 1950 2500 3000 and start the dialog only if the person answers the question above. How can I do it without breaking the current dialog stack?
Upvotes: 0
Views: 567
Reputation: 2890
What you are asking for is basically not possible - Using proactive messages does not enable you to change the current context's call stack - It only enables you sending messages to the user.
The only way I would think about bypassing this is using middleware to intercept messages and decide if you should change the callstack or not (using beginDialog).
This is also not optimal since you might have the following scenario: 1. Current call stack question: "How many years of experience do you have?" 2. Proactive prompt: "Choose an answer: 1) 1000. 2) 2000 etc.."
If the user types "2" which context is he referring to?
Maybe a good solution would be to ask the user to type "quiz answer: 2" which will enable you to intercept this message using middleware:
bot.use({
botbuilder: function (session, next) {
if (/^(quiz answer)/g.test(session.message.text)) {
session.beginDialog('/quizAnswer');
}
else {
next();
}
}
});
After the dialog /quizAnswer ends, it will return to the normal flow. Keep in mind, that even in that case - the user might not remember which context he was in, and you'll have a hard time trying to figure out what was the last message/prompt etc...
Maybe a better solution would be to have a separate bot for the quiz.
Upvotes: 1