0
votes

for example, If a user asks the bot "whats the weather", and the luis will recognize the entity and the bot will ask for location. After that, the bot has to pick an answer from a point and has to reply back to the user with an answer. I am not able to do the 'reply back with the answer' to the user.

Thanks in advance.

1
Are you looking for context.PostAsync(...) method?Nicolas R
I am using Node.js bro.. i am not good at C#...Goutham
So looks like you are looking for session.send? docs.microsoft.com/en-us/bot-framework/nodejs/…Nicolas R

1 Answers

0
votes

Are you using a standard waterfall methodology in your dialog? For example, the following code is pulled from a demo I built (written in TypeScript):

bot.dialog("location", [
        (sess, args, next) => {
            builder.Prompts.choice(sess, "We are showing multiple results. Please choose one:", getEntities(builder, args));
        },
        (sess, results) => {
            sess.send(new builder.Message(sess).addAttachment(dialogs.createHeroCard(sess, parser.findExact("title", results.response.entity))));
        }
    ]).triggerAction({
        matches: "location"
});

In this example, the intent in LUIS is labeled "location", so the triggerAction matches against that. The dialog has two functions. The first is called when LUIS returns, and it displays a choice dialog with multiple options. When the user chooses one of those options, the result ends up in the second function. So this encompasses two questions. First, the user asks where a particular speaking engagement is being held, and the bot returns a few items that match the intent (maybe there are three presentations on "bots" at a conference). It displays a choice dialog with the elements, and the user's choice pings back to the dialog (but in the second function), and sends a hero card of the presentation chosen.

In the first instance, the bot uses builder.Prompts.choice() to ask for the choice information, and the second response uses session.send() to display the result.

In your example, you could use builder.Prompts.text() to ask for the user's location, and upon receiving the response (available in the second function of the waterfall as results.response, if your function parameters are session and results), you'd parse that data, and then use session.send() to display the results.

So if this were translated to your example, you could probably do something like:

bot.dialog("weather", [
        (sess, args, next) => {
            builder.Prompts.text(sess, "What location do you want weather for?");
        },
        (sess, results) => {
            //Do something with the results
            sess.send("Here's the weather!");
    }
    ]).triggerAction({
        matches: "weather"
});