2017-02-23 40 views
0

我想提示問題與中是聊天窗口沒有選擇,如何使用PromptDialog.Confirm()在MessageController.cs POST方法

public class MessagesController : ApiController 
{ 
    public virtual async Task<HttpResponseMessage> Post([FromBody] Activity activity) 
    { 
     ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl)); 
     Activity reply; 

     if (activity != null) 
     { 
      // check if activity is of type message 
      if (activity.Type == ActivityTypes.Message) 
      { 
       await GetEntityFromLUIS(activity); 
      } 
      else if (activity.Type == ActivityTypes.ConversationUpdate) 
      { 
        constructResponse = "Hi"; 
        reply = activity.CreateReply($"{constructResponse}"); 
        await connector.Conversations.ReplyToActivityAsync(reply); //After this we need Prompt question with Yes r No 
      } 
     } 
     else 
     { 
      connector = new ConnectorClient(new Uri(activity.ServiceUrl)); 

      HandleSystemMessage(activity); 
     } 

     return new HttpResponseMessage(System.Net.HttpStatusCode.Accepted); 
    } 
} 

如何提示問題與**有任何疑問**和顯示後。下一步,下面的代碼

reply = activity.CreateReply($"{constructResponse}"); 
await connector.Conversations.ReplyToActivityAsync(reply); 

回答

0

您可以使用PromptDialog.Confirm像

PromptDialog.Confirm(context, Confirmed,"Have question"); 

確認()用戶

public async Task Confirmed(IDialogContext context, IAwaitable<bool> argument) 
    { 
     bool isCorrect = await argument; 
     if (isCorrect) 
     { } 
     else 
     { } 
    } 
+0

的答案在我需要聲明這證實功能後發生,在MessageController.cs中或需要創建任何其他類。我曾在同一個MessageController.cs中聲明,但bot沒有響應,儘管它沒有顯示「Hi」。 – Krishna