Reputation: 965
How can I achieve this? So I did this:
.matches('Football position', (session, results) => {
session.send("So you are looking for a \%s\ position. ", session.message.text);
function (session, args, next) {
builder.Prompts.confirm(session, "Did that solve your problem buddy !");
},
function (session, args) {
if (args.response) {
session.send("good by");
else {
session.send("Please try again");
}
})
So, first: a confirmation regarding the previous answer the person gave. Then: a dialog where the user can put in NO or YES. Based on the answer, I want to go a different way and show a different message, but it does not work at all.
Could someone help, please?
Upvotes: 1
Views: 159
Reputation: 13918
First of all, there is a mistake in your code snippet, the second parameter of function matches()
should be a tring|IDialogWaterfallStep[]|IDialogWaterfallStep
. You need to modifty your code snippet as:
matches('Football position',[(session,args)=>{},(session,args)=>{}...])
Second, send()
will not keep the state in the waterfall steps, which means, your user never will step into the following steps via your code snippet. If you attempt to recieve user's input, you can use IPrompts
.
Then: a dialog where the user can put in NO or YES
You can leverage choice to achieve this:
bot.dialog('/', [
(session) => {
var msg = new builder.Message(session)
.text("Did that solve your problem buddy !")
.suggestedActions(
builder.SuggestedActions.create(
session, [
builder.CardAction.imBack(session, "Yes", "Yes"),
builder.CardAction.imBack(session, "No", "No")
]
)
);
builder.Prompts.choice(session, msg, ["Yes", "No"]);
},
(session, args, next) => {
if (args.response.entity == "Yes") {
session.send("You selected Yes")
} else {
session.send("You selected No")
}
}
])
Upvotes: 2