private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> argument) { var message = await argument; if (Regex.IsMatch(message.Text, ".*order.*", RegexOptions.IgnoreCase)) { context.Call(OrderDialog.CreateDialog(), BeerOrderedAsync); return; } if (Regex.IsMatch(message.Text, ".*recommend.*", RegexOptions.IgnoreCase)) { context.Call(RecommendationDialog.CreateDialog(null, null, null, null), BeerRecommendedAsync); return; } if (Regex.IsMatch(message.Text, "^help.*", RegexOptions.IgnoreCase)) { await context.SpeakAsync("You can type 'order' for ordering beers and 'recommend' for getting some recommendations", InputHints.ExpectingInput); context.Wait(MessageReceivedAsync); } else if (Regex.IsMatch(message.Text, "^(bye|adios).*", RegexOptions.IgnoreCase)) { await context.SpeakAsync("Thank you. Come again!", InputHints.ExpectingInput); context.Done(true); } else { await context.SpeakAsync("I don't quite understand. Say 'help' for getting acquianted with me.", InputHints.ExpectingInput); context.Wait(MessageReceivedAsync); } }
public Task OnOrderBeerAsync(IDialogContext context, IAwaitable <IMessageActivity> messageAwaitable, LuisResult luisResult) { var beerName = GetEntity(luisResult, BeerNameEntityName); var chaser = GetEntity(luisResult, ChaserEntityName); var sideDish = GetEntity(luisResult, SideDishEntityName); context.Call(OrderDialog.CreateDialog(beerName, chaser, sideDish), BeerOrderedAsync); return(Task.FromResult((object)null)); }
private async Task ConfirmOrderLastKnownBeerAsync(IDialogContext context, IAwaitable <bool> isConfirmed) { if (await isConfirmed) { var beerName = context.UserData.GetValue <string>(LastBeerOrderedKeyName); context.Call(OrderDialog.CreateDialog(beerName), BeerOrderedAsync); } else { await context.SpeakAsync("No problem. So how can I help you?", InputHints.ExpectingInput); context.Wait(MessageReceived); } }
private async Task CompleteBeerRecommendationAsync(IDialogContext context, IAwaitable <bool> shouldOrder) { Debug.Assert(_recommendedBeer != null); if (await shouldOrder) { context.Call(OrderDialog.CreateDialog(_recommendedBeer.Name), BeerOrderedAsync); } else { await context.SpeakAsync("So what would you like to do next?", InputHints.ExpectingInput); context.Wait(MessageReceived); } _recommendedBeer = null; }