BOT to ask entity in second step

Building a simple customer service BOT, have designed the LUIS model and it works great when the order no. is provided in the first step itself. for eg. whats the status of my order ABC0898787 ? where intent is detected correctly and ABC0898787 is identified as the entity.

However, need to adapt the bot to have a conversation as follows:

User: whats the status of my order

Bot: please provide the order no

User: (It is ABC0986767) or (ABC0986767)

Bot should be able to map the number to entity and process the request.

the code for intent method, whats the best way to integrate the second step without setting up the LUIS model to take single words as entity ?

   [LuisIntent("OrderStatus")]
        public async Task OrderStatus(IDialogContext context, LuisResult result)
        {
            var returnMsg = "You wanted to check the order status";
            var orderStatus = "Dispatched";
            var deliveryDate = DateTime.Now.AddDays(3);

            var entities = new List<EntityRecommendation>(result.Entities);
            if(entities.Any((entity)=> entity.Type == "Order"))
            {
                var orderEntity = entities.Where((entity) => entity.Type == "Order").FirstOrDefault();
                var resolutionStr = orderEntity.Entity;
                if(!string.IsNullOrEmpty(resolutionStr))
                {
                    returnMsg = "Your order " + resolutionStr + " is " + orderStatus + " and expected to arrive " + deliveryDate.Humanize();
                }
            }

            await context.PostAsync(returnMsg);
            context.Wait(MessageReceived);
        }

Answers


Replace MessageReceived with the name of your method that will take the user's input. Before that, check if entity exists. If exists, then use MessageReceived, otherwise this method.

Pseudocode:

if (entity.exists) 
    OutputResult()
    Context.Wait(MessageReceived)
else //entitiy doesn't exist
    SendMessage("Please enter order number")
    Context.Wait(MyMethod)

The method called MyMethod begins like this:

public async Task MyMethod(IDialogContext context, IAwaitable<IMessageActivity> argument) 
{
    var response = await argument;
    string text = response.Text;

I think Microsoft didn't make it clear enough that MessageReceived is just a name of a method (that you don't see), and it can be replaced with the name of any other method. There can also be multiple context.Waits in a method depending on a condition, as long as the code doesn't reach a context.Wait() twice before the user sends a new message.


Need Your Help

Adding external libraries in Eclipse

java eclipse servlets

I create new projects in Eclipse regularly and every time when I add a Servlet to one of them I get the error import javax.servlet can't be resolved