示例#1
0
        protected override async Task PostAsync(IActivity item, string state, CancellationToken token)
        {
            // this.task.Reset();
            var message = item as IMessageActivity;

            if (message != null)
            {
                var incomingMessage = message.Text.ToLowerInvariant();
                var messageToSend   = string.Empty;

                //if (incomingMessage == "hello")
                //    messageToSend = "Hi! I am a bot";

                if (incomingMessage.ToLower().Contains("help") || incomingMessage.ToLower().Contains("support"))
                {
                    messageToSend = "help";
                    var helpDialog   = new HelpDialog();
                    var interruption = helpDialog.Void <object, IMessageActivity>();
                    this.task.Call(interruption, null);
                    await this.task.PollAsync(token);
                }

                if (incomingMessage.ToLower().Contains("cancel"))
                {
                    messageToSend = "cancel";

                    var canDialog    = new CancelDialog();
                    var interruption = canDialog.Void <object, IMessageActivity>();
                    this.task.Call(interruption, null);
                    await this.task.PollAsync(token);
                }
                if (incomingMessage.ToLower().Contains("exit") ||
                    incomingMessage.ToLower().Contains("abort") ||
                    incomingMessage.ToLower().Contains("start again"))
                {
                    messageToSend = "cancel";

                    var exitDialog   = new ExitDialog();
                    var interruption = exitDialog.Void <object, IMessageActivity>();
                    this.task.Call(interruption, null);
                    await this.task.PollAsync(token);
                }

                if (incomingMessage.ToLower().Contains("thanks") ||
                    incomingMessage.ToLower().Contains("thank you") ||
                    incomingMessage.ToLower().Contains("thanks once again"))
                {
                    messageToSend = "Thanks";

                    var happyDialog  = new HappyUserDialog();
                    var interruption = happyDialog.Void <object, IMessageActivity>();
                    this.task.Call(interruption, null);
                    await this.task.PollAsync(token);
                }
            }
        }
        protected override async Task PostAsync(IActivity item, string state, CancellationToken token)
        {
            var message = item as IMessageActivity;

            if (message != null)
            {
                var settingsDialog = new CancelDialog();

                var interruption = settingsDialog.Void <object, IMessageActivity>();

                this.task.Call(interruption, null);

                await this.task.PollAsync(token);
            }
        }