You can do this using a prompts.Choice. This will present the user with buttons for each option - the user can click them or type the response.
So, if you have a QnAMaker dialog defined ...
var recognizer = new cognitiveservices.QnAMakerRecognizer({
knowledgeBaseId: 'set your kbid here',
subscriptionKey: 'set your subscription key here'});
var basicQnAMakerDialog = new cognitiveservices.QnAMakerDialog({
recognizers: [recognizer],
defaultMessage: 'No match! Try changing the query terms!',
qnaThreshold: 0.3
});
bot.dialog('/QnAMakerDialogue', basicQnAMakerDialog);
You can switch to this dialog with replaceDialog, based on what the user chose ...
function (session, results) {
builder.Prompts.choice(session, "Hi I'm your bot you what are you looking for?", ["Ask a question", "Other cool stuff"], {listStyle: builder.ListStyle.button});
},
function (session, results) {
if(results.response) {
switch (results.response.entity) {
case 'Ask a question':
session.replaceDialog('/QnAMakerDialogue');
case 'Other cool stuff':
session.replaceDialog('/CoolStuffDialog');
default:
session.send("Something went horribly wrong");
return;
}
}
}
If your user has responded that they want to ask a question, you will need to prompt for the question. To do this, I've sometimes used a wrapper dialogue QnAPromptDialogue ...
function (session,args,next) {
//if the user just entered 'ask question' or similar, prompt for the actual question
var regex = new RegExp("^ask .*");
if(regex.test(session.message.text)) {
builder.Prompts.text(session, "Go ahead, what is your question?");
} else {
next();
}
},
function (session, results) {
session.replaceDialog('/QnAMakerDialogue');
}
Might not work for everybody, but including in case it's helpful.