public async Task <LUISIntentStatus> HandleIntent(string text)
        {
            try
            {
                if (_router == null)
                {
                    var handlers = new DroneIntents();
                    _router = IntentRouter.Setup(Keys.LUISAppId, Keys.LUISAzureSubscriptionKey, handlers, false);
                }
                var status = new LUISIntentStatus();
                status.service = this;
                var handled = await _router.Route(text, status);

                return(status);
            }
            catch (Exception)
            {
                return(new LUISIntentStatus()
                {
                    SpeechRespose = "LUIS and I are not talking right now, make sure IDs are correct in Keys.cs",
                    TextResponse = "Can't access LUIS, make sure to populate Keys.cs with the LUIS IDs",
                    Success = true
                });
            }
        }
Exemple #2
0
        public async Task <bool> HandleFlyToHeight(LuisResult result, object context)
        {
            LUISIntentStatus usingIntentRouter = (LUISIntentStatus)context;

            var entity = result.Entities.Where(e => e.Key == "height").Select(e => e.Value).FirstOrDefault();

            if (entity == null)
            {
                usingIntentRouter.Success = false;
                return(false);
            }

            var height = entity.First().Value;

            var succeeded = await sendCommandToBot("flyHeight", "height", height.ToString());

            if (succeeded)
            {
                usingIntentRouter.SpeechRespose = "I've sucessfully disarmed";
            }
            else
            {
                usingIntentRouter.SpeechRespose = "Unable to disarm";
            }


            usingIntentRouter.Success = true;
            return(true);
        }
Exemple #3
0
        public async Task <bool> HandleArm(LuisResult result, object context)
        {
            LUISIntentStatus usingIntentRouter = (LUISIntentStatus)context;

            await usingIntentRouter.service.SpeakAsync("Preparing to Arm");

            await Task.Delay(1000);

            await usingIntentRouter.service.SpeakAsync("please stand back");

            await Task.Delay(3000);

            var succeeded = await sendCommandToBot("arm");

            if (succeeded)
            {
                await usingIntentRouter.service.SpeakAsync("I've sucessfully armed");
            }
            else
            {
                await usingIntentRouter.service.SpeakAsync("I've failed to arm");
            }

            usingIntentRouter.handled = true;
            usingIntentRouter.Success = true;
            return(true);
        }
Exemple #4
0
        public async Task <bool> HandleNone(LuisResult result, object context)
        {
            LUISIntentStatus usingIntentRouter = (LUISIntentStatus)context;
            await Task.Delay(0);

            usingIntentRouter.Success = false;
            return(true);
        }
Exemple #5
0
        public async Task <bool> HandleDisarm(LuisResult result, object context)
        {
            LUISIntentStatus usingIntentRouter = (LUISIntentStatus)context;

            var succeeded = await sendCommandToBot("disarm");

            if (succeeded)
            {
                usingIntentRouter.SpeechRespose = "I've sucessfully disarmed";
            }
            else
            {
                usingIntentRouter.SpeechRespose = "Unable to disarm";
            }


            usingIntentRouter.Success = true;
            return(true);
        }