简体   繁体   English

如何以编程方式调用Luis Intent方法并从表单流传递数据

[英]How to Call Luis intent method programatically and pass data from form flow

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. 完成表格后,我想触发luis intent。我使用json触发了intent,但它为我提供了所有intent的数据,而不是触发了最高得分的intent。 what are all the possible ways to call luis from c# code 从C#代码调用luis的所有可能方法是什么

Form code- public static IForm BuildForm() { 表单代码-公共静态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 //这里我要触发下面给出的luis intent方法DocumentSearchIntent

            };

        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) { Luis意图方法-[LuisIntent(“ DocumentSearch”)]公共异步任务DocumentSearchIntent(IDialogContext上下文,LuisResult结果){

        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);

    }

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. 我觉得这个文章可以帮助你在BOT框架中使用的形式根据你的情况,你可以调用基于返回的得分最高的意图所需的意图方法。 I think this article might be useful for you to call the intent method. 我想, 文章给你打电话的意图方法可能是有用的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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