简体   繁体   中英

How to implement “Back” conversation in Chatbot

I wish to implement following scenario conversation in MS botframework

Bot: =>  what can do for you?            => User
Bot: <=  I want to rent a house         <= User
Bot: =>  Which city?                    => User
Bot: <=                 London          <= User
Bot: =>  How many bedrooms              => User
Bot: <=  Ops, I want a home in New York <= User  #User wish to change the topic here..

In MS botframework, how can I use Waterfall dialog to implement above story? any advice?

I don't think it is possible to implement it with waterfall approach with reasonable efforts. In simple case you can try to analyze the response, in your case it is a number of bedrooms, and if it is not a number, you can check the response for another request. The problem here is that you should do it for all responses and for open text responses it will be hard to distinguish between a legal answer or a topic change.

So, you should implement it using an intent approach.

First, you need an intent detector, you can use Luis as it is highly integrated with the bot framework or implement your own intent detector.

In in you case, this detector should detect the intent - I want to rent a house (a car and so on).

var intents = new builder.IntentDialog({ recognizers: [luis] });

See https://docs.botframework.com/en-us/node/builder/chat/IntentDialog These code examples are for Node.Js but the same approach should works for .Net.

Then, for each intent you should register an appropriate action that starts an waterfall dialog that gets all necessary data.

bot.beginDialogAction("RentHouseAction", RentHouseDialog.name+":/", { matches: "RentHouseAction"});

where RentHouseAction is the action you define in Luis RentHouseDialog is a waterfall dialog that is reside in the library.

bot.library(RentHouseDialog);

Note that as the RentHouseDialog dialog finishes it will return to the place where the previous dialog has stopped. So, it again asks - How many bedrooms . To prevent this behavior you should detect that your previous dialog hasn't finished yet (you can use the state for it where you collect the answers) and call session.replaceDialog('<>'); .

I hope it helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM