简体   繁体   中英

handle multiple confirmation Prompts

How to handle multiple confirmation prompts: use case, 1st prompt is to ask would you like to add more products? if yes, should repeat the intent to take more products and quantity, if no, should ask for confirmation- Shall I place an order? -> if yes, make an order, if no -> cancel

Short answer: use sessionAttributes

‐------------

Long answer with a tip:

If you must do it this way, you should probably use a single intent, but re-elicit the same slot multiple times.

You should probably also ask beforehand how many products they want to list, so you can ask for that many things before expecting to confirm instead of asking if they want to add another product every time.

Let's say you have a Pizza Ordering Bot. For toppings, it could be like this.

Bot: What topping would you like?
User: Cheese
Bot: Would you like another topping?
User: Yes
Bot: What topping would you like?
User: Peppers
Bot: Would you like another topping?
(...again and again, unnatural)

So that would be more natural if you changed to:

Bot: How many toppings would you like?
User: 3
Bot: OK, what is the first topping?
User: Cheese
Bot: Got it, what is the second topping?
(much shorter, more natural)

In both cases, you would have a single slot for toppings, and every time you collect 1 value, you would copy that value into the bot's sessionAttributes and erase the slot from the slots object that you return to the bot when you ElicitSlot for the same slot.

Then when the user confirms that they are finished giving you all of the "toppings" or products they want, then you can combine all of the previous values from your sessionAttributes and fulfill the intent.

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