Hi,
I think there's little bug, after last update of bot emulator: When connecting to bot service (or hitting "Start new conversation" button), emulator send 2 identical requests to API with "ConversationUpdate" message, what causes two identical replies from my service.
Issue is not presented when service is published and used with external client like FB Messenger or Skype, only when calling from emulator. So I assume that it's emulator bug.
To reproduce this bug, just create new project with default bot project template and connect to it with bot emulator. If breakpoint is set in controller, it will fire twice, with exact parameters and also in emulator log you will see duplicate request/response cycle 2 times.
ok, figured out, it's not a bug, just requests are going twice, as first is indicating that bot added to conversation and second is indicating that user has been added too. But was that so or it changed? because just recently it started to fire two conversation update events.
Hi @giorgobiani This change was made in preparation for group conversation support. In a group conversation, users come and go. Whenever this happens, your bot will receive a corresponding ConversationUpdate activity.
To filter out your bot from the ConversationUpdate.MembersAdded (C#):
C#
case ActivityTypes.ConversationUpdate:
IConversationUpdateActivity update = activity;
var client = new ConnectorClient(new Uri(activity.ServiceUrl), new MicrosoftAppCredentials());
if (update.MembersAdded != null && update.MembersAdded.Any())
{
foreach (var newMember in update.MembersAdded)
{
if (newMember.Id != activity.Recipient.Id)
{
var reply = activity.CreateReply();
reply.Text = $"Welcome {newMember.Name}!";
await client.Conversations.ReplyToActivityAsync(reply);
}
}
}
break;
Thanks @eanders-MS, got that! Closing issue.
Most helpful comment
Hi @giorgobiani This change was made in preparation for group conversation support. In a group conversation, users come and go. Whenever this happens, your bot will receive a corresponding
ConversationUpdateactivity.To filter out your bot from the
ConversationUpdate.MembersAdded(C#):C# case ActivityTypes.ConversationUpdate: IConversationUpdateActivity update = activity; var client = new ConnectorClient(new Uri(activity.ServiceUrl), new MicrosoftAppCredentials()); if (update.MembersAdded != null && update.MembersAdded.Any()) { foreach (var newMember in update.MembersAdded) { if (newMember.Id != activity.Recipient.Id) { var reply = activity.CreateReply(); reply.Text = $"Welcome {newMember.Name}!"; await client.Conversations.ReplyToActivityAsync(reply); } } } break;