public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken)) { try { DialogContext dc = null; switch (turnContext.Activity.Type) { case ActivityTypes.Message: switch (turnContext.Activity.Text.ToLowerInvariant()) { case "signout": case "logout": case "signoff": case "logoff": var botAdapter = (BotFrameworkAdapter)turnContext.Adapter; await botAdapter.SignOutUserAsync(turnContext, ConnectionSettingName, CancellationToken.None); await turnContext.SendActivityAsync("You are now signed out."); break; case "help": await turnContext.SendActivityAsync(HelpText); break; default: dc = await _dialogs.CreateContextAsync(turnContext); await dc.ContinueAsync(); if (!turnContext.Responded) { await dc.BeginAsync("displayToken"); } break; } break; case ActivityTypes.Event: case ActivityTypes.Invoke: // This handles the MS Teams invoke activity sent when magic code is not used //See: https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/authentication/auth-oauth-card#getting-started-with-oauthcard-in-teams //Manifest Schema Here: https://docs.microsoft.com/en-us/microsoftteams/platform/resources/schema/manifest-schema dc = await _dialogs.CreateContextAsync(turnContext); await dc.ContinueAsync(); if (!turnContext.Responded) { await dc.BeginAsync("displayToken"); } break; case ActivityTypes.ConversationUpdate: var newUserName = turnContext.Activity.MembersAdded.FirstOrDefault()?.Name; if (!string.Equals("Bot", newUserName)) { var reply = turnContext.Activity.CreateReply(); reply.Text = HelpText; reply.Attachments = new List <Attachment> { GetHeroCard(newUserName).ToAttachment() }; await turnContext.SendActivityAsync(reply); } break; } } catch (Exception e) { await turnContext.SendActivityAsync($"Exception: {e.Message}"); } }