private void ShowUserAccountsOptions(IDialogContext context) { PromptDialog.Choice(context, OnOptionSelectedAsync, _clientAccounts .Select(x => x.AccountNumber).ToList(), TextProvider.Provide(TextCategory.ACCOUNTBALANCE_MoreThanOneAccount), TextProvider.Provide(TextCategory.COMMON_NotValidOption)); }
public override async Task StartAsync(IDialogContext context) { List <Branch> branches = DAL.GetBranches(); IMessageActivity selectBranchReply = context.MakeMessage(); selectBranchReply.AttachmentLayout = AttachmentLayoutTypes.List; selectBranchReply.Text = TextProvider.Provide(TextCategory.SELECTBRANCH_PleaseSelect); selectBranchReply.Attachments = new List <Attachment>(); foreach (Branch branch in branches) { List <CardImage> cardImages = new List <CardImage>(); cardImages.Add(new CardImage("https://image.ibb.co/fPqt70/blue-location-icon.png")); ThumbnailCard thumbnailCard = new ThumbnailCard() { Images = cardImages, Title = branch.BranchName, Subtitle = $"{branch.ZipCode} {branch.City}, {branch.Street} {branch.HouseNumber}.", Text = $"Open on weekdays: {branch.WeekDayOpeningHours}", Tap = new CardAction(ActionTypes.PostBack, value: branch.BranchId.ToString()) }; selectBranchReply.Attachments.Add(thumbnailCard.ToAttachment()); } await context.PostAsync(selectBranchReply); context.Wait(BranchIdReceivedAsync); }
public override async Task StartAsync(IDialogContext context) { List <DebitCard> clientDebitCards = DAL.GetClientDebitCards(1); IMessageActivity selectCardReply = context.MakeMessage(); //itt állítjuk be, hogy görgethető legyen a menüsor selectCardReply.AttachmentLayout = AttachmentLayoutTypes.Carousel; selectCardReply.Text = TextProvider.Provide(TextCategory.SELECTCARD_PleaseSelect); selectCardReply.Attachments = new List <Attachment>(); foreach (DebitCard card in clientDebitCards) { List <CardImage> cardImages = new List <CardImage>(); List <CardAction> cardButtons = new List <CardAction>(); cardImages.Add(new CardImage("https://image.ibb.co/jPo20L/mastercard-blue.png")); cardButtons.Add(new CardAction(ActionTypes.PostBack, "Select", value: card.DebitCardId.ToString())); HeroCard hc = new HeroCard() { Images = cardImages, Title = card.DebitCardType.Type, Subtitle = card.CardNumber, Text = "Expiration: " + (card.ExpirationDate != null ? card.ExpirationDate.Value.ToString("MM'/'yy") : "UNKNOWN"), Buttons = cardButtons }; selectCardReply.Attachments.Add(hc.ToAttachment()); } await context.PostAsync(selectCardReply); context.Wait(CardIdReceivedAsync); }
public static IForm <BranchAppointmentForm> BuildForm() { return(new FormBuilder <BranchAppointmentForm>() .Message(TextProvider.Provide( TextCategory.BRANCHAPPOINTMENT_Welcome)) .Build()); }
public override async Task StartAsync(IDialogContext context) { switch (_limitType) { case CardLimitType.PurchaseLimit: await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_OldPurchaseLimit) + _selectedCard.DailyPaymentLimit + " " + _cardCurrencyIso); await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_InputPurchaseLimit)); context.Wait(ResumeAfterLimitChangedAsync); break; case CardLimitType.CashWithdrawalLimit: await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_OldWithdrawalLimit) + _selectedCard.DailyCashWithdrawalLimit + " " + _cardCurrencyIso); await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_InputWithdrawalLimit)); context.Wait(ResumeAfterLimitChangedAsync); break; default: throw new ArgumentOutOfRangeException(); } }
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result) { IMessageActivity message = await result; _clientDebitCards = DAL.GetClientDebitCards(_clientId); switch (_clientDebitCards.Count) { case 1: int cardId = _clientDebitCards.Single().DebitCardId; await PostLimitInformationAsync(context, cardId); context.Done <object>(null); break; case 0: await context.PostAsync(TextProvider.Provide(TextCategory.GETCARDLIMIT_ZeroCard)); context.Done <object>(null); break; default: await context.PostAsync(TextProvider.Provide(TextCategory.GETCARDLIMIT_MoreThanOneCard)); context.Call(new SelectCardDialog(), ResumeAfterSelectCardDialogAsync); break; } }
private async Task ResumeAfterSearchBranchDialogAsync(IDialogContext context, IAwaitable <object> result) { await result; PromptDialog.Confirm(context, ResumeBookAppointmentBranchConfirmDialogAsync, TextProvider.Provide(TextCategory.BRANCHAPPOINTMENT_WishToBook), TextProvider.Provide(TextCategory.COMMON_NotUnderstandable)); }
private async Task ResumeAfterGetCardLimitDialogAsync(IDialogContext context, IAwaitable <object> result) { await result; PromptDialog.Confirm(context, ResumeAfterSetLimitConfirmDialogAsync, TextProvider.Provide(TextCategory.SETCARDLIMIT_WishToChange), TextProvider.Provide(TextCategory.COMMON_NotUnderstandable)); }
private async Task ResumeAfterSelectBranchDialogAsync(IDialogContext context, IAwaitable <int> result) { int branchId = await result; Branch selectedBranch = DAL.GetBranch(branchId); await context.PostAsync( $"{TextProvider.Provide(TextCategory.SELECTBRANCH_SelectedBranch)}\nName: {selectedBranch.BranchName}\nAddress: {selectedBranch.ZipCode} {selectedBranch.City}, {selectedBranch.Street} {selectedBranch.HouseNumber}."); context.Done <object>(null); }
public async Task GreetAsync(IDialogContext context, LuisResult result) { if (CheckMinimumIntentScore(result.TopScoringIntent.Score)) { await context.PostAsync(TextProvider.Provide(TextCategory.GREETING)); } else { await AskForAccurateInput(context); } }
private void CreateLimitTypeChoice(IDialogContext context) { PromptDialog.Choice(context, ResumeAfterLimitTypeChoiceAsync, new[] { CardLimitType.PurchaseLimit, CardLimitType.CashWithdrawalLimit, CardLimitType.Both }, TextProvider.Provide(TextCategory.SETCARDLIMIT_PleaseSelectLimitType), TextProvider.Provide(TextCategory.COMMON_NotValidOption), descriptions: new[] { TextProvider.Provide(TextCategory.SETCARDLIMIT_PurchaseLimitDesc), TextProvider.Provide(TextCategory.SETCARDLIMIT_WithDrawalLimitDesc), TextProvider.Provide(TextCategory.SETCARDLIMIT_BothLimitTypeDesc) }); }
private async Task PostLimitInformationAsync(IDialogContext context, int cardId) { DebitCard card = _clientDebitCards.Single(x => x.DebitCardId == cardId); string cardTypeName = card.DebitCardType.Type; int withdrawLimit = card.DailyCashWithdrawalLimit ?? 0; int purchaseLimit = card.DailyPaymentLimit ?? 0; string currency = card.Account.Currency; await context.PostAsync(TextProvider.Provide(TextCategory.GETCARDLIMIT_WithdrawalLimit) + withdrawLimit + " " + currency); await context.PostAsync(TextProvider.Provide(TextCategory.GETCARDLIMIT_PurchaseLimit) + purchaseLimit + " " + currency); }
private async Task ResumeAfterSetCardLimitInitializationDialogAsync(IDialogContext context, IAwaitable <bool> result) { bool success = await result; if (success) { await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_Success)); } else { await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_Error)); } context.PrivateConversationData.RemoveValue("selectedCardId"); await HelpMore(context); }
private async Task ResumeAfterLimitChangedAsync(IDialogContext context, IAwaitable <IMessageActivity> result) { string newLimitAsString = (await result).Text; bool success = int.TryParse(newLimitAsString, out int newLimit); if (!success || newLimit <= 0) { await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_InvalidAmount)); context.Wait(ResumeAfterLimitChangedAsync); } else { DAL.UpdateCardLimit(_cardId, _limitType, newLimit); CardLimitModificationResult modificationResult; switch (_limitType) { case CardLimitType.PurchaseLimit: modificationResult = new CardLimitModificationResult() { PurchaseLimitChanged = true, PurchaseLimit = newLimit }; await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_PurchaseLimitChanged) + newLimit + " " + _cardCurrencyIso); break; case CardLimitType.CashWithdrawalLimit: modificationResult = new CardLimitModificationResult() { WithDrawalLimitChanged = true, WithDrawalLimit = newLimit }; await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_WithdrawalLimitChanged) + newLimit + " " + _cardCurrencyIso); break; default: throw new ArgumentOutOfRangeException(); } context.Done(modificationResult); } }
private async Task BranchIdReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result) { IMessageActivity branchIdAsString = await result; if (int.TryParse(branchIdAsString.Text, out int branchId)) { context.PrivateConversationData.SetValue("branchId", branchId); context.Done(branchId); } else { await context.PostAsync(TextProvider.Provide(TextCategory.SELECTBRANCH_InvalidBranchIdentifier)); await context.PostAsync(TextProvider.Provide(TextCategory.SELECTBRANCH_PleaseSelect)); context.Wait(RetryAsync); } }
private async Task RetryAsync(IDialogContext context, IAwaitable <IMessageActivity> result) { IMessageActivity branchIdAsString = await result; if (int.TryParse(branchIdAsString.Text, out int branchId)) { context.PrivateConversationData.SetValue("branchId", branchId); context.Done(branchId); } else { await context.PostAsync(TextProvider.Provide(TextCategory.SELECTBRANCH_InvalidBranchIdentifier)); await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_TooManyAttempt)); context.Reset(); } }
private async Task <Activity> HandleSystemMessage(Activity activity) { string messageType = activity.GetActivityType(); if (messageType == ActivityTypes.DeleteUserData) { // Implement user deletion here // If we handle user deletion, return a real message } else if (messageType == ActivityTypes.ConversationUpdate) { // Handle conversation state changes, like members being added and removed // Use Activity.MembersAdded and Activity.MembersRemoved and Activity.Action for info // Not available in all channels IConversationUpdateActivity update = activity; using (ILifetimeScope scope = Microsoft.Bot.Builder.Dialogs.Internals.DialogModule.BeginLifetimeScope(Conversation.Container, activity)) { IConnectorClient client = scope.Resolve <IConnectorClient>(); if (update.MembersAdded.Any()) { Activity reply = activity.CreateReply(); foreach (ChannelAccount newMember in update.MembersAdded) { if (newMember.Id != activity.Recipient.Id) { reply.Text = TextProvider.Provide(TextCategory.GREETING_UserAdded); await client.Conversations.ReplyToActivityAsync(reply); } } } } } else if (messageType == ActivityTypes.ContactRelationUpdate) { // Handle add/remove from contact lists // Activity.From + Activity.Action represent what happened } else if (messageType == ActivityTypes.Typing) { // Handle knowing that the user is typing } return(null); }
private async Task RetryAsync(IDialogContext context, IAwaitable <IMessageActivity> result) { IMessageActivity cardIdAsString = await result; if (int.TryParse(cardIdAsString.Text, out int cardId)) { //betöltjük a kiválasztott kártyát a conversationdata-ba context.PrivateConversationData.SetValue("selectedCardId", cardId); context.Done(cardId); } else { await context.PostAsync(TextProvider.Provide(TextCategory.SELECTCARD_InvalidCardIdentifier)); await context.PostAsync(TextProvider.Provide(TextCategory.COMMON_TooManyAttempt)); context.Reset(); } }
private async Task ResumeBookAppointmentBranchConfirmDialogAsync(IDialogContext context, IAwaitable <bool> result) { try { bool appoint = await result; if (appoint) { await context.Forward(FormDialog.FromForm(BranchAppointmentForm.BuildForm), ResumeAfterBranchAppointmentForm, Activity.CreateMessageActivity()); } else { await HelpMore(context); } } catch (TooManyAttemptsException) { await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_TooManyAttempt)); } }
public async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result) { _clientAccounts = DAL.GetClientAccounts(_clientId); if (_clientAccounts.Count > 1) { ShowUserAccountsOptions(context); } else if (_clientAccounts.Count == 1) { _selectedAccount = _clientAccounts.Single(); await WriteOutBalanceAsync(context, _selectedAccount); context.Done(true); } else { await context.PostAsync(TextProvider.Provide(TextCategory.ACCOUNTBALANCE_ZeroAccount)); context.Done(true); } }
private async Task ResumeAfterBranchAppointmentForm(IDialogContext context, IAwaitable <BranchAppointmentForm> result) { BranchAppointmentForm appointment = await result; if (appointment != null) { if (context.PrivateConversationData.TryGetValue("branchId", out int branchId)) { DAL dal = new DAL(); //A vasárnapot átalakítjuk hetedik napra int currentDayOfWeek = (int)DateTime.Now.DayOfWeek == 0 ? 7 : (int)DateTime.Now.DayOfWeek; int remainsFromWeek = 7 - currentDayOfWeek; int selectedWorkDay = (int)appointment.Days + 1; DateTime bookingDate = DateTime.Now .AddDays(selectedWorkDay + 7 * (int)appointment.Term + remainsFromWeek).Date.AddHours((int)appointment.Hour); dal.InsertAppointmentBooking(branchId, _clientId, (int)appointment.Case, bookingDate); await context.PostAsync(TextProvider.Provide(TextCategory.BRANCHAPPOINTMENT_BookingSaved)); } } await HelpMore(context); }
private async Task ResumeAfterSetLimitConfirmDialogAsync(IDialogContext context, IAwaitable <bool> result) { try { bool changeSettings = await result; if (changeSettings) { context.Call( new SetCardLimitInitializationDialog(1, context.PrivateConversationData.GetValue <int>("selectedCardId")), ResumeAfterSetCardLimitInitializationDialogAsync); } else { await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_WontChange)); } } catch (TooManyAttemptsException) { await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_TooManyAttempt)); } }
private async Task WriteOutBalanceAsync(IDialogContext context, Account account) { await context.PostAsync(TextProvider.Provide(TextCategory.ACCOUNTBALANCE_BalanceIs) + $"{account.Balance} {account.Currency}"); }
//ez reagál a felhasználónak, amennyiben a score alapján ez a dialógus veszi át az irányítást protected override async Task PostAsync(IActivity item, string state, CancellationToken token) { InterruptionDialog cancelInterruptionDialog = new InterruptionDialog(TextProvider.Provide(TextCategory.INTERRUPTION_Cancel)); IDialog <IMessageActivity> cancelInterruption = cancelInterruptionDialog.Void <object, IMessageActivity>(); task.Call(cancelInterruption, null); task.Reset(); }
protected override async Task PostAsync(IActivity item, string state, CancellationToken token) { InterruptionDialog helpInterruptionDialog = new InterruptionDialog(TextProvider.Provide(TextCategory.INTERRUPTION_Help)); IDialog <IMessageActivity> helpInterruption = helpInterruptionDialog.Void <object, IMessageActivity>(); task.Call(helpInterruption, null); //await task.PollAsync(token); }
private async Task AskForAccurateInput(IDialogContext context) { await context.PostAsync(TextProvider.Provide(TextCategory.COMMON_AskingMoreAccurateInput)); }
private async Task HelpMore(IDialogContext context) { await context.PostAsync( TextProvider.Provide(TextCategory.COMMON_HelpMore)); }