Integrating LUIS with FormFlow

瘦欲@ 提交于 2020-01-01 18:55:49

问题


I have created a bot, having a FormFlow in it. Now if you type I want to launch a product, LUIS will tell which dialog it has to go to :

    internal static IDialog<AssesmentHelper> CreateProduct()
            {
                return Chain.From(() => FormDialog.FromForm(AssesmentHelper.BuildForm))
                    .Do(async (context, profileForm) =>
                    {
                        try
                        {
                            var completed = await profileForm;

                        }
                        catch (FormCanceledException<AssesmentHelper> e)
                        {
                            string reply;
                            if (e.InnerException == null)
                            {
                                reply = $"You quit on {e.Last}--maybe you can finish next time!";
                            }
                            else
                            {
                                reply = Responses.ShortCircuit;
                            }
                            await context.PostAsync(reply);
                        }
                    });
            }

public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
        { 
stLuis = await LuisHelper.ParseUserInput(activity.Text);
    switch (stLuis.topScoringIntent.intent)
    {

         case "CreateProduct":
              await Conversation.SendAsync(activity, CreateProduct);
              break;

         case "EditProduct":
               await Conversation.SendAsync(activity, EditProduct);
               break;

           case "None":

               break;

            default:
               break;
    }
}

Now, once it enters dialog, it asks user to select numbers:

Please select numbers:

  1. Azure
  2. Windows

Now if I reply 1,2. Luis returns it as None intent, so my message does not go to the corresponding dialog. It always go to None case.

The code for dialog is:

 public static IForm<AssesmentHelper> BuildForm()
        {
            return new FormBuilder<AssesmentHelper>()
                    .Message(Responses.NumberSelection)
                    .Field(nameof(Program))
                    .Field(nameof(Product))
                    .Build();
        }

Enum for program and product:

[Serializable]
    public enum Program
    {
        None = 0,
        A = 1,
     };

        [Serializable]
        public enum Product
        {
            None = 0,
            Azure = 1,
            Windows = 2
        };

As soon as I enter this dialog, It asks me to select number for selecting program. Now if i select 1,2. Luis returns it as None intent. So Case "None", is executed.

What I want is, redirect the control to same dialog. I have similar dialog for Edit Product as well. That's why I cannot train my luis app to understand numbers as Product Intent. Otherwise whenever i select number for Edit Product, it will go to different case.

Earlier it was identifying correct intents somehow, but today i republished my luis app and it stopped identifying.

来源:https://stackoverflow.com/questions/40610686/integrating-luis-with-formflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!