public async Task <IDialogFlowOutput> ExecuteAsync(IDialogFlowInput flowPostModel) { // Save the email with the session Id for later use var sessionId = flowPostModel.SessionId; var emailAddress = Helpers.DictionaryHelper.GetValue <string>(flowPostModel?.Result?.Parameters, "root_email"); // Save the session and email to the store if (!string.IsNullOrEmpty(emailAddress)) { // Get the user Id for the email var user = await DBState.GetUser(emailAddress); if (user == null) { user = await DBState.SaveUser(new Core.DataModels.User() { Email = emailAddress, CurrentSessionId = sessionId }); } else { user.CurrentSessionId = sessionId; user = await DBState.SaveUser(new Core.DataModels.User() { Email = emailAddress, CurrentSessionId = sessionId }); } // Insert the session state if it does not exist await DBState.SaveUserSession(sessionId, emailAddress); // Save the session state } var response = new DialogFlowOutput(); return(response); }