public OnboardingDialog(BotServices botServices, IStatePropertyAccessor <OnboardingState> accessor, IBotTelemetryClient telemetryClient)
            : base(botServices, nameof(OnboardingDialog), telemetryClient)
        {
            _accessor       = accessor;
            InitialDialogId = nameof(OnboardingDialog);

            var onboarding = new WaterfallStep[]
            {
                AskForName,
                AskForLocation,
                FinishOnboardingDialog,
            };

            // To capture built-in waterfall dialog telemetry, set the telemetry client
            // to the new waterfall dialog and add it to the component dialog
            TelemetryClient = telemetryClient;
            AddDialog(new WaterfallDialog(InitialDialogId, onboarding)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new TextPrompt(NamePrompt));
            AddDialog(new TextPrompt(LocationPrompt));
        }
 public static void TrackTraceEx(this IBotTelemetryClient telemetryClient, string message, Severity severityLevel, Activity activity, IDictionary <string, string> properties, string dialogId = null)
 {
     telemetryClient.TrackTrace(message, severityLevel, GetFinalProperties(activity, dialogId, properties));
 }
예제 #3
0
        /// <summary>
        /// Initializes a  new instance of the <see cref="Kevya"/> class.
        /// </summary>
        /// <param name="botServices">Bot services.</param>
        /// <param name="conversationState">Bot conversation state.</param>
        /// <param name="userState">Bot user state.</param>
        public Kevya(BotServices botServices, ConversationState conversationState, UserState userState, IBotTelemetryClient telemetryClient)
        {
            _conversationState = conversationState ?? throw new ArgumentNullException(nameof(conversationState));
            _userState         = userState ?? throw new ArgumentNullException(nameof(userState));
            _services          = botServices ?? throw new ArgumentNullException(nameof(botServices));
            _telemetryClient   = telemetryClient ?? throw new  ArgumentNullException(nameof(telemetryClient));

            _dialogs = new DialogSet(_conversationState.CreateProperty <DialogState>(nameof(Kevya)));
            _dialogs.Add(new MainDialog(_services, _conversationState, _userState, _telemetryClient));
        }
 public InterruptableDialog(string dialogId, IBotTelemetryClient telemetryClient)
     : base(dialogId)
 {
     PrimaryDialogName = dialogId;
     TelemetryClient   = telemetryClient;
 }
 public static void TrackEventEx(this IBotTelemetryClient telemetryClient, string eventName, Activity activity, string dialogId = null, IDictionary <string, string> properties = null, IDictionary <string, double> metrics = null)
 {
     telemetryClient.TrackEvent(eventName, GetFinalProperties(activity, dialogId, properties), metrics);
 }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TelemetryLoggerMiddleware"/> class.
 /// </summary>
 /// <param name="telemetryClient">The IBotTelemetryClient implementation used for registering telemetry events.</param>
 /// <param name="logPersonalInformation"> (Optional) TRUE to include personally indentifiable information.</param>
 /// <param name="config"> (Optional) TelemetryConfiguration to use for Application Insights.</param>
 public TelemetryLoggerMiddleware(IBotTelemetryClient telemetryClient, bool logPersonalInformation = false, TelemetryConfiguration config = null)
 {
     _telemetryClient       = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient));
     LogPersonalInformation = logPersonalInformation;
 }
예제 #7
0
        public ForwardEmailDialog(
            BotSettings settings,
            BotServices services,
            ResponseManager responseManager,
            ConversationState conversationState,
            FindContactDialog findContactDialog,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient,
            MicrosoftAppCredentials appCredentials)
            : base(nameof(ForwardEmailDialog), settings, services, responseManager, conversationState, serviceManager, telemetryClient, appCredentials)
        {
            TelemetryClient = telemetryClient;

            var forwardEmail = new WaterfallStep[]
            {
                IfClearContextStep,
                GetAuthToken,
                AfterGetAuthToken,
                SetDisplayConfig,
                CollectSelectedEmail,
                AfterCollectSelectedEmail,
                CollectRecipient,
                CollectAdditionalText,
                AfterCollectAdditionalText,
                ConfirmBeforeSending,
                ConfirmAllRecipient,
                ForwardEmail,
            };

            var showEmail = new WaterfallStep[]
            {
                PagingStep,
                ShowEmails,
            };

            var collectRecipients = new WaterfallStep[]
            {
                PromptRecipientCollection,
                GetRecipients,
            };

            var updateSelectMessage = new WaterfallStep[]
            {
                UpdateMessage,
                PromptUpdateMessage,
                AfterUpdateMessage,
            };

            // Define the conversation flow using a waterfall model.
            AddDialog(new WaterfallDialog(Actions.Forward, forwardEmail)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.Show, showEmail)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.CollectRecipient, collectRecipients)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.UpdateSelectMessage, updateSelectMessage)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new FindContactDialog(settings, services, responseManager, conversationState, serviceManager, telemetryClient));
            InitialDialogId = Actions.Forward;
        }
예제 #8
0
        public VehicleSettingsDialog(
            BotSettings settings,
            BotServices services,
            ResponseManager responseManager,
            ConversationState conversationState,
            IBotTelemetryClient telemetryClient,
            IHttpContextAccessor httpContext)
            : base(nameof(VehicleSettingsDialog), settings, services, responseManager, conversationState, telemetryClient)
        {
            TelemetryClient = telemetryClient;

            var localeConfig = services.GetCognitiveModels();

            // Initialise supporting LUIS models for followup questions
            vehicleSettingNameSelectionLuisRecognizer  = localeConfig.LuisServices["SettingsName"];
            vehicleSettingValueSelectionLuisRecognizer = localeConfig.LuisServices["SettingsValue"];

            // Initialise supporting LUIS models for followup questions
            vehicleSettingNameSelectionLuisRecognizer  = localeConfig.LuisServices["SettingsName"];
            vehicleSettingValueSelectionLuisRecognizer = localeConfig.LuisServices["SettingsValue"];

            // Supporting setting files are stored as embedded resources
            var resourceAssembly = typeof(VehicleSettingsDialog).Assembly;

            var settingFile = resourceAssembly
                              .GetManifestResourceNames()
                              .Where(x => x.Contains(AvailableSettingsFileName))
                              .First();

            var alternativeSettingFileName = resourceAssembly
                                             .GetManifestResourceNames()
                                             .Where(x => x.Contains(AlternativeSettingsFileName))
                                             .First();

            if (string.IsNullOrEmpty(settingFile) || string.IsNullOrEmpty(alternativeSettingFileName))
            {
                throw new FileNotFoundException($"Unable to find Available Setting and/or Alternative Names files in \"{resourceAssembly.FullName}\" assembly.");
            }

            settingList   = new SettingList(resourceAssembly, settingFile, alternativeSettingFileName);
            settingFilter = new SettingFilter(settingList);

            // Setting Change waterfall
            var processVehicleSettingChangeWaterfall = new WaterfallStep[]
            {
                ProcessSetting,
                ProcessVehicleSettingsChange,
                ProcessChange,
                SendChange
            };

            AddDialog(new WaterfallDialog(Actions.ProcessVehicleSettingChange, processVehicleSettingChangeWaterfall)
            {
                TelemetryClient = telemetryClient
            });

            // Prompts
            AddDialog(new ChoicePrompt(Actions.SettingNameSelectionPrompt, SettingNameSelectionValidator, Culture.English)
            {
                Style = ListStyle.Auto, ChoiceOptions = new ChoiceFactoryOptions {
                    InlineSeparator = string.Empty, InlineOr = string.Empty, InlineOrMore = string.Empty, IncludeNumbers = true
                }
            });
            AddDialog(new ChoicePrompt(Actions.SettingValueSelectionPrompt, SettingValueSelectionValidator, Culture.English)
            {
                Style = ListStyle.Auto, ChoiceOptions = new ChoiceFactoryOptions {
                    InlineSeparator = string.Empty, InlineOr = string.Empty, InlineOrMore = string.Empty, IncludeNumbers = true
                }
            });

            AddDialog(new ConfirmPrompt(Actions.SettingConfirmationPrompt));

            // Set starting dialog for component
            InitialDialogId = Actions.ProcessVehicleSettingChange;

            // Used to resolve image paths (local or hosted)
            _httpContext = httpContext;
        }
예제 #9
0
        public SummaryDialog(
            SkillConfigurationBase services,
            ResponseManager responseManager,
            IStatePropertyAccessor <CalendarSkillState> accessor,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient)
            : base(nameof(SummaryDialog), services, responseManager, accessor, serviceManager, telemetryClient)
        {
            TelemetryClient = telemetryClient;

            var initStep = new WaterfallStep[]
            {
                Init,
            };

            var showNext = new WaterfallStep[]
            {
                GetAuthToken,
                AfterGetAuthToken,
                ShowNextEvent,
            };

            var showSummary = new WaterfallStep[]
            {
                GetAuthToken,
                AfterGetAuthToken,
                ShowEventsSummary,
                CallReadEventDialog,
                AskForShowOverview,
                AfterAskForShowOverview
            };

            var readEvent = new WaterfallStep[]
            {
                ReadEvent,
                AfterReadOutEvent,
            };

            // Define the conversation flow using a waterfall model.
            AddDialog(new WaterfallDialog(Actions.GetEventsInit, initStep)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.ShowNextEvent, showNext)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.ShowEventsSummary, showSummary)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.Read, readEvent)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new UpdateEventDialog(services, responseManager, accessor, serviceManager, telemetryClient));
            AddDialog(new ChangeEventStatusDialog(services, responseManager, accessor, serviceManager, telemetryClient));

            // Set starting dialog for component
            InitialDialogId = Actions.GetEventsInit;
        }
예제 #10
0
        public MainDialog(BotServices services, ConversationState conversationState, UserState userState, EndpointService endpointService, IBotTelemetryClient telemetryClient)
            : base(nameof(MainDialog), telemetryClient)
        {
            _services              = services ?? throw new ArgumentNullException(nameof(services));
            _conversationState     = conversationState;
            _userState             = userState;
            _endpointService       = endpointService;
            TelemetryClient        = telemetryClient;
            _onboardingState       = _userState.CreateProperty <OnboardingState>(nameof(OnboardingState));
            _parametersAccessor    = _userState.CreateProperty <Dictionary <string, object> >("userInfo");
            _virtualAssistantState = _conversationState.CreateProperty <VirtualAssistantState>(nameof(VirtualAssistantState));

            AddDialog(new OnboardingDialog(_services, _onboardingState, telemetryClient));
            AddDialog(new EscalateDialog(_services, telemetryClient));

            RegisterSkills(_services.SkillDefinitions);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="TelemetryLoggerMiddleware"/> class.
 /// </summary>
 /// <param name="telemetryClient">The telemetry client to send telemetry events to.</param>
 /// <param name="logPersonalInformation">`true` to include personally identifiable information; otherwise, `false`.</param>
 public TelemetryLoggerMiddleware(IBotTelemetryClient telemetryClient, bool logPersonalInformation = false)
 {
     TelemetryClient        = telemetryClient ?? new NullBotTelemetryClient();
     LogPersonalInformation = logPersonalInformation;
 }
예제 #12
0
        public MainDialog(BotServices services, ConversationState conversationState, UserState userState, IBotTelemetryClient telemetryClient)
            : base(nameof(MainDialog))
        {
            _services          = services ?? throw new ArgumentNullException(nameof(services));
            _conversationState = conversationState;
            _userState         = userState;
            TelemetryClient    = telemetryClient;

            AddDialog(new OnboardingDialog(_services, _userState.CreateProperty <OnboardingState>(nameof(OnboardingState)), telemetryClient));
            AddDialog(new EscalateDialog(_services));
        }
예제 #13
0
        public ToDoSkill(ISkillConfiguration services, ConversationState conversationState, UserState userState, IBotTelemetryClient telemetryClient, ITaskService serviceManager = null, bool skillMode = false)
        {
            _skillMode         = skillMode;
            _services          = services ?? throw new ArgumentNullException(nameof(services));
            _userState         = userState ?? throw new ArgumentNullException(nameof(userState));
            _conversationState = conversationState ?? throw new ArgumentNullException(nameof(conversationState));
            _telemetryClient   = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient));

            var isOutlookProvider = _services.Properties.ContainsKey("TaskServiceProvider") &&
                                    _services.Properties["TaskServiceProvider"].ToString().Equals(ProviderTypes.Outlook.ToString(), StringComparison.InvariantCultureIgnoreCase);
            ITaskService taskService = new OneNoteService();

            if (isOutlookProvider)
            {
                taskService = new OutlookService();
            }

            _serviceManager = serviceManager ?? taskService;

            _dialogs = new DialogSet(_conversationState.CreateProperty <DialogState>(nameof(DialogState)));
            _dialogs.Add(new MainDialog(_services, _conversationState, _userState, _telemetryClient, _serviceManager, _skillMode));
        }
예제 #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VirtualAssistant"/> class.
        /// </summary>
        /// <param name="botServices">Bot services.</param>
        /// <param name="conversationState">Bot conversation state.</param>
        /// <param name="userState">Bot user state.</param>
        /// <param name="proactiveState">Proactive state.</param>
        /// <param name="endpointService">Bot endpoint service.</param>
        /// <param name="telemetryClient">Bot telemetry client.</param>
        /// <param name="backgroundTaskQueue">Background task queue.</param>
        /// <param name="responseManager">Response manager.</param>
        /// <param name="imageAssetLocation">Image asset location.</param>
        /// <param name="httpContext">Http context.</param>
        public VirtualAssistant(BotServices botServices, ConversationState conversationState, UserState userState, ProactiveState proactiveState, EndpointService endpointService, IBotTelemetryClient telemetryClient, IBackgroundTaskQueue backgroundTaskQueue, ResponseManager responseManager, string imageAssetLocation, IHttpContextAccessor httpContext = null)
        {
            _conversationState   = conversationState ?? throw new ArgumentNullException(nameof(conversationState));
            _userState           = userState ?? throw new ArgumentNullException(nameof(userState));
            _proactiveState      = proactiveState ?? throw new ArgumentNullException(nameof(proactiveState));
            _services            = botServices ?? throw new ArgumentNullException(nameof(botServices));
            _endpointService     = endpointService ?? throw new ArgumentNullException(nameof(endpointService));
            _telemetryClient     = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient));
            _backgroundTaskQueue = backgroundTaskQueue;
            _responseManager     = responseManager;
            _imageAssetLocation  = imageAssetLocation;
            _httpContext         = httpContext ?? throw new ArgumentNullException(nameof(httpContext));

            _dialogs = new DialogSet(_conversationState.CreateProperty <DialogState>(nameof(VirtualAssistant)));
            _dialogs.Add(new MainDialog(_services, _conversationState, _userState, _proactiveState, _endpointService, _telemetryClient, _backgroundTaskQueue, _responseManager, _imageAssetLocation, _httpContext));
        }
예제 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Dialog"/> class.
 /// Called from constructors in derived classes to initialize the <see cref="Dialog"/> class.
 /// </summary>
 /// <param name="dialogId">The ID to assign to this dialog.</param>
 public Dialog(string dialogId = null)
 {
     Id = dialogId;
     _telemetryClient = NullBotTelemetryClient.Instance;
 }
예제 #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="QnAMaker"/> class.
        /// </summary>
        /// <param name="endpoint">The endpoint of the knowledge base to query.</param>
        /// <param name="options">The options for the QnA Maker knowledge base.</param>
        /// <param name="httpClient">An alternate client with which to talk to QnAMaker.
        /// If null, a default client is used for this instance.</param>
        /// <param name="telemetryClient">The IBotTelemetryClient used for logging telemetry events.</param>
        /// <param name="logPersonalInformation">Set to true to include personally indentifiable information in telemetry events.</param>
        public QnAMaker(QnAMakerEndpoint endpoint, QnAMakerOptions options, HttpClient httpClient, IBotTelemetryClient telemetryClient, bool logPersonalInformation = false)
        {
            _endpoint = endpoint ?? throw new ArgumentNullException(nameof(endpoint));

            if (string.IsNullOrEmpty(endpoint.KnowledgeBaseId))
            {
                throw new ArgumentException(nameof(endpoint.KnowledgeBaseId));
            }

            if (string.IsNullOrEmpty(endpoint.Host))
            {
                throw new ArgumentException(nameof(endpoint.Host));
            }

            if (string.IsNullOrEmpty(endpoint.EndpointKey))
            {
                throw new ArgumentException(nameof(endpoint.EndpointKey));
            }

            if (_endpoint.Host.EndsWith("v2.0"))
            {
                throw new NotSupportedException("v2.0 of QnA Maker service is no longer supported in the Bot Framework. Please upgrade your QnA Maker service at www.qnamaker.ai.");
            }

            _options = options ?? new QnAMakerOptions();
            ValidateOptions(_options);

            if (httpClient == null)
            {
                _httpClient = DefaultHttpClient;
            }
            else
            {
                _httpClient = httpClient;
            }

            _isLegacyProtocol = _endpoint.Host.EndsWith("v3.0");

            TelemetryClient        = telemetryClient ?? new NullBotTelemetryClient();
            LogPersonalInformation = logPersonalInformation;
        }
        public SendEmailDialog(
            BotSettings settings,
            BotServices services,
            ResponseManager responseManager,
            ConversationState conversationState,
            FindContactDialog findContactDialog,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient,
            MicrosoftAppCredentials appCredentials)
            : base(nameof(SendEmailDialog), settings, services, responseManager, conversationState, serviceManager, telemetryClient, appCredentials)
        {
            TelemetryClient = telemetryClient;

            var sendEmail = new WaterfallStep[]
            {
                IfClearContextStep,
                GetAuthToken,
                AfterGetAuthToken,
                CollectRecipient,
                CollectSubject,
                CollectText,
                ConfirmBeforeSending,
                ConfirmAllRecipient,
                SendEmail,
            };

            var collectRecipients = new WaterfallStep[]
            {
                PromptRecipientCollection,
                GetRecipients,
            };

            var updateSubject = new WaterfallStep[]
            {
                UpdateSubject,
                RetryCollectSubject,
                AfterUpdateSubject,
            };

            var updateContent = new WaterfallStep[]
            {
                UpdateContent,
                PlayBackContent,
                AfterCollectContent,
            };

            var getRecreateInfo = new WaterfallStep[]
            {
                GetRecreateInfo,
                AfterGetRecreateInfo,
            };

            // Define the conversation flow using a waterfall model.
            AddDialog(new WaterfallDialog(Actions.Send, sendEmail)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.CollectRecipient, collectRecipients)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.UpdateSubject, updateSubject)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.UpdateContent, updateContent)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new FindContactDialog(settings, services, responseManager, conversationState, serviceManager, telemetryClient));
            AddDialog(new WaterfallDialog(Actions.GetRecreateInfo, getRecreateInfo)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new GetRecreateInfoPrompt(Actions.GetRecreateInfoPrompt));
            InitialDialogId = Actions.Send;
        }
        public SkillCallingRequestHandler(ITurnContext turnContext, IBotTelemetryClient botTelemetryClient, Action <Activity> tokenRequestHandler = null, Action <Activity> handoffActivityHandler = null)
        {
            _turnContext            = turnContext ?? throw new ArgumentNullException(nameof(turnContext));
            _botTelemetryClient     = botTelemetryClient;
            _tokenRequestHandler    = tokenRequestHandler;
            _handoffActivityHandler = handoffActivityHandler;

            var routes = new RouteTemplate[]
            {
                new RouteTemplate()
                {
                    Method = "POST",
                    Path   = "/activities/{activityId}",
                    Action = new RouteAction()
                    {
                        Action =
                            async(request, routeData) =>
                        {
                            var activity = await request.ReadBodyAsJson <Activity>().ConfigureAwait(false);

                            if (activity != null)
                            {
                                if (activity.Type == ActivityTypes.Event && activity.Name == TokenEvents.TokenRequestEventName)
                                {
                                    if (_tokenRequestHandler != null)
                                    {
                                        _tokenRequestHandler(activity);

                                        return(new ResourceResponse());
                                    }
                                    else
                                    {
                                        throw new ArgumentNullException("TokenRequestHandler", "Skill is requesting for token but there's no handler on the calling side!");
                                    }
                                }
                                else if (activity.Type == ActivityTypes.EndOfConversation)
                                {
                                    if (_handoffActivityHandler != null)
                                    {
                                        _handoffActivityHandler(activity);

                                        return(new ResourceResponse());
                                    }
                                    else
                                    {
                                        throw new ArgumentNullException("HandoffActivityHandler", "Skill is sending handoff activity but there's no handler on the calling side!");
                                    }
                                }
                                else
                                {
                                    var result = await _turnContext.SendActivityAsync(activity).ConfigureAwait(false);

                                    return(result);
                                }
                            }
                            else
                            {
                                throw new Exception("Error deserializing activity response!");
                            }
                        },
                    },
                },
                new RouteTemplate()
                {
                    Method = "PUT",
                    Path   = "/activities/{activityId}",
                    Action = new RouteAction()
                    {
                        Action =
                            async(request, routeData) =>
                        {
                            var activity = await request.ReadBodyAsJson <Activity>().ConfigureAwait(false);

                            var result = _turnContext.UpdateActivityAsync(activity).ConfigureAwait(false);
                            return(result);
                        },
                    },
                },
                new RouteTemplate()
                {
                    Method = "DELETE",
                    Path   = "/activities/{activityId}",
                    Action = new RouteAction()
                    {
                        Action =
                            async(request, routeData) =>
                        {
                            var result = await _turnContext.DeleteActivityAsync(routeData.activityId);

                            return(result);
                        },
                    },
                },
            };

            _router = new Router(routes);
        }
예제 #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomQuestionAnswering"/> class.
        /// </summary>
        /// <param name="endpoint">The <see cref="QnAMakerEndpoint"/> of the knowledge base to query.</param>
        /// <param name="options">The <see cref="QnAMakerOptions"/> for the Custom Question Answering Knowledge Base.</param>
        /// <param name="httpClient">An alternate client with which to talk to Language Service.
        /// If null, a default client is used for this instance.</param>
        /// <param name="telemetryClient">The IBotTelemetryClient used for logging telemetry events.</param>
        /// <param name="logPersonalInformation">Set to true to include personally identifiable information in telemetry events.</param>
        public CustomQuestionAnswering(QnAMakerEndpoint endpoint, QnAMakerOptions options, HttpClient httpClient, IBotTelemetryClient telemetryClient, bool logPersonalInformation = false)
        {
            _endpoint = endpoint ?? throw new ArgumentNullException(nameof(endpoint));

            if (string.IsNullOrEmpty(endpoint.KnowledgeBaseId))
            {
                throw new ArgumentException(nameof(endpoint.KnowledgeBaseId));
            }

            if (string.IsNullOrEmpty(endpoint.Host))
            {
                throw new ArgumentException(nameof(endpoint.Host));
            }

            if (string.IsNullOrEmpty(endpoint.EndpointKey))
            {
                throw new ArgumentException(nameof(endpoint.EndpointKey));
            }

            if (_endpoint.Host.EndsWith("v2.0", StringComparison.Ordinal) || _endpoint.Host.EndsWith("v3.0", StringComparison.Ordinal))
            {
                throw new NotSupportedException("v2.0 and v3.0 of QnA Maker service is no longer supported in the QnA Maker.");
            }

            _httpClient = httpClient ?? DefaultHttpClient;

            TelemetryClient        = telemetryClient ?? new NullBotTelemetryClient();
            LogPersonalInformation = logPersonalInformation;

            _languageServiceHelper = new LanguageServiceUtils(TelemetryClient, _httpClient, endpoint, options);
        }
예제 #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DialogSet"/> class.
 /// </summary>
 /// <param name="dialogState">The state property accessor with which to manage the stack for
 /// this dialog set.</param>
 /// <remarks>To start and control the dialogs in this dialog set, create a <see cref="DialogContext"/>
 /// and use its methods to start, continue, or end dialogs. To create a dialog context,
 /// call <see cref="CreateContextAsync(ITurnContext, CancellationToken)"/>.
 /// </remarks>
 public DialogSet(IStatePropertyAccessor <DialogState> dialogState)
 {
     _dialogState     = dialogState ?? throw new ArgumentNullException($"missing {nameof(dialogState)}");
     _telemetryClient = NullBotTelemetryClient.Instance;
 }
예제 #21
0
 public LuisRecognizer(LuisApplication application, IBotTelemetryClient telemetryClient, bool logPersonalInformation, LuisPredictionOptions predictionOptions = null, bool includeApiResults = false, HttpClientHandler clientHandler = null)
     : this(BuildLuisRecognizerOptionsV2(application, predictionOptions, includeApiResults), clientHandler)
 {
 }
 internal SkillWebSocketRequestHandler(IBotTelemetryClient botTelemetryClient)
 {
     _botTelemetryClient = botTelemetryClient ?? NullBotTelemetryClient.Instance;
     _stopWatch          = new Diagnostics.Stopwatch();
 }
예제 #23
0
 public MainDialogTests(ITestOutputHelper output) : base(output)
 {
     _mockLogger      = new Mock <ILogger <MainDialog> >();
     _telemetryClient = new NullBotTelemetryClient();
     _userState       = new UserState(new MemoryStorage());
 }
예제 #24
0
파일: EmailSkill.cs 프로젝트: rneubauer/AI
        public EmailSkill(SkillConfigurationBase services, ConversationState conversationState, UserState userState, IBotTelemetryClient telemetryClient, IServiceManager serviceManager = null, bool skillMode = false)
        {
            _skillMode         = skillMode;
            _services          = services ?? throw new ArgumentNullException(nameof(services));
            _userState         = userState ?? throw new ArgumentNullException(nameof(userState));
            _conversationState = conversationState ?? throw new ArgumentNullException(nameof(conversationState));
            _telemetryClient   = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient));
            _serviceManager    = serviceManager ?? new ServiceManager(services);

            _dialogs = new DialogSet(_conversationState.CreateProperty <DialogState>(nameof(DialogState)));
            _dialogs.Add(new MainDialog(_services, _conversationState, _userState, _telemetryClient, _serviceManager, _skillMode));
        }
 public static void TrackExceptionEx(this IBotTelemetryClient telemetryClient, Exception exception, Activity activity, string dialogId = null, IDictionary <string, string> properties = null, IDictionary <string, double> metrics = null)
 {
     telemetryClient.TrackException(exception, GetFinalProperties(activity, dialogId, properties), metrics);
 }
예제 #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QnAMaker"/> class.
 /// </summary>
 /// <param name="service">QnA service details from configuration.</param>
 /// <param name="options">The options for the QnA Maker knowledge base.</param>
 /// <param name="httpClient">An alternate client with which to talk to QnAMaker.
 /// If null, a default client is used for this instance.</param>
 /// <param name="telemetryClient">The IBotTelemetryClient used for logging telemetry events.</param>
 /// <param name="logPersonalInformation">Set to true to include personally identifiable information in telemetry events.</param>
 public QnAMaker(QnAMakerService service, QnAMakerOptions options, HttpClient httpClient, IBotTelemetryClient telemetryClient, bool logPersonalInformation = false)
     : this(new QnAMakerEndpoint(service), options, httpClient, telemetryClient, logPersonalInformation)
 {
 }
예제 #27
0
 public OverrideFillLogger(IBotTelemetryClient telemetryClient, bool logPersonalInformation = false)
     : base(telemetryClient, logPersonalInformation)
 {
 }
예제 #28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="QnAMaker"/> class.
        /// </summary>
        /// <param name="endpoint">The endpoint of the knowledge base to query.</param>
        /// <param name="options">The options for the QnA Maker knowledge base.</param>
        /// <param name="httpClient">An alternate client with which to talk to QnAMaker.
        /// If null, a default client is used for this instance.</param>
        /// <param name="telemetryClient">The IBotTelemetryClient used for logging telemetry events.</param>
        /// <param name="logPersonalInformation">Set to true to include personally identifiable information in telemetry events.</param>
        public QnAMaker(QnAMakerEndpoint endpoint, QnAMakerOptions options, HttpClient httpClient, IBotTelemetryClient telemetryClient, bool logPersonalInformation = false)
        {
            _endpoint = endpoint ?? throw new ArgumentNullException(nameof(endpoint));

            if (string.IsNullOrEmpty(endpoint.KnowledgeBaseId))
            {
                throw new ArgumentException(nameof(endpoint.KnowledgeBaseId));
            }

            if (string.IsNullOrEmpty(endpoint.Host))
            {
                throw new ArgumentException(nameof(endpoint.Host));
            }

            if (string.IsNullOrEmpty(endpoint.EndpointKey))
            {
                throw new ArgumentException(nameof(endpoint.EndpointKey));
            }

            if (_endpoint.Host.EndsWith("v2.0") || _endpoint.Host.EndsWith("v3.0"))
            {
                throw new NotSupportedException("v2.0 and v3.0 of QnA Maker service is no longer supported in the QnA Maker.");
            }

            if (httpClient == null)
            {
                _httpClient = DefaultHttpClient;
            }
            else
            {
                _httpClient = httpClient;
            }

            TelemetryClient        = telemetryClient ?? new NullBotTelemetryClient();
            LogPersonalInformation = logPersonalInformation;

            this._generateAnswerHelper      = new GenerateAnswerUtils(TelemetryClient, _endpoint, options, _httpClient);
            this._activeLearningTrainHelper = new TrainUtils(_endpoint, _httpClient);
        }
예제 #29
0
        public ChallengeGuesserDialog(string id, IConfiguration configuration, ILogger logger, IBotTelemetryClient telemetryClient)
            : base(id)

        {
            Configuration   = configuration;
            Logger          = logger;
            TelemetryClient = telemetryClient;

            tableService = new TableService(Configuration["DailyChallengeTableConnectionString"], Configuration["DailyChallengeTableName"]);

            AddDialog(new TextPrompt(nameof(TextPrompt)));
            AddDialog(new AttachmentPrompt(nameof(AttachmentPrompt)));
            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
            {
                IntroStepAsync,
                ActStepAsync,
                FinalStepAsync
            }));

            // The initial child Dialog to run.
            InitialDialogId = nameof(WaterfallDialog);
        }
예제 #30
0
파일: MainDialog.cs 프로젝트: rneubauer/AI
        public MainDialog(SkillConfigurationBase services, ConversationState conversationState, UserState userState, IServiceManager serviceManager, IHttpContextAccessor httpContext, IBotTelemetryClient telemetryClient, bool skillMode)
            : base(nameof(MainDialog), telemetryClient)
        {
            _skillMode         = skillMode;
            _services          = services;
            _conversationState = conversationState;
            _userState         = userState;
            _telemetryClient   = telemetryClient;
            _serviceManager    = serviceManager;
            _httpContext       = httpContext;

            // Initialize state accessor
            _stateAccessor = _conversationState.CreateProperty <AutomotiveSkillState>(nameof(AutomotiveSkillState));

            // Register dialogs
            RegisterDialogs();
        }