public IHttpActionResult GetReviews(string query) { var data = _walmartHelper.GetSearchData(query.Replace(" ", "+")); if (data != null && data.items.Any()) { var reviews = _walmartHelper.GetReviews(data.items[0].itemId); return(Ok(reviews)); } return(null); }
private SpeechletResponse ProcessReviews(Intent intent) { // Get the slots from the intent. Dictionary <string, Slot> slots = intent.Slots; Slot productSlot = slots[Constants.ProductSlot]; // Check for product and create output to user. if (productSlot != null && !string.IsNullOrEmpty(productSlot.Value)) { string product = productSlot.Value; var output = string.Empty; var data = _walmartHelper.GetSearchData(product.Replace(" ", "+")); if (data != null && data.items.Any()) { var reviews = _walmartHelper.GetReviews(data.items[0].itemId); //read first review and ask for more if needed output = reviews[0].reviewText; } return(BuildSpeechletResponse("Reviews", output, true)); } return(BuildSpeechletResponse("Reviews", Constants.Error, true)); }