private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            // Call LUIS, try and identify what the user is trying to do.
            //If the entities are included in the response, convert them to a viewmodel and use them in the next prompt, otherwise prompt the user for the missing data.
            var luisResult = await _luisRecognizer.RecognizeAsync <IVR>(stepContext.Context, cancellationToken);

            switch (luisResult.TopIntent().intent)
            {
            case IVR.Intent.TaxForms:
                await stepContext.Context.SendActivityAsync(VoiceFactory.TextAndVoice(TaxFormsResponse), cancellationToken);

                break;

            case IVR.Intent.POStatus:
                var poStatusResult    = luisResult.Entities.ToObject <POStatusModel>();
                var poStatusViewModel = new PurchaseOrderStatusViewModel();

                if (poStatusResult.PONumber != null && poStatusResult.PONumber.Length > 0)
                {
                    poStatusViewModel.PONumber = poStatusResult.PONumber.First();
                }

                return(await stepContext.ReplaceDialogAsync(nameof(PurchaseOrderStatusDialog), poStatusViewModel));

            case IVR.Intent.LeavePolicy:
                var leavePolicyResult    = luisResult.Entities.ToObject <LeavePolicyModel>();
                var leavePolicyViewModel = new LeavePolicyViewModel();

                if (leavePolicyResult.LeaveOfAbscensePolicies != null && leavePolicyResult.LeaveOfAbscensePolicies.Length > 0)
                {
                    leavePolicyViewModel.LeaveOfAbscensePolicy = leavePolicyResult.LeaveOfAbscensePolicies.First().First();
                }

                return(await stepContext.ReplaceDialogAsync(nameof(LeavePolicyDialog), leavePolicyViewModel));

            case IVR.Intent.Cancel:
                //If the user indicates that they are done with the call, leave a message and hangup.
                var goodbyeMessage = VoiceFactory.TextAndVoice(HangupText, InputHints.IgnoringInput);
                await stepContext.Context.SendActivityAsync(goodbyeMessage, cancellationToken);

                await Task.Delay(3000);     // Temporary hack to make sure that the message has finished being read.Bug is tracked to fix this issue.

                //End of conversation activity currently causes a HangUp. This functionality is experimental, and the API might change.
                await stepContext.Context.SendActivityAsync(Activity.CreateEndOfConversationActivity(), cancellationToken);

                return(await stepContext.EndDialogAsync());

            default:
                // Catch all for unhandled intents
                var didntUnderstandMessageText = $"Sorry, I didn't get that. Please try asking in a different way (intent was {luisResult.TopIntent().intent}). What I heard was {stepContext.Context.Activity.Text}";
                var didntUnderstandMessage     = VoiceFactory.TextAndVoice(didntUnderstandMessageText, InputHints.IgnoringInput);
                await stepContext.Context.SendActivityAsync(didntUnderstandMessage, cancellationToken);

                break;
            }

            return(await stepContext.NextAsync(null, cancellationToken));
        }
        private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            // Call LUIS, try and identify what the user is trying to do.
            //If the entities are included in the response, convert them to a viewmodel and user them, otherwise prompt the user for the missing data.
            var luisResult = await _luisRecognizer.RecognizeAsync <IVR>(stepContext.Context, cancellationToken);

            switch (luisResult.TopIntent().intent)
            {
            case IVR.Intent.FindNearestStore:
                //Get Luis model and convert it to an easier to work with viewmodel
                var nearestStoreResult    = luisResult.Entities.ToObject <FindNearestStoreModel>();
                var nearestStoreViewModel = new StoreLocationViewModel();

                if (nearestStoreResult.StoreLocation != null && nearestStoreResult.StoreLocation.Length > 0)
                {
                    var storeLocation = nearestStoreResult.StoreLocation.First();
                    if (storeLocation.City.Length > 0)
                    {
                        nearestStoreViewModel.City = storeLocation.City.First();
                    }
                    if (storeLocation.State.Length > 0)
                    {
                        nearestStoreViewModel.State = storeLocation.State.First();
                    }
                }

                return(await stepContext.ReplaceDialogAsync(nameof(NearestStoreDialog), nearestStoreViewModel));

            case IVR.Intent.OrderStatus:
                var orderStatusResult    = luisResult.Entities.ToObject <OrderStatusModel>();
                var orderStatusViewModel = new OrderStatusViewModel();

                if (orderStatusResult.OrderNumber != null && orderStatusResult.OrderNumber.Length > 0)
                {
                    orderStatusViewModel.OrderNumber = orderStatusResult.OrderNumber.First();
                }

                return(await stepContext.ReplaceDialogAsync(nameof(OrderStatusDialog), orderStatusViewModel));

            case IVR.Intent.Cancel:
                //If the user indicates that they are done with the call, leave a message and hangup.
                var goodbyeMessage = VoiceFactory.TextAndVoice(HangupText, InputHints.IgnoringInput);
                await stepContext.Context.SendActivityAsync(goodbyeMessage, cancellationToken);

                await Task.Delay(3000);     //Temporary hack to make sure that the message has finished being read. Bug is tracked to fix this issue.

                //End of conversation activity currently causes a HangUp. This functionality is experimental, and the API might change.
                await stepContext.Context.SendActivityAsync(Activity.CreateEndOfConversationActivity(), cancellationToken);

                return(await stepContext.EndDialogAsync());

            default:
                // Catch all for unhandled intents
                var didntUnderstandMessageText = $"Sorry, I didn't get that. Please try asking in a different way (intent was {luisResult.TopIntent().intent}). What I heard was {stepContext.Context.Activity.Text}";
                var didntUnderstandMessage     = VoiceFactory.TextAndVoice(didntUnderstandMessageText, InputHints.IgnoringInput);
                await stepContext.Context.SendActivityAsync(didntUnderstandMessage, cancellationToken);

                break;
            }

            return(await stepContext.NextAsync(null, cancellationToken));
        }