/// <summary> /// POST: api/Messages /// Receive a message from a user and reply to it /// </summary> public async Task <Message> Post([FromBody] Message message) { if (message.Type == "Message") { string QuestionString; TestLUIS testLUIS = await GetEntityFromLUIS(message.Text); if (testLUIS.intents.Count() > 0) { switch (testLUIS.intents[0].intent) { case "ExistingFeature": QuestionString = await GetFeature(testLUIS.entities[0].entity); break; default: QuestionString = "Sorry, I am not getting you..."; break; } } else { QuestionString = "Sorry, I am not getting you..."; } // return our reply to the user return(message.CreateReplyMessage(QuestionString)); } else { return(HandleSystemMessage(message)); } }
private static async Task <TestLUIS> GetEntityFromLUIS(string Query) { Query = Uri.EscapeDataString(Query); TestLUIS Data = new TestLUIS(); using (HttpClient client = new HttpClient()) { string RequestURI = "https://api.projectoxford.ai/luis/v1/application?id=8c964792-9689-4666-99bc-aa098ed9c12d&subscription-key=196293091bb94400a95df61554a4abc3&q=" + Query; HttpResponseMessage msg = await client.GetAsync(RequestURI); if (msg.IsSuccessStatusCode) { var JsonDataResponse = await msg.Content.ReadAsStringAsync(); Data = JsonConvert.DeserializeObject <TestLUIS>(JsonDataResponse); } } return(Data); }