2016-07-20 50 views
2

嘗試使用以下代碼創建1:1會話時,出現錯誤消息「activityid不能爲空」,有人可以幫我指出什麼是錯的?BotFramework 1:1會話拋出錯誤「activityid不能爲空」

var newRecipient = new ChannelAccount(); 
          newRecipient.Name = user.Mentioned.Name; 
          newRecipient.Id = user.Mentioned.Id; 

          var ConversationId = await connector.Conversations.CreateDirectConversationAsync(activity.Recipient, newRecipient); 
          IMessageActivity message = Activity.CreateMessageActivity(); 
          message.From = activity.Recipient; 
          message.Recipient = newRecipient; 
          message.Conversation = new ConversationAccount(id: ConversationId.Id); 
          message.Text = $"Congratulations {user.Mentioned.Name}!, you have got a :tangerine: from {activity.From.Name}"; 
          message.Locale = "en-Us"; 
          message.Id = Guid.NewGuid().ToString(); 
          var reply = await connector.Conversations.ReplyToActivityAsync((Activity)message); 

回答

2

您正在使用:

ReplyToActivityAsync

但不能回覆到現有converstation,而是創建一個新的。您應該改用以下內容:

SendToConversationAsync

+0

還提高了下一個版本的錯誤消息。 – Lars

+0

是的。這就是我最終做的。感謝你的回答 – Supreet

相關問題