Exemple #1
0
        public RootTopic(IBotContext context) : base(context)
        {
            this.SubTopics.Add("namePrompt", (object[] args) =>
            {
                var namePrompt = new TextPrompt();

                namePrompt.Set
                .OnPrompt("What is your name?")
                .OnSuccess((ctx, value) =>
                {
                    this.ClearActiveTopic();

                    this.State.Name = value;

                    this.OnReceiveActivity(context);
                })
                .OnFailure((ctx, reason) =>
                {
                    this.ClearActiveTopic();

                    context.SendActivity("I'm sorry I'm having issues understanding you.");

                    this.OnReceiveActivity(context);
                });

                return(namePrompt);
            });

            this.SubTopics.Add("agePrompt", (object[] args) =>
            {
                var agePrompt = new IntPrompt();

                agePrompt.Set
                .OnPrompt("How old are you?")
                .OnSuccess((ctx, value) =>
                {
                    this.ClearActiveTopic();

                    this.State.Age = value;

                    this.OnReceiveActivity(context);
                })
                .OnFailure((ctx, reason) =>
                {
                    this.ClearActiveTopic();

                    context.SendActivity("I'm sorry I'm having issues understanding you.");

                    this.OnReceiveActivity(context);
                });

                return(agePrompt);
            });
        }
Exemple #2
0
        public RootTopic(IBotContext context) : base(context)
        {
            this.SubTopics.Add("namePrompt", (object[] args) =>
            {
                var namePrompt = new TextPrompt();

                namePrompt.Set
                .OnPrompt("What is your name?")
                .OnSuccess((ctx, value) =>
                {
                    this.ClearActiveTopic();

                    this.State.Name = value;

                    this.OnReceiveActivity(ctx);
                });

                return(namePrompt);
            });

            this.SubTopics.Add("agePrompt", (object[] args) =>
            {
                var agePrompt = new IntPrompt();

                agePrompt.Set
                .OnPrompt("How old are you?")
                .OnSuccess((ctx, value) =>
                {
                    this.ClearActiveTopic();

                    this.State.Age = value;

                    this.OnReceiveActivity(context);
                });

                return(agePrompt);
            });
        }
        public RootTopic(ITurnContext turnContext) : base(turnContext)
        {
            this.SubTopics.Add("namePrompt", (object[] args) =>
            {
                var namePrompt = new TextPrompt();

                namePrompt.Set
                .OnPrompt("What is your name?")
                .OnSuccess((turn, value) =>
                {
                    ClearActiveTopic();

                    State.Name = value;
                    // Returns a Task, should be returned so OnTurn that called it can return that.
                    OnTurn(turn);
                });

                return(namePrompt);
            });

            this.SubTopics.Add("agePrompt", (object[] args) =>
            {
                var agePrompt = new IntPrompt();

                agePrompt.Set
                .OnPrompt("How old are you?")
                .OnSuccess((turn, value) =>
                {
                    ClearActiveTopic();

                    State.Age = value;

                    OnTurn(turn);
                });

                return(agePrompt);
            });
        }