2017-12-18 6 views
1

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

답변

3

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

당신은 문의 글을 찾을 수 없음에 대해 전송 된 메시지가 나타나지 않도록하려면, 대신 MessageReceivedAsync을 무시하고 블록 내부의 코드를 변경해야합니다 있습니다 if (sendDefaultMessageAndWait)