コード例 #1
0
        public async Task Greeting(IDialogContext context, LuisResult result)
        {
            await context.PostAsync("Hello! I will be your guide today.");

            var userModel = new UserModel();

            if (result.TryFindEntity("CandidateName", out EntityRecommendation candidate))
            {
                userModel.Name = candidate.Entity;
            }
            else
            {
                if (context.GetProperty <string>(nameof(userModel.Name), out var name))
                {
                    userModel.Name = name;
                }
            }

            var hasMail = context.GetProperty <string>(nameof(userModel.Email), out var email);

            if (hasMail)
            {
                userModel.Email = email;
            }

            var registrationForm = new FormDialog <UserModel>(userModel, _userModel, FormOptions.PromptInStart);

            context.Call(registrationForm, GreetingCallback);
        }