/// <summary> /// /// </summary> /// <param name="ct"></param> /// <returns></returns> private async Task CustomerSessionProcessAsync(CancellationToken ct) { try { // Perform face verfication of the customer in front of the camera. If known customer, the this.User property will be set with the customer profile await this.PerformFaceVerificationAsync(ct); // If a known customer is present, have the customer do their voice verfication and if successful, continue the business flow if (this.User != null && await this.PerformVoiceVerficationAsync(ct)) { // Customer is authenticated and authorized int attempts = 0; bool intentProcessed = false; do { // Continue looping asking the customer what they want to do and handle their request until one completes or they leave the kiosk attempts++; ct.ThrowIfCancellationRequested(); // User keeps speaking commands that are not recognized, stop the loop if (attempts > 5) { await this.DisplayKioskMessageAsync(ct, "You've reached the maximum number of attempts, please authenticate again."); break; } this.CustomerMessage = null; await this.DisplayKioskMessageAsync(ct, $"{this.User.FirstName}, how can I help you?"); // Prompt user to speak a command await _speechToText.GetTextFromSpeechAsync(); // Process the spoken command using LUIS await this.DisplayKioskMessageAsync(ct, "Thinking...", false); intentProcessed = await this.ProcessCustomerTextAsync(ct, this.CustomerMessage); this.CustomerMessage = null; }while (intentProcessed == false); // Keep looping until a command is recognized // Final verification check to make sure customer is smiling before leaving the kiosk await this.PerformCustomerHappyVerificationAsync(ct); } } catch (Exception ex) { this.Log("Error in CustomerSessionProcessAsync(): " + ex.Message, ex); } finally { // Customer interaction is complete, reset and end the session this.CustomerMessage = null; await this.DisplayKioskMessageAsync(ct, "Goodbye!"); await this.EndSessionAsync(); } }