Пример #1
0
        private async Task <DialogTurnResult> FirstStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var activity = stepContext.Context.Activity;

            if (!activity.Text.Contains("We are Hungry") && !activity.Text.Contains("ccc"))
            {
                await stepContext.Context.SendActivityAsync(MessageFactory.Text("Please input \"We are Hungry\""), cancellationToken);

                var help    = new HelpService();
                var command = help.Command();
                await stepContext.Context.SendActivityAsync(MessageFactory.Text("You can give command"), cancellationToken);

                await stepContext.Context.SendActivityAsync(MessageFactory.Attachment(command), cancellationToken);

                if (string.IsNullOrWhiteSpace(activity.Text) && activity.Value != null)
                {
                    activity.Text = JsonConvert.SerializeObject(activity.Value);
                }

                return(await stepContext.EndDialogAsync());
            }
            else
            {
                return(await stepContext.NextAsync());
            }
        }
Пример #2
0
        protected override async Task OnMessageActivityAsync(ITurnContext <IMessageActivity> turnContext, CancellationToken cancellationToken)
        {
            if (turnContext.Activity.Text.Contains("Library"))
            {
                var libraryCard = await GetLibraryCard(turnContext);

                await turnContext.SendActivityAsync(MessageFactory.Attachment(libraryCard), cancellationToken);
            }
            else if (turnContext.Activity.Text.Contains("Pay"))
            {
                var memberId = turnContext.Activity.From.Id;
                var payCard  = _paymentService.CreatePayAdaptiveAttachment(memberId);
                await turnContext.SendActivityAsync(MessageFactory.Attachment(payCard), cancellationToken);
            }
            else if (turnContext.Activity.Text.Contains("payment"))
            {
                var memberId = turnContext.Activity.From.Id;
                var url      = JObject.FromObject(turnContext.Activity.Value).GetValue("payment").ToString();
                _paymentService.UpdatePayment(memberId, url);
                var payCard  = _paymentService.CreatePayAdaptiveAttachment(memberId);
                var activity = MessageFactory.Attachment(payCard);
                activity.Id = turnContext.Activity.ReplyToId;
                await turnContext.UpdateActivityAsync(activity, cancellationToken);

                await turnContext.SendActivityAsync(MessageFactory.Text("You update your payment link: " + url), cancellationToken);
            }
            else if (turnContext.Activity.Text.Contains("Customized Menu"))
            {
                var CustomMenucard = _customMenuService.CallCustomeCard();

                var NewID = turnContext.SendActivityAsync(MessageFactory.Attachment(CustomMenucard), cancellationToken).Result.Id;

                var UpdateActivity = MessageFactory.Attachment(_customMenuService.CallCustomeCard(NewID));
                UpdateActivity.Id = NewID; //指定要更新的activity
                await turnContext.UpdateActivityAsync(UpdateActivity, cancellationToken);
            }
            else if (turnContext.Activity.Text.Contains("Help"))
            {
                var help    = new HelpService();
                var card    = help.IntroductionCard();
                var command = help.Command();
                await turnContext.SendActivityAsync(MessageFactory.Attachment(card), cancellationToken);

                await turnContext.SendActivityAsync(MessageFactory.Text("You can give command"), cancellationToken);

                await turnContext.SendActivityAsync(MessageFactory.Attachment(command), cancellationToken);
            }
            //ting 要移動到訂單完成那邊 回覆pay
            else if (turnContext.Activity.Text.Contains("aaa"))
            {
                var memberId = turnContext.Activity.From.Id;
                var card     = new CreateCardService2().ReplyPayment(_paymentService, turnContext);
                await turnContext.SendActivityAsync(MessageFactory.Attachment(card), cancellationToken);
            }
            else
            {
                await Dialog.RunAsync(turnContext, ConversationState.CreateProperty <DialogState>(nameof(DialogState)), cancellationToken);
            }
        }