コード例 #1
0
        private async Task PromptForTimeslot(IDialogContext context)
        {
            try
            {
                DateTime selectedDate;
                context.UserData.TryGetValue <DateTime>("SessionFinderSelectedDate", out selectedDate);

                List <string> choices = new List <string>()
                {
                    "Morning", "Afternoon"
                };

                EditablePromptDialog.Choice(context,
                                            TimeSlotChoiceAsync,
                                            choices,
                                            "Which time?",
                                            "I didn't understand that. Please choose one of the options",
                                            2);
            }
            catch (Exception e)
            {
                _telemetry.TrackTrace("PromptForTimeslot exception thrown");
                _telemetry.TrackException(e);

                // Cleanup context data to ensure next time round we don't remember anything
                await RemoveSessionFinderContextData(context);

                await context.PostAsync("An error ocurred whilst trying to ascertain the time you were interested in, please try again later.");

                context.Wait(MessageReceived);
            }
        }
コード例 #2
0
        public async Task None(IDialogContext context, LuisResult result)
        {
            //check the language - it may not be english!

            if (TranslatorService.Instance.GetLanguage(context) != "en")
            {
                var checkLanguage = await TranslatorService.Instance.Detect(result.Query);

                if (checkLanguage != "en")
                {
                    context.UserData.SetValue("checkLanguage", checkLanguage);

                    EditablePromptDialog.Choice(context,
                                                LanuageSelectionChoicesAsync,
                                                new List <string> {
                        "Yes", "No"
                    },
                                                await TranslatorService.Instance.Translate("You are not speaking English! Would you like me to translate for you?", "en", checkLanguage),
                                                await TranslatorService.Instance.Translate("I didn't understand that. Please choose one of the options", "en", checkLanguage),
                                                2);

                    return;
                }
            }

            await context.PostAsync("I'm sorry. I didn't understand you.");

            context.Wait(MessageReceived);
        }
コード例 #3
0
        public async Task ProcessPizzaForm(IDialogContext context, LuisResult result)
        {
            var entities = new List <EntityRecommendation>(result.Entities);

            if (!entities.Any((entity) => entity.Type == "Kind"))
            {
                // Infer kind
                foreach (var entity in result.Entities)
                {
                    string kind = null;
                    switch (entity.Type)
                    {
                    case "Signature": kind = "Signature"; break;

                    case "GourmetDelite": kind = "Gourmet delite"; break;

                    case "Stuffed": kind = "stuffed"; break;

                    default:
                        if (entity.Type.StartsWith("BYO"))
                        {
                            kind = "byo";
                        }
                        break;
                    }
                    if (kind != null)
                    {
                        entities.Add(new EntityRecommendation(type: "Kind")
                        {
                            Entity = kind
                        });
                        break;
                    }
                }
            }

            var topicChoices = new List <string>
            {
                "Ham",
                "Pineapple",
                "Meatlovers"
            };


            EditablePromptDialog.Choice(context,
                                        PizzaFormComplete,
                                        topicChoices,
                                        "Which toppings?",
                                        "I didn't understand that. Please choose one of the toppings",
                                        2);
        }
コード例 #4
0
        public async Task NoIntent(IDialogContext context, LuisResult result)
        {
            var sentReply = await QueryQnaMakerAsync(context, result);

            if (sentReply)
            {
                return;
            }

            // Add Azure Search fall-through here if required
            // sentReply = await QueryAzureSearch(contenxt, result);
            //if (sentReply)
            //{
            //    return;
            //}

            if (_translatorService.GetLanguage(context) != "en")
            {
                var checkLanguage = await _translatorService.Detect(result.Query);

                if (checkLanguage != "en")
                {
                    context.UserData.SetValue("checkLanguage", checkLanguage);

                    EditablePromptDialog.Choice(context,
                                                LanuageSelectionChoicesAsync,
                                                new List <string> {
                        "Yes", "No"
                    },
                                                await _translatorService.Translate(
                                                    "You are not speaking English! Would you like me to translate for you?", "en",
                                                    checkLanguage),
                                                await _translatorService.Translate(
                                                    "I didn't understand that. Please choose one of the options", "en",
                                                    checkLanguage),
                                                2);

                    return;
                }
            }

            context.Wait(MessageReceived);
        }