Azure Bot Framework,QnA Maker API,如何在QnA对话中获取查询文本

在QnA Maker API中,当找不到结果时,它会返回一些默认消息,或者我们可以更改该消息,但是我想运行一个函数/方法当没有结果来源。以下是代码。Azure Bot Framework,QnA Maker API,如何在QnA对话中获取查询文本

public QnaDialog(): base(

new QnAMakerService(new QnAMakerAttribute(ConfigurationManager.AppSettings["QnaSubscriptionKey"],

ConfigurationManager.AppSettings["QnaKnowledgebaseId"], "Hmm, I wasn't able to find any relevant content. Can you try asking in a different way? or try with typing help.", 0.5)))

{

//this is what i want to call, this is working but **i am not able to get query text here**

SendEmail email = new SendEmail();

email.SendEmailtoAdmin("Query_Text", "Email ID");

}

回答:

,看一下在GitHub上QnaMakerDialog实施here。

你会看到你有几个选项,更容易的是覆盖在Qna搜索之后调用的DefaultWaitNextMessageAsync方法。

protected virtual async Task DefaultWaitNextMessageAsync(IDialogContext context, IMessageActivity message, QnAMakerResults result) 

{

if (result.Answers.Count == 0)

{

// Here you have the query text in message.Text so:

SendEmail email = new SendEmail();

email.SendEmailtoAdmin(message.Text, "Email ID");

}

context.Done(true);

}

请注意,如果你想避免派出约没有QNA发现的消息,你应该重写MessageReceivedAsync替代和改变块中的代码if (sendDefaultMessageAndWait)

以上是 Azure Bot Framework,QnA Maker API,如何在QnA对话中获取查询文本 的全部内容, 来源链接: utcz.com/qa/261986.html

回到顶部