[英]How to Call Luis intent method programatically and pass data from form flow
我有一個要獲取用戶輸入的表單。 完成表格后,我想觸發luis intent。我使用json觸發了intent,但它為我提供了所有intent的數據,而不是觸發了最高得分的intent。 從C#代碼調用luis的所有可能方法是什么
表單代碼-公共靜態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";
//這里我要觸發下面給出的luis intent方法DocumentSearchIntent
};
return new FormBuilder<DocumentFormFlow>()
.Message("Welcome to the Chat bot !")
.OnCompletion(processDocumentSearch)
.Build();
}
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);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.