BotFramework 1:1 对话引发错误 "activityid can not be null"
BotFramework 1:1 conversation throws error "activityid can not be null"
尝试使用以下代码创建 1:1 对话时,我收到错误提示 "activityid cannot be null" 谁能帮我指出问题所在?
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);
您正在使用:
ReplyToActivityAsync
但不回复现有对话,而是创建一个新对话。您应该改用以下内容:
SendToConversationAsync
尝试使用以下代码创建 1:1 对话时,我收到错误提示 "activityid cannot be null" 谁能帮我指出问题所在?
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);
您正在使用:
ReplyToActivityAsync
但不回复现有对话,而是创建一个新对话。您应该改用以下内容:
SendToConversationAsync