예제 #1
0
        protected override async Task RouteAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken))
        {
            var state = await _conversationStateAccessor.GetAsync(dc.Context, () => new SkillConversationState());

            // get current activity locale
            var locale       = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
            var localeConfig = _services.LocaleConfigurations[locale];

            // Get skill LUIS model from configuration
            localeConfig.LuisServices.TryGetValue("FakeSkill", out var luisService);

            if (luisService == null)
            {
                throw new Exception("The specified LUIS Model could not be found in your Bot Services configuration.");
            }
            else
            {
                var skillOptions = new SkillTemplateDialogOptions
                {
                    SkillMode = _skillMode,
                };

                var result = await luisService.RecognizeAsync <FakeSkillLU>(dc.Context, CancellationToken.None);

                var intent = result?.TopIntent().intent;

                switch (intent)
                {
                case FakeSkillLU.Intent.Sample:
                {
                    await dc.BeginDialogAsync(nameof(SampleDialog), skillOptions);

                    break;
                }

                case FakeSkillLU.Intent.Auth:
                {
                    await dc.BeginDialogAsync(nameof(AuthDialog), skillOptions);

                    break;
                }

                case FakeSkillLU.Intent.None:
                {
                    // No intent was identified, send confused message
                    await dc.Context.SendActivityAsync(dc.Context.Activity.CreateReply(SharedResponses.DidntUnderstandMessage));

                    if (_skillMode)
                    {
                        await CompleteAsync(dc);
                    }

                    break;
                }

                default:
                {
                    // intent was identified but not yet implemented
                    await dc.Context.SendActivityAsync(dc.Context.Activity.CreateReply(MainResponses.FeatureNotAvailable));

                    if (_skillMode)
                    {
                        await CompleteAsync(dc);
                    }

                    break;
                }
                }
            }
        }
예제 #2
0
        protected override async Task RouteAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken))
        {
            var state = await _conversationStateAccessor.GetAsync(dc.Context, () => new RestaurantBookingState());

            // get current activity locale
            var locale       = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
            var localeConfig = _services.LocaleConfigurations[locale];

            // Get skill LUIS model from configuration
            localeConfig.LuisServices.TryGetValue("restaurant", out var luisService);

            if (luisService == null)
            {
                throw new Exception("The specified LUIS Model could not be found in your Bot Services configuration.");
            }
            else
            {
                var skillOptions = new SkillTemplateDialogOptions
                {
                    SkillMode = _skillMode,
                };

                var turnResult = EndOfTurn;
                var result     = await luisService.RecognizeAsync <Reservation>(dc.Context, CancellationToken.None);

                var intent = result?.TopIntent().intent;

                switch (intent)
                {
                case Reservation.Intent.Reservation:
                {
                    turnResult = await dc.BeginDialogAsync(nameof(BookingDialog), skillOptions);

                    break;
                }

                case Reservation.Intent.None:
                {
                    // No intent was identified, send confused message
                    await dc.Context.SendActivityAsync(_responseManager.GetResponse(RestaurantBookingSharedResponses.DidntUnderstandMessage));

                    if (_skillMode)
                    {
                        turnResult = new DialogTurnResult(DialogTurnStatus.Complete);
                    }

                    break;
                }

                default:
                {
                    // intent was identified but not yet implemented
                    await dc.Context.SendActivityAsync(_responseManager.GetResponse(RestaurantBookingSharedResponses.DidntUnderstandMessage));

                    if (_skillMode)
                    {
                        turnResult = new DialogTurnResult(DialogTurnStatus.Complete);
                    }

                    break;
                }
                }

                if (turnResult != EndOfTurn)
                {
                    await CompleteAsync(dc);
                }
            }
        }