gac*_*der 3 c# azure botframework azure-bot-service azure-qna-maker
在 QnA Maker API 中,当没有找到结果时,它会返回一些默认消息,或者我们可以更改该消息,但是我想在没有结果时运行一个函数/方法。下面是代码。
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");
}
Run Code Online (Sandbox Code Playgroud)
看看到QnaMakerDialog执行此GitHub上。
你会看到你有几个选项,覆盖DefaultWaitNextMessageAsync
Qna 搜索后调用的方法更容易。
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);
}
Run Code Online (Sandbox Code Playgroud)
请注意,如果您想避免发送关于 no Qna found 的消息,您应该重写 MessageReceivedAsync 并更改块内的代码 if (sendDefaultMessageAndWait)
归档时间: |
|
查看次数: |
540 次 |
最近记录: |