private async Task <Activity> HandleSystemMessageAsync(Activity message) { TeamEventBase eventData = message.GetConversationUpdateData(); switch (eventData.EventType) { case TeamEventType.MembersAdded: var connector = new ConnectorClient(new Uri(message.ServiceUrl)); connector.SetRetryPolicy( RetryHelpers.DefaultPolicyBuilder.WaitAndRetryAsync( new[] { TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(10) }) ); var tenantId = message.GetTenantId(); var botAccount = message.Recipient; var channelData = message.GetChannelData <TeamsChannelData>(); // if the bot is in the collection of added members, // then send a welcome to all team members if (message.MembersAdded.Any(m => m.Id.Equals(botAccount.Id))) { // Fetch the members in the current conversation IList <ChannelAccount> channelAccount = await connector.Conversations.GetConversationMembersAsync( message.Conversation.Id); IEnumerable <TeamsChannelAccount> members = channelAccount.AsTeamsChannelAccounts(); // send a OneToOne message to each member foreach (TeamsChannelAccount member in members) { await MessageHelpers.SendOneToOneWelcomeMessage( connector, channelData, botAccount, member, tenantId); } } else { // send a OneToOne message to new members foreach (TeamsChannelAccount member in message.MembersAdded.AsTeamsChannelAccounts()) { await MessageHelpers.SendOneToOneWelcomeMessage( connector, channelData, botAccount, member, tenantId); } } break; case TeamEventType.MembersRemoved: break; case TeamEventType.ChannelCreated: break; case TeamEventType.ChannelDeleted: break; case TeamEventType.ChannelRenamed: break; case TeamEventType.TeamRenamed: break; default: break; } return(null); }