Exemple #1
0
        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);
            }
        }
Exemple #2
0
        public Task OnRecommendBeerAsync(IDialogContext context, IAwaitable <IMessageActivity> messageAwaitable, LuisResult luisResult)
        {
            var beerName = GetEntity(luisResult, BeerNameEntityName);
            var brewery  = GetEntity(luisResult, BreweryEntityName);
            var category = GetEntity(luisResult, CategoryEntityName);
            var country  = GetEntity(luisResult, CountryEntityName);

            context.Call(RecommendationDialog.CreateDialog(beerName, brewery, category, country), BeerRecommendedAsync);
            return(Task.FromResult((object)null));
        }