New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When starting new conversation, emulator sends "conversationUpdate" event twice #99

Closed
giorgobiani opened this Issue Feb 4, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@giorgobiani
Copy link

giorgobiani commented Feb 4, 2017

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.

@giorgobiani

This comment has been minimized.

Copy link

giorgobiani commented Feb 4, 2017

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.

@eanders-MS

This comment has been minimized.

Copy link
Contributor

eanders-MS commented Feb 6, 2017

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#):

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;
@giorgobiani

This comment has been minimized.

Copy link

giorgobiani commented Feb 6, 2017

Thanks @eanders-MS, got that! Closing issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment