public AdapterWithErrorHandler(ICredentialProvider credentialProvider, ILogger <BotFrameworkHttpAdapter> logger, ConversationState conversationState = null) : base(credentialProvider) { // combine path for cross platform support string[] paths = { ".", "Resources", "AdapterWithErrorHandler.LG" }; string fullPath = Path.Combine(paths); _lgEngine = TemplateEngine.FromFiles(fullPath); OnTurnError = async(turnContext, exception) => { // Log any leaked exception from the application. logger.LogError($"Exception caught : {exception.Message}"); // Send a catch-all apology to the user. await turnContext.SendActivityAsync(_lgEngine.EvaluateTemplate("SomethingWentWrong", null)); if (conversationState != null) { try { // Delete the conversationState for the current conversation to prevent the // bot from getting stuck in a error-loop caused by being in a bad state. // ConversationState should be thought of as similar to "cookie-state" in a Web pages. await conversationState.DeleteAsync(turnContext); } catch (Exception e) { logger.LogError($"Exception caught on attempting to Delete ConversationState : {e.Message}"); } } }; }
public MainDialog(ILogger <MainDialog> logger) : base(nameof(MainDialog)) { _logger = logger; // combine path for cross platform support string[] paths = { ".", "Resources", "MainDialog.LG" }; string mainDialogLGFile = Path.Combine(paths); paths = new string[] { ".", "Resources", "Cards.LG" }; string cardsLGFile = Path.Combine(paths); string[] lgFiles = { mainDialogLGFile, cardsLGFile }; // For simple LG resolution, we will call the TemplateEngine directly. _lgEngine = TemplateEngine.FromFiles(lgFiles); // Resource explorer helps load all .lg files for this project. // TextMessageActivityGenerator is used to transform chatdown style cards into full blown activity. var resourceExplorer = ResourceExplorer.LoadProject(Directory.GetCurrentDirectory(), ignoreFolders: new string[] { "models" }); _activityGenerator = new TextMessageActivityGenerator(new LGLanguageGenerator(resourceExplorer)); AddDialog(new ChoicePrompt(nameof(ChoicePrompt))); AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[] { ChoiceCardStepAsync, ShowCardStepAsync, })); // The initial child Dialog to run. InitialDialogId = nameof(WaterfallDialog); }
public UserProfileDialog(UserState userState) : base(nameof(UserProfileDialog)) { _userProfileAccessor = userState.CreateProperty <UserProfile>("UserProfile"); // combine path for cross platform support string[] paths = { ".", "Resources", "UserProfileDialog.LG" }; string fullPath = Path.Combine(paths); _lgEngine = TemplateEngine.FromFiles(fullPath); // This array defines how the Waterfall will execute. var waterfallSteps = new WaterfallStep[] { TransportStepAsync, NameStepAsync, NameConfirmStepAsync, AgeStepAsync, ConfirmStepAsync, SummaryStepAsync, }; // Add named dialogs to the DialogSet. These names are saved in the dialog state. AddDialog(new WaterfallDialog(nameof(WaterfallDialog), waterfallSteps)); AddDialog(new TextPrompt(nameof(TextPrompt))); AddDialog(new NumberPrompt <int>(nameof(NumberPrompt <int>), AgePromptValidatorAsync)); AddDialog(new ChoicePrompt(nameof(ChoicePrompt))); AddDialog(new ConfirmPrompt(nameof(ConfirmPrompt))); // The initial child Dialog to run. InitialDialogId = nameof(WaterfallDialog); }
public DialogAndWelcomeBot(ConversationState conversationState, UserState userState, T dialog, ILogger <DialogBot <T> > logger) : base(conversationState, userState, dialog, logger) { // combine path for cross platform support string[] paths = { ".", "Bots", "DialogAndWelcomeBot.lg" }; string fullPath = Path.Combine(paths); _lgEngine = TemplateEngine.FromFiles(fullPath); }
public AdapterWithErrorHandler(ICredentialProvider credentialProvider, ILogger <BotFrameworkHttpAdapter> logger, ConversationState conversationState = null) : base(credentialProvider) { // combine path for cross platform support string[] paths = { ".", "Resources", "AdapterWithErrorHandler.LG" }; string fullPath = Path.Combine(paths); _lgEngine = TemplateEngine.FromFiles(fullPath); // manage all bot resources var resourceExplorer = ResourceExplorer .LoadProject(Directory.GetCurrentDirectory(), ignoreFolders: new string[] { "models" }); //resourceExplorer.AddFolder(luisModelsFolder); var lg = new LGLanguageGenerator(resourceExplorer); Use(new RegisterClassMiddleware <ILanguageGenerator>(lg)); Use(new RegisterClassMiddleware <IMessageActivityGenerator>(new TextMessageActivityGenerator(lg))); OnTurnError = async(turnContext, exception) => { // Log any leaked exception from the application. logger.LogError($"Exception caught : {exception.Message}"); // Send a catch-all apology to the user. await turnContext.SendActivityAsync(_lgEngine.EvaluateTemplate("SomethingWentWrong", null)); if (conversationState != null) { try { // Delete the conversationState for the current conversation to prevent the // bot from getting stuck in a error-loop caused by being in a bad state. // ConversationState should be thought of as similar to "cookie-state" in a Web pages. await conversationState.DeleteAsync(turnContext); } catch (Exception e) { logger.LogError($"Exception caught on attempting to Delete ConversationState : {e.Message}"); } } }; }
public DateResolverDialog(string id = null) : base(id ?? nameof(DateResolverDialog)) { // combine path for cross platform support string[] paths = { ".", "Resources", "BookingDialog.LG" }; string fullPath = Path.Combine(paths); _lgEngine = TemplateEngine.FromFiles(fullPath); AddDialog(new DateTimePrompt(nameof(DateTimePrompt), DateTimePromptValidator)); AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[] { InitialStepAsync, FinalStepAsync, })); // The initial child Dialog to run. InitialDialogId = nameof(WaterfallDialog); }
public static Activity GetLUISHeroCard(string text, LaLigaBL.PictureType picture) { var chatActivity = Activity.CreateMessageActivity(); var lgEngine = TemplateEngine.FromFiles(@".\Resources\LaLigaTemplates.lg"); string imageURL; switch (picture) { case LaLigaBL.PictureType.ChampionsLeague: imageURL = lgEngine.EvaluateTemplate("ChampionsLeagueImage", new { }); break; case LaLigaBL.PictureType.LaLiga: imageURL = lgEngine.EvaluateTemplate("CardImage", new { }); break; case LaLigaBL.PictureType.Ticket: imageURL = lgEngine.EvaluateTemplate("TicketsImage", new { }); break; default: imageURL = ""; break; } CardImage cardImage = new CardImage(imageURL); var plCard = new HeroCard() { //Title = cardTitle, Text = text, Images = new List <CardImage>() { cardImage } }; var attachment = plCard.ToAttachment(); chatActivity.Attachments.Add(attachment); return((Activity)chatActivity); }
public AdapterWithErrorHandler(ICredentialProvider credentialProvider, ILogger <BotFrameworkHttpAdapter> logger, IStorage storage, UserState userState, ConversationState conversationState, ResourceExplorer resourceExplorer, IConfiguration configuration) : base(credentialProvider) { // combine path for cross platform support string[] paths = { ".", "AdapterWithErrorHandler.lg" }; string fullPath = Path.Combine(paths); _lgEngine = TemplateEngine.FromFiles(fullPath); this.UseStorage(storage); this.UseState(userState, conversationState); this.UseLanguageGenerator(new LGLanguageGenerator(resourceExplorer)); this.UseDebugger(configuration.GetValue <int>("debugport", 4712), events: new Events <AdaptiveEvents>()); OnTurnError = async(turnContext, exception) => { // Log any leaked exception from the application. logger.LogError($"Exception caught : {exception.Message}"); // Send a catch-all apology to the user. await turnContext.SendActivityAsync(_lgEngine.EvaluateTemplate("SomethingWentWrong", null)); if (conversationState != null) { try { // Delete the conversationState for the current conversation to prevent the // bot from getting stuck in a error-loop caused by being in a bad state. // ConversationState should be thought of as similar to "cookie-state" in a Web pages. await conversationState.DeleteAsync(turnContext); } catch (Exception e) { logger.LogError($"Exception caught on attempting to Delete ConversationState : {e.Message}"); } } }; }
public MainDialog(IConfiguration configuration, ILogger <MainDialog> logger) : base(nameof(MainDialog)) { // combine path for cross platform support string[] paths = { ".", "Resources", "MainDialog.LG" }; string fullPath = Path.Combine(paths); _lgEngine = TemplateEngine.FromFiles(fullPath); Configuration = configuration; Logger = logger; AddDialog(new TextPrompt(nameof(TextPrompt))); AddDialog(new BookingDialog()); AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[] { IntroStepAsync, ActStepAsync, FinalStepAsync, })); // The initial child Dialog to run. InitialDialogId = nameof(WaterfallDialog); }
public BookingDialog() : base(nameof(BookingDialog)) { // combine path for cross platform support string[] paths = { ".", "Resources", "BookingDialog.LG" }; string fullPath = Path.Combine(paths); _lgEngine = TemplateEngine.FromFiles(fullPath); AddDialog(new TextPrompt(nameof(TextPrompt))); AddDialog(new ConfirmPrompt(nameof(ConfirmPrompt))); AddDialog(new DateResolverDialog()); AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[] { DestinationStepAsync, OriginStepAsync, TravelDateStepAsync, ConfirmStepAsync, FinalStepAsync, })); // The initial child Dialog to run. InitialDialogId = nameof(WaterfallDialog); }
public MainDialog(ILogger <MainDialog> logger) : base(nameof(MainDialog)) { _logger = logger; // combine path for cross platform support string[] paths = { ".", "Resources", "MainDialog.LG" }; string mainDialogLGFile = Path.Combine(paths); paths = new string[] { ".", "Resources", "Cards.LG" }; string cardsLGFile = Path.Combine(paths); string[] lgFiles = { mainDialogLGFile, cardsLGFile }; _lgEngine = TemplateEngine.FromFiles(lgFiles); AddDialog(new ChoicePrompt(nameof(ChoicePrompt))); AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[] { ChoiceCardStepAsync, ShowCardStepAsync, })); // The initial child Dialog to run. InitialDialogId = nameof(WaterfallDialog); }