public static SinglePolicyRootObject GetAllPolicyById(string id) { client = new HttpClient(); client.BaseAddress = new Uri(host); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); SinglePolicyRootObject allPolicies = null; string path = string.Format(idBasedPolicy, id, client_id); HttpResponseMessage response = client.GetAsync(path).Result; if (response.IsSuccessStatusCode) { string result = response.Content.ReadAsStringAsync().Result; allPolicies = Newtonsoft.Json.JsonConvert.DeserializeObject <SinglePolicyRootObject>(result); } return(allPolicies); }
public AlexaResponse IDBasedPolicyIntentHandler(Request request) { string speech = ""; string id = ""; if (request.SlotsList.Any()) { id = request.SlotsList.FirstOrDefault(s => s.Key == "id").Value; } try { string _policy = string.Empty; SinglePolicyRootObject policy = GetAllPolicyById(id); if (policy != null) { _policy = _policy + "<prosody rate=\"slow\">" + policy.result.text.Replace("<", "").Replace(">", "") + "</prosody>"; speech = _policy; } else { speech = "Could not locate information, please try with a different ID number."; } } catch { speech = "Road Star is currently experience voice issue, please try back shortly."; } var response = new AlexaResponse(speech, false, AddSSML(speech)); speech = "You can find Alternative Fuel policy contacts in each state by saying, Get me All Contacts for Virginia"; response.Response.Reprompt.OutputSpeech.Text = speech; response.Response.Reprompt.OutputSpeech.Ssml = AddSSML(speech); return(response); }