public async void Predict() { string _appId = txtAppId.Text; string _subscriptionKey = ((MainWindow)Application.Current.MainWindow).SubscriptionKey; string _textToPredict = txtPredict.Text; try { // Set up an intent router using the StaticIntentHandlers class to process intents using (var router = IntentRouter.Setup <StaticIntentHandlers>(_appId, _subscriptionKey)) { // Feed it into the IntentRouter to see if it was handled var handled = await router.Route(_textToPredict, this); if (!handled) { queryTextBlock.Text = ""; topIntentTextBlock.Text = ""; ((MainWindow)Application.Current.MainWindow).Log("Intent was not matched confidently, maybe more training required?"); } else { ((MainWindow)Application.Current.MainWindow).Log("Predicted successfully."); } } } catch (Exception exception) { ((MainWindow)Application.Current.MainWindow).Log(exception.Message); } }
public async void Predict() { string _appId = txtAppId.Text; string _subscriptionKey = ((MainWindow)Application.Current.MainWindow).SubscriptionKey; string _textToPredict = txtPredict.Text; IntentHandlers ih = new IntentHandlers(); try { using (var router = IntentRouter.Setup(_appId, _subscriptionKey, ih)) { var handled = await router.Route(_textToPredict, this); if (!handled) { queryTextBlock.Text = ""; topIntentTextBlock.Text = ""; ((MainWindow)Application.Current.MainWindow).Log("Intent was not matched confidently, maybe more training required?"); } else { ((MainWindow)Application.Current.MainWindow).Log("Predicted successfully."); } } } catch (Exception exception) { ((MainWindow)Application.Current.MainWindow).Log(exception.Message); } }
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 }); } }
public async Task <LUISIntentStatus> HandleIntent(string text) { try { if (_router == null) { var handlers = new LUISIntentHandlers(); _router = IntentRouter.Setup("<Your APP ID>", "Your KEY", handlers, false); } var status = new LUISIntentStatus(); var handled = await _router.Route(text, status); return(status); } catch (Exception ex) { 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 }); } }
public GoogleCloudDialogflowV2WebhookResponse Post(GoogleCloudDialogflowV2WebhookRequest obj) { var botModel = ModelMapper.DialogFlowToModel(obj); if (botModel == null) { return(null); } botModel = IntentRouter.Process(botModel); return(ModelMapper.ModelToDialogFlow(botModel)); }
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result) { var activity = await result as Activity; var client = new LuisClient(modelId, subscriptionKey, domain); using (var router = IntentRouter.Setup <IntentHandlers>(client)) { var handled = await router.Route(activity.Text, this); } context.Wait(MessageReceivedAsync); }
private async void ProcessSpeech(string s) { // // BUG: If command is finished with Patrick the following code removes all preable and then patrick, resulting in an empty string to try and say // // try { s = s.Substring(s.IndexOf(callSign)); // commands must start with Patrick. Removes chatter before commands } catch (Exception e) { // no patrick found Debug.WriteLine("No Patrick found"); } if (s.Contains(callSign)) { string q = s.Replace(callSign, ""); //Removed the space at the end of Patrick if (q.Length == 0) { return; //Quick fix for BUG } // Set up our custom context for the intent handlers App.SpeechFunc speakresponse = this.Speak; // Generate the base API url for the LUIS application IntentHandlers ih = new IntentHandlers(); // Set up an intent router using the IntentHandlers class to process intents //using (var router = IntentRouter.Setup<IntentHandlers>(appid, appkey)) using (var router = IntentRouter.Setup(appid, appkey, ih)) { try { var handled = await router.Route(q, context, speakresponse); if (!handled) { speakresponse("I'm sorry. I am not able to do that at this time."); } } catch (Exception ex) { } } return; } }
public SkillResponse Post(SkillRequest skillRequest) { var commonModel = CommonModelMapper.AlexaToCommonModel(skillRequest); if (commonModel == null) { return(null); } commonModel = IntentRouter.Process(commonModel); return(CommonModelMapper.CommonModelToAlexa(commonModel)); }
public dynamic Post(AIResponse aiResponse) { var commonModel = CommonModelMapper.ApiAiToCommonModel(aiResponse); if (commonModel == null) { return(null); } commonModel = IntentRouter.Process(commonModel); return(CommonModelMapper.CommonModelToApiAi(commonModel)); }
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result) { var activity = await result as Activity; var aiResponse = apiAi.TextRequest(activity.Text); var commonModel = CommonModelMapper.ApiAiToCommonModel(aiResponse); commonModel = IntentRouter.Process(commonModel); await context.PostAsync(commonModel.Response.Text); context.Wait(MessageReceivedAsync); }
public SkillResponse Post(SkillRequest skillRequest) { var commonModel = CommonModelMapper.AlexaToCommonModel(skillRequest); if (commonModel == null) { return(null); } if (commonModel.Request.State == null || commonModel.Request.State == "COMPLETED") { commonModel = IntentRouter.Process(commonModel); } return(CommonModelMapper.CommonModelToAlexa(commonModel)); }
public async Task <dynamic> Post() { var json = await Request.Content.ReadAsStringAsync(); WebhookRequest request = CommonModelMapper.JsonToDialogflow(json); var commonModel = CommonModelMapper.DialogflowToCommonModel(request); if (commonModel == null) { return(null); } commonModel = IntentRouter.Process(commonModel); return(CommonModelMapper.CommonModelToDialogflow(commonModel)); }
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result) { var activity = await result as Activity; var aiResponse = apiAi.TextRequest(string.IsNullOrWhiteSpace(activity.Text) ? "Hello" : activity.Text); var commonModel = CommonModelMapper.ApiAiToCommonModel(aiResponse); commonModel = IntentRouter.Process(commonModel); // calculate something for us to return int length = (activity.Text ?? string.Empty).Length; // return our reply to the user await context.PostAsync(aiResponse.Result.Fulfillment.Speech); //await context.PostAsync($"You sent {activity.Text} which was {length} characters"); context.Wait(MessageReceivedAsync); }
static void Main(string[] args) { //var query = new EnglishQuery(); //query.Predict("what is the weather in tokyo").Wait(); //var result = query.Result; var objWeather = new WeatherApp(); var luisClient = new LuisClient("f3a00b57-72d0-4817-ad66-f1e2cb739d62", "0412598c6e17402280a6d10d02b0321d", true); IntentRouter router = IntentRouter.Setup <WeatherApp>(luisClient); Task <bool> taskResult = router.Route("weather in delhi", objWeather); taskResult.Wait(); Console.WriteLine("Task Completed"); Console.ReadLine(); }
public dynamic Post(AIResponse aiResponse) { var commonModel = CommonModelMapper.DialogFlowToCommonModel(aiResponse); if (commonModel == null) { return(null); } commonModel = IntentRouter.Process(commonModel); return(CommonModelMapper.CommonModelToDialogFlow(commonModel)); ////var response = new ////{ //// fulfillmentText = Handlers.WelcomeIntent.Process(new CommonModel()).Response.Text, //// ////Text = "Hello!!" ////}; ////return response; }
public SkillResponse post(SkillRequest skillRequest) { var response = new SkillResponse() { Version = "2.0", Response = new ResponseBody() }; var responseText = string.Empty; var intentRequest = skillRequest.Request as IntentRequest; var commonModel = CommonModelMapper.AlexaToCommonModel(skillRequest); if (commonModel == null) { return(null); } commonModel = IntentRouter.Process(commonModel); return(CommonModelMapper.CommonModelToAlexa(commonModel)); }
public dynamic Post(AIResponse aIResponse) { var commonModel = CommonModelMapper.ApiAiToCommonModel(aIResponse); if (commonModel == null) { return(null); } try { commonModel = IntentRouter.Process(commonModel); } catch (DbEntityValidationException ex) { foreach (var entityValidationErrors in ex.EntityValidationErrors) { foreach (var validationError in entityValidationErrors.ValidationErrors) { Debug.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage); } } } return(CommonModelMapper.CommonModelToApiAi(commonModel)); }
public WeatherApp() { this.__luisClient = new LuisClient(Globals.LUIS_APPID, Globals.LUIS_APPKEY, true); this.__router = IntentRouter.Setup <WeatherApp>(this.__luisClient); }
public PersonalAssistantApp() { this.__luisClient = new LuisClient(Globals.LUIS_APPID, Globals.LUIS_APPKEY, true); this.__router = IntentRouter.Setup <PersonalAssistantApp>(this.__luisClient); }