public async Task StartAsync(IDialogContext context) { // we don't yet have a restaurant; prompt the user to select a restaurant var response = string.Format(Properties.Resources.RESTAURANT_REQUEST, context.Cuisine(), context.Location()); await PostAsync(context, response); // wait for the user to respond with a restaurant context.Wait(MessageReceived); }
// Methods public override async Task StartAsync(IDialogContext context) { if (string.IsNullOrWhiteSpace(context.Cuisine())) { // we don't yet have a cuisine; prompt the user to select a cuisine var response = string.Format(Properties.Resources.CUISINE_REQUEST, context.Location()); await PostAsync(context, response); // wait for the user to respond with a cuisine context.Wait(MessageReceived); } else if (!await RestaurantService.HasRestaurantsAsync(context.Location(), context.Cuisine())) { // we couldn't find any restaurants for the given location and cuisine // ask the user to provide a different cuisine await NotFound(context, context.Cuisine()); } else { // we already have a cuisine; move onto the restaurant dialog context.Call(new RestaurantDialog(), null); } }
// Methods public async Task StartAsync(IDialogContext context) { if (string.IsNullOrWhiteSpace(context.Cuisine())) { // we don't yet have a cuisine; prompt the user to select a cuisine var response = string.Format(Properties.Resources.CUISINE_REQUEST, context.Location()); await PostAsync(context, response); // wait for the user to respond with a cuisine context.Wait(MessageReceived); } else { // we already have a cuisine; move onto the restaurant dialog context.Call(new RestaurantDialog(), null); } }
private async Task PostAsync(IDialogContext context, string text) { // create a new 'card' for each restaurant that we find var restaurants = await RestaurantService.GetRestaurantsAsync(context.Location(), context.Cuisine()); var attachments = restaurants.Select(r => CreateAttachment(r)).ToList(); // create a new new message including the restaurant cards to be send to the user var message = context.MakeMessage(); message.Text = text; message.Attachments = attachments; message.AttachmentLayout = AttachmentLayoutTypes.Carousel; // send the message to the user await context.PostAsync(message); }
public override async Task StartAsync(IDialogContext context) { if (context.Restaurant() == null) { // we don't yet have a restaurant; prompt the user to select a restaurant var response = string.Format(Properties.Resources.RESTAURANT_REQUEST, context.Cuisine(), context.Location()); await PostAsync(context, response); // wait for the user to respond with a restaurant context.Wait(MessageReceived); } else if (!await RestaurantService.RestaurantExists(context.Location(), context.Restaurant().Name)) { // we couldn't find the current restaurant in the current location // ask the user to provide a different restaurant and wait for a response await NotFound(context, context.Location()); } else { // we already have a restaurant; move onto the when dialog context.Call(new WhenDialog(), null); } }