private static Attachment BuildHeroCard(FoodCardModel currentFood) { var foodName = currentFood.name; var foodURL = currentFood.getCurrentURL(); var heroCard = new HeroCard { Title = String.Format("How about {0}?", foodName), Images = new List <CardImage> { new CardImage(foodURL) }, Buttons = new List <CardAction> { new CardAction(ActionTypes.ImBack, MoreOption, value: "Show me more " + foodName), new CardAction(ActionTypes.ImBack, NextOption, value: NextOption), new CardAction(ActionTypes.OpenUrl, FindOption, value: String.Format(yelpUrl, foodName)) } }; return(heroCard.ToAttachment()); }
private async Task UserChoice(IDialogContext context, IAwaitable <object> result) { var activity = await result; //await context.PostAsync($@"Hi {activity}!"); List <FoodModel> foodList = FoodModel.GetFoodList(); var userText = activity.ToString(); if (userText.Contains(MoreOption.Substring(0, 4))) { //More of the same food if (currentFood == null) { //No current food - generate random currentFood = getRandomFood(foodList); } else { currentFood.IncrementIndex(); } } else if (userText.Contains(NextOption)) { //Next food type currentFood = getRandomFood(foodList); } else if (userText.Contains(FindOption)) { //Find restaurant if (currentFood != null) { Uri uri = new Uri(String.Format(yelpUrl, currentFood.name)); await context.PostAsync("Our friends at Yelp will help you find " + currentFood.name.ToLower() + " here: " + uri.AbsoluteUri); return; } else { //User types find food without previous prompt PromptDialog.Choice <string>( context, UserChoice, new string[] { StartOption }, "Not sure what you mean... but I'm guessing you're hungry?", ErrorMsg, 3, PromptStyle.Auto); } } else { //New session- Show random food currentFood = getRandomFood(foodList); } //Image attachment message var message = context.MakeMessage(); var attachment = GetImageAttachment(currentFood.getCurrentURL()); message.Attachments.Add(attachment); await context.PostAsync(message); //Next available choice dialog PromptDialog.Choice <string>( context, UserChoice, new string[] { String.Format(MoreOption, currentFood.name), NextOption, FindOption }, "How about " + currentFood.name + "?", ChoiceErrorMsg, 3, PromptStyle.Auto); }