private async Task OnRecordCompleted(RecordOutcomeEvent recordOutcomeEvent) { recordOutcomeEvent.ResultingWorkflow.Actions = new List <ActionBase> { GetPromptForText(EndingMessage), new Hangup { OperationId = Guid.NewGuid().ToString() } }; // Convert the audio to text if (recordOutcomeEvent.RecordOutcome.Outcome == Outcome.Success) { var record = await recordOutcomeEvent.RecordedContent; string text = await this.GetTextFromAudioAsync(record); StockBot2.StockLUIS Data = new StockBot2.StockLUIS(); Data = await GetEntityFromLUIS(text); var callState = this.callStateMap[recordOutcomeEvent.ConversationResult.Id]; await this.SendSTTResultToUser("We detected the following audio: " + Data.entities[0].entity, callState.Participants); } recordOutcomeEvent.ResultingWorkflow.Links = null; this.callStateMap.Remove(recordOutcomeEvent.ConversationResult.Id); }
private static async Task <StockBot2.StockLUIS> GetEntityFromLUIS(string Query) { Query = Uri.EscapeDataString(Query); StockBot2.StockLUIS Data = new StockBot2.StockLUIS(); using (System.Net.Http.HttpClient client = new System.Net.Http.HttpClient()) { string RequestURI = "https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/3265728d-0c1a-4b89-a097-a7220b717404?subscription-key=62a8a6f896d248379b773c3dc8179269&timezoneOffset=330&verbose=true&q=" + Query; System.Net.Http.HttpResponseMessage msg = await client.GetAsync(RequestURI); if (msg.IsSuccessStatusCode) { var JsonDataResponse = await msg.Content.ReadAsStringAsync(); Data = Newtonsoft.Json.JsonConvert.DeserializeObject <StockBot2.StockLUIS>(JsonDataResponse); } } return(Data); }