2017-12-24 20 views
1

C#의 Microsoft bot 프레임 워크를 사용하여 대화방을 개발 중입니다. 우리는 데이터베이스를 쿼리하고 결과를 반환하는 기능을 가지고 있지만 결과가 반환되기까지 최대 25 ~ 30 초가 걸릴 수 있습니다.Microsoft bot framework Webchat C#

그때까지 로봇은 "보낼 수 없습니다, 다시 시도하십시오"라고 말합니다. 이 시간 초과를 늘릴 수있는 방법이 있습니까? 또는 사용자가 요청을 처리 중임을 알 수 있도록 사용자에게 "기다려주십시오"와 같은 메시지를 표시 할 수 있습니까?

+0

코드가 필요합니다. 코드에서 타이머를 설정하지 않으면 TCP 응용 프로그램이 시간 초과되는 것은 일반적이지 않습니다. – jdweng

답변

1

SDK에 하드 코딩되어 있으므로 "보내지 못했습니다. 다시 시도하십시오."와 같은 메시지를 무시할 수 없습니다. Nicolas에 따르면 해결 방법은 proactive message을 사용자에게 보내는 것입니다. 당신은 다음과 같이 코딩 할 수 있습니다, 당신의 대화에서 그런

public class ConversationStarter 
{ 
    //Note: Of course you don't want these here. Eventually you will need to save these in some table 
    //Having them here as static variables means we can only remember one user :) 
    public static string fromId; 
    public static string fromName; 
    public static string toId; 
    public static string toName; 
    public static string serviceUrl; 
    public static string channelId; 
    public static string conversationId; 

    //This will send an adhoc message to the user 
    public static async Task Resume(string conversationId, string channelId) 
    { 
     var userAccount = new ChannelAccount(toId, toName); 
     var botAccount = new ChannelAccount(fromId, fromName); 
     var connector = new ConnectorClient(new Uri(serviceUrl)); 

     IMessageActivity message = Activity.CreateMessageActivity(); 
     if (!string.IsNullOrEmpty(conversationId) && !string.IsNullOrEmpty(channelId)) 
     { 
      message.ChannelId = channelId; 
     } 
     else 
     { 
      conversationId = (await connector.Conversations.CreateDirectConversationAsync(botAccount, userAccount)).Id; 
     } 
     message.From = botAccount; 
     message.Recipient = userAccount; 
     message.Conversation = new ConversationAccount(id: conversationId); 
     message.Text = "Hello, work is done!"; 
     message.Locale = "en-Us"; 
     await connector.Conversations.SendToConversationAsync((Activity)message); 
    } 
} 

:

는 예를 들어, 당신은 먼저 이런 ConversationStarter.cs 클래스를 만들 수 있습니다

다음 Task.Delay(30000) 방법은 30 대 작업에 사용되는
public async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result) 
{ 
    var message = await result; 

    //We need to keep this data so we know who to send the message to. Assume this would be stored somewhere, e.g. an Azure Table 
    ConversationStarter.toId = message.From.Id; 
    ConversationStarter.toName = message.From.Name; 
    ConversationStarter.fromId = message.Recipient.Id; 
    ConversationStarter.fromName = message.Recipient.Name; 
    ConversationStarter.serviceUrl = message.ServiceUrl; 
    ConversationStarter.channelId = message.ChannelId; 
    ConversationStarter.conversationId = message.Conversation.Id; 

    await context.PostAsync("Please wait, we're processing..."); 

    Processing(); 
} 


public async Task Processing() 
{ 
    //replace the task.delay() method with your task. 
    await Task.Delay(30000).ContinueWith((t) => 
    { 
     ConversationStarter.Resume(ConversationStarter.conversationId, ConversationStarter.channelId); 
    }); 

} 

테스트를 수행 할 때 데이터베이스에서 데이터를 검색하는 태스크로 대체 할 수 있어야합니다.

+0

팁 주셔서 감사합니다 :) – saravana14

0

당신은 다음을 수행해야합니다

  1. 당신이 회신을 받았는데 일단
  2. 는 적극적인 메시지를 만들
  3. 메시지 정보를 저장 답장을 기본 텍스트로 사용자의 요구를 인정하고 요청을 처리를 시스템의