0
votes

I have a form where i am getting user input. On completion of form i want to trigger luis intent.I have used json to trigger the intent but it gave me data with all the intent instead of triggering the top scoring intent. what are all the possible ways to call luis from c# code

Form code- public static IForm BuildForm() {

        OnCompletionAsyncDelegate<DocumentFormFlow> processDocumentSearch = async (context, Docdata) =>
        {
            string message = "Thanks for using chat bot Please wait while we search your document , Welcome Again !!! :)";
            await context.PostAsync(message);
            string query = "fetch me " + Docdata.ClientName + " " + Docdata.SelectDocument + "document";

//here i want to trigger luis intent method DocumentSearchIntent given below

            };

        return new FormBuilder<DocumentFormFlow>()
                .Message("Welcome to the  Chat bot !")
                .OnCompletion(processDocumentSearch)
                .Build();

}

Luis intent method- [LuisIntent("DocumentSearch")] public async Task DocumentSearchIntent(IDialogContext context, LuisResult result) {

        FilesFound.Clear();
        var msj = context.MakeMessage();
        var clientname = string.Empty;
        var documenttype = string.Empty;
        EntityRecommendation rec;
        if (result.TryFindEntity("ClientName", out rec))
            clientname = rec.Entity;
        if (result.TryFindEntity("DocumentType", out rec))
            documenttype = rec.Entity;
        if (documenttype.Contains("."))
            documenttype = documenttype.Replace(" ", "");

        if (clientname == string.Empty || documenttype == string.Empty)
            msj.Text = "Could you please provide both input for client name and document.";
        else
        {
            DirSearch(path, clientname, documenttype);



            int count = 0;
            do
            {
                if (FilesFound.Count == 0)
                {
                    msj.Text = "No document found for this search";
                    break;
                }

                msj.Text += FilesFound[count].ToString();
                count++;
            } while (count < FilesFound.Count);


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

    }
1
Your Subscription Key should not be publicly exposed. I've removed it from your question, but please be sure to change it in the portal.Eric Dahlvang
@EricDahlvang - That other question is a good find, but it seems to apply to using LUIS within a form. This question just wants to pass the result of a form to LUIS.Kyle Delaney
Can you explain what you mean by triggering the top-scoring intent? Do you have a LuisDialog that you want to call a method from according to the intent? Extracting the top intent from the LUIS response is a simple matter and you can do whatever you want with it. What do you want to do?Kyle Delaney
i have a form in chat bot that is used to get uuser information. On the completion of the form i want to trigger luit intent based on input .Namrata Mahajan

1 Answers

2
votes

I think this article might help you in using form as per your scenario in the bot framework, You can then call the required intent method based on the top scoring intent returned. I think this article might be useful for you to call the intent method.