public async Task <IActionResult> Get([FromRoute(Name = "data")] string data, [FromRoute(Name = "endpoint")] Guid endpointId) { var endpoint = await EndpointService.FindById(endpointId, true); var outputData = endpoint.OutputData; //TODO: get rid of try/catch try { var json = JsonConvert.DeserializeObject(endpoint.OutputData); HttpContext.Response.Headers["Content-Type"] = "application/json; charset=utf-8"; } catch { } HttpContext.Response.StatusCode = endpoint.OutputStatusCode; endpoint.OutputData = null; await LoggingService.Create(new RequestLog { Received = data, Endpoint = endpoint }); if (endpoint.CallbackType == CallbackType.Asynchronous) { await Task.Run(async() => await AsyncRequestService.Call(endpoint)); } return(Content(outputData)); }
public Bot(ILoggerFactory loggerFactory, BotServices services, EndpointService endpointService, StateBotAccessors stateBotPropertyAccessors, JobState jobState, Config config) { _services = services ?? throw new ArgumentNullException(nameof(services)); _jobState = jobState ?? throw new ArgumentNullException(nameof(jobState)); _stateBotPropertyAccessors = stateBotPropertyAccessors; _jobStatePropertyAccessor = jobState.CreateProperty <JobStorage>(nameof(JobState)); if (!_services.LuisServices.ContainsKey(LuisKey)) { throw new ArgumentException("Missing LUIS configuration...."); } if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } _logger = loggerFactory.CreateLogger <Bot>(); _services = services; AppId = string.IsNullOrEmpty(endpointService.AppId) ? "1" : endpointService.AppId; AppPassword = string.IsNullOrEmpty(endpointService.AppId) ? "1" : endpointService.AppPassword; ServiceEndpoint = endpointService.Endpoint; _uiPathHttpClient = new UiPathHttpClient(config.UiPathUserName, config.UiPathPassword, config.UiPathTenancyName); }
public async Task Run([EventGridTrigger] EventGridEvent eventGridEvent, IBinder binder) { if (eventGridEvent == null || !EventMappings.TryGetValue(eventGridEvent.EventType.ToLowerInvariant(), out var target)) { _log.LogInformation($"Unrecognized event type: {eventGridEvent?.EventType}, skipping"); return; } var dtName = eventGridEvent.Topic.Split("/", StringSplitOptions.RemoveEmptyEntries).Last(); var dtId = eventGridEvent.Subject; var evt = JsonConvert.DeserializeObject <JObject>(eventGridEvent.Data.ToString()); var data = evt["data"]; _log.LogInformation($"Received event from {dtName} for {dtId} with content {data.ToString()}"); var messages = binder.Bind <IAsyncCollector <SignalRMessage> >( new SignalRAttribute { HubName = EndpointService.EncodeInstanceNameForSignalR(dtName) }); await messages.AddAsync(new SignalRMessage { Target = target, Arguments = new[] { new { dtId, data } } }); }
public async Task <HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "POST", Route = "signalr/negotiate")] HttpRequest req, IBinder binder) { var rpr = _requestProcessor.Process(req); if (!rpr.IsSuccess) { return(HttpUtilities.BadRequest(rpr.Message)); } await SetupEndpointAsync(rpr.Context.InstanceName); await SetupRouteAsync(rpr.Context); var hubName = EndpointService.EncodeInstanceNameForSignalR(rpr.Context.InstanceName); var connectionInfo = binder.Bind <SignalRConnectionInfo>( new SignalRConnectionInfoAttribute { HubName = hubName, UserId = Guid.NewGuid().ToString() }); _log.LogInformation($"Negotiated connection to {hubName}"); return(HttpUtilities.Ok(connectionInfo)); }
public MainDialog( SkillConfigurationBase services, EndpointService endpointService, ResponseManager responseManager, ConversationState conversationState, UserState userState, ProactiveState proactiveState, IBotTelemetryClient telemetryClient, IBackgroundTaskQueue backgroundTaskQueue, IServiceManager serviceManager, bool skillMode) : base(nameof(MainDialog), telemetryClient) { _skillMode = skillMode; _services = services; _endpointService = endpointService; _responseManager = responseManager; _userState = userState; _conversationState = conversationState; _proactiveState = proactiveState; TelemetryClient = telemetryClient; _backgroundTaskQueue = backgroundTaskQueue; _serviceManager = serviceManager; // Initialize state accessor _stateAccessor = _conversationState.CreateProperty <CalendarSkillState>(nameof(CalendarSkillState)); _proactiveStateAccessor = _proactiveState.CreateProperty <ProactiveModel>(nameof(ProactiveModel)); // Register dialogs RegisterDialogs(); }
public FakeSkill(SkillConfigurationBase services, EndpointService endpointService, ConversationState conversationState, UserState userState, ProactiveState proactiveState, IBotTelemetryClient telemetryClient, IBackgroundTaskQueue backgroundTaskQueue, bool skillMode = false, ResponseManager responseManager = null, ServiceManager serviceManager = null) { _skillMode = skillMode; _services = services ?? throw new ArgumentNullException(nameof(services)); _userState = userState ?? throw new ArgumentNullException(nameof(userState)); _conversationState = conversationState ?? throw new ArgumentNullException(nameof(conversationState)); _proactiveState = proactiveState; _endpointService = endpointService; _backgroundTaskQueue = backgroundTaskQueue; _telemetryClient = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient)); _serviceManager = serviceManager ?? new ServiceManager(); if (responseManager == null) { var locales = new string[] { "en-us", "de-de", "es-es", "fr-fr", "it-it", "zh-cn" }; responseManager = new ResponseManager( locales, new SampleAuthResponses(), new MainResponses(), new SharedResponses(), new SampleResponses()); } _responseManager = responseManager; _dialogs = new DialogSet(_conversationState.CreateProperty <DialogState>(nameof(DialogState))); _dialogs.Add(new MainDialog(_services, _responseManager, _conversationState, _userState, _telemetryClient, _serviceManager, _skillMode)); }
public RestaurantBooking( SkillConfigurationBase services, EndpointService endpointService, ConversationState conversationState, UserState userState, ProactiveState proactiveState, IBotTelemetryClient telemetryClient, IBackgroundTaskQueue backgroundTaskQueue, bool skillMode = false, ResponseManager responseManager = null, IServiceManager serviceManager = null, IHttpContextAccessor httpContext = null) { _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(); _httpContext = httpContext; if (responseManager == null) { responseManager = new ResponseManager( _services.LocaleConfigurations.Keys.ToArray(), new RestaurantBookingSharedResponses(), new RestaurantBookingMainResponses()); } _responseManager = responseManager; _dialogs = new DialogSet(_conversationState.CreateProperty <DialogState>(nameof(DialogState))); _dialogs.Add(new MainDialog(_services, _responseManager, _conversationState, _userState, _telemetryClient, _serviceManager, _httpContext, _skillMode)); }
public void SetDashboard(Dashboard dashboard) { if (dashboard == null) { return; } Dashboard = dashboard; SetRunspaceFactory(Dashboard.EndpointInitialSessionState); foreach (var endpoint in CmdletExtensions.HostState.EndpointService.Endpoints) { EndpointService.Register(endpoint.Value); } foreach (var endpoint in CmdletExtensions.HostState.EndpointService.RestEndpoints) { EndpointService.Register(endpoint); } CmdletExtensions.HostState.EndpointService.Endpoints.Clear(); CmdletExtensions.HostState.EndpointService.RestEndpoints.Clear(); if (ServiceProvider != null) { var manager = ServiceProvider.GetServices <IHostedService>().First(m => m is ScheduledEndpointManager) as ScheduledEndpointManager; var source = new CancellationTokenSource(); #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed manager.StartAsync(source.Token); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed } }
public UpcomingEventDialog( SkillConfigurationBase services, EndpointService endpointService, ResponseManager responseManager, IStatePropertyAccessor <CalendarSkillState> accessor, IStatePropertyAccessor <ProactiveModel> proactiveStateAccessor, IServiceManager serviceManager, IBotTelemetryClient telemetryClient, IBackgroundTaskQueue backgroundTaskQueue) : base(nameof(UpcomingEventDialog), services, responseManager, accessor, serviceManager, telemetryClient) { _backgroundTaskQueue = backgroundTaskQueue; _proactiveStateAccessor = proactiveStateAccessor; _endpointService = endpointService; _responseManager = responseManager; var upcomingMeeting = new WaterfallStep[] { GetAuthToken, AfterGetAuthToken, QueueUpcomingEventWorker }; // Define the conversation flow using a waterfall model. AddDialog(new WaterfallDialog(Actions.ShowUpcomingMeeting, upcomingMeeting)); // Set starting dialog for component InitialDialogId = Actions.ShowUpcomingMeeting; }
/// <summary> /// Initializes a new instance of the <see cref="ProactiveBot"/> class. /// </summary> /// <param name="jobState">The state provider that is independent of user or conversation.</param> /// <param name="endpointService">The <see cref="EndpointService"/> portion of the <see cref="BotConfiguration"/>.</param> /// <seealso cref="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-2.1#windows-eventlog-provider"/> public ProactiveBot(JobState jobState, EndpointService endpointService) { _jobState = jobState ?? throw new ArgumentNullException(nameof(jobState)); _jobLogPropertyAccessor = _jobState.CreateProperty <JobLog>(nameof(JobLog)); // Validate AppId. // Note: For local testing, .bot AppId is empty for the Bot Framework Emulator. AppId = string.IsNullOrWhiteSpace(endpointService.AppId) ? "1" : endpointService.AppId; }
public SkillDialog(Dictionary <string, ISkillConfiguration> skills, IStatePropertyAccessor <DialogState> accessor, EndpointService endpointService, bool useCachedTokens = true) : base(nameof(SkillDialog)) { _skills = skills; _accessor = accessor; _endpointService = endpointService; _useCachedTokens = useCachedTokens; _dialogs = new DialogSet(_accessor); }
public void SetUp() { _page = MockRepository.GenerateMock <IFubuPage>(); _urls = new StubUrlRegistry(); _page.Stub(p => p.Urls).Return(_urls); var endpoints = new EndpointService(new StubAuthorizationPreviewService(), _urls); _page.Stub(p => p.Get <IEndpointService>()).Return(endpoints); }
public DashboardService(Endpoint[] restEndpoints, Endpoint endpointInitializationScript, string updateToken, string reloadToken) { EndpointService = new EndpointService(); SetRestEndpoints(restEndpoints); SetRunspaceFactory(endpointInitializationScript); UpdateToken = updateToken; ReloadToken = reloadToken; StartTime = DateTime.UtcNow; Properties = new Dictionary <string, object>(); }
public DashboardService(Dashboard dashboard, Endpoint[] restEndpoints, string updateToken, string reloadToken) { EndpointService = new EndpointService(); SetDashboard(dashboard); SetRestEndpoints(restEndpoints); UpdateToken = updateToken; ReloadToken = reloadToken; StartTime = DateTime.UtcNow; Properties = new Dictionary <string, object>(); }
/// <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="endpointService">Bot endpoint service.</param> /// <param name="telemetryClient">Bot telemetry client.</param> public VirtualAssistant(BotServices botServices, ConversationState conversationState, UserState userState, EndpointService endpointService, IBotTelemetryClient telemetryClient) { _conversationState = conversationState ?? throw new ArgumentNullException(nameof(conversationState)); _userState = userState ?? throw new ArgumentNullException(nameof(userState)); _services = botServices ?? throw new ArgumentNullException(nameof(botServices)); _endpointService = endpointService ?? throw new ArgumentNullException(nameof(endpointService)); _telemetryClient = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient)); _dialogs = new DialogSet(_conversationState.CreateProperty <DialogState>(nameof(VirtualAssistant))); _dialogs.Add(new MainDialog(_services, _conversationState, _userState, _endpointService, _telemetryClient)); }
/// <summary> /// Initializes a new instance of the <see cref="VirtualAssistant"/> class. /// </summary> /// <param name="botConfig">Bot configuration.</param> /// <param name="botServices">Bot services.</param> /// <param name="conversationState">Bot conversation state.</param> /// <param name="userState">Bot user state.</param> /// <param name="endpointService">Bot endpoint service.</param> public VirtualAssistant(BotServices botServices, BotConfiguration botConfig, ConversationState conversationState, UserState userState, EndpointService endpointService) { _conversationState = conversationState ?? throw new ArgumentNullException(nameof(conversationState)); _userState = userState ?? throw new ArgumentNullException(nameof(userState)); _services = botServices ?? throw new ArgumentNullException(nameof(botServices)); _endpointService = endpointService ?? throw new ArgumentNullException(nameof(endpointService)); _botConfig = botConfig; _dialogs = new DialogSet(_conversationState.CreateProperty <DialogState>(nameof(VirtualAssistant))); _dialogs.Add(new MainDialog(_services, _botConfig, _conversationState, _userState, _endpointService)); }
public SkillDialog(SkillDefinition skillDefinition, SkillConfigurationBase skillConfiguration, EndpointService endpointService, IBotTelemetryClient telemetryClient, bool useCachedTokens = true) : base(skillDefinition.Id) { _skillDefinition = skillDefinition; _skillConfiguration = skillConfiguration; _endpointService = endpointService; _telemetryClient = telemetryClient; _useCachedTokens = useCachedTokens; AddDialog(new MultiProviderAuthDialog(skillConfiguration)); }
public void SetRestEndpoints(Endpoint[] endpoints) { if (endpoints == null) { return; } foreach (var endpoint in endpoints) { EndpointService.Register(endpoint); } }
/// <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) { _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; _dialogs = new DialogSet(_conversationState.CreateProperty <DialogState>(nameof(VirtualAssistant))); _dialogs.Add(new MainDialog(_services, _conversationState, _userState, _proactiveState, _endpointService, _telemetryClient, _backgroundTaskQueue, _responseManager)); }
/// <summary> /// Initializes a new instance of the class. /// </summary> /// <param name="conversationState">The managed conversation state.</param> /// <param name="loggerFactory">A <see cref="ILoggerFactory"/> that is hooked to the Azure App Service provider.</param> /// <seealso cref="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-2.1#windows-eventlog-provider"/> public AgentBotBot( ConversationState conversationState, UserState userState, IServiceProvider serviceProvider, ILoggerFactory loggerFactory, BotServices botServices, EndpointService endpointService) { if (conversationState == null) { throw new ArgumentNullException(nameof(conversationState)); } if (userState == null) { throw new ArgumentNullException(nameof(userState)); } if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } _accessors = new AgentBotAccessors(conversationState, userState) { AgentState = userState.CreateProperty <AgentState>(AgentBotAccessors.AgentStateName), DialogState = conversationState.CreateProperty <DialogState>(AgentBotAccessors.DialogStateName) }; // Validate AppId. // Note: For local testing, .bot AppId is empty for the Bot Framework Emulator. AppId = string.IsNullOrWhiteSpace(endpointService.AppId) ? "1" : endpointService.AppId; _dialogSet = new DialogSet(_accessors.DialogState); _dialogSet.Add(new ProvisionAgentDialog("provision-agent", serviceProvider, _accessors)); _dialogSet.Add(new CreateInvitationDialog("create-invitation", serviceProvider, _accessors)); _dialogSet.Add(new AcceptInvitationDialog("accept-invitation", serviceProvider, _accessors)); _dialogSet.Add(new NotifyConnectedDialog("notify-connected", serviceProvider, _accessors, AppId)); _dialogSet.Add(new IssueCredentialDialog("issue-credential")); _dialogSet.Add(new TextPrompt("text-prompt")); _dialogSet.Add(new ConfirmPrompt("yes-no-prompt")); _dialogSet.Add(new ChoicePrompt("credential-type-prompt")); _logger = loggerFactory.CreateLogger <AgentBotBot>(); _logger.LogTrace("Turn start."); _serviceProvider = serviceProvider; _botServices = botServices; }
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); }
public SkillDialog(SkillDefinition skillDefinition, SkillConfigurationBase skillConfiguration, ProactiveState proactiveState, EndpointService endpointService, IBotTelemetryClient telemetryClient, IBackgroundTaskQueue backgroundTaskQueue, bool useCachedTokens = true) : base(skillDefinition.Id) { _skillDefinition = skillDefinition; _skillConfiguration = skillConfiguration; _proactiveState = proactiveState; _endpointService = endpointService; _telemetryClient = telemetryClient; _backgroundTaskQueue = backgroundTaskQueue; _useCachedTokens = useCachedTokens; var supportedLanguages = skillConfiguration.LocaleConfigurations.Keys.ToArray(); _responseManager = new ResponseManager(supportedLanguages, new SkillResponses()); AddDialog(new MultiProviderAuthDialog(skillConfiguration)); }
public CalendarSkill( SkillConfigurationBase services, EndpointService endpointService, ConversationState conversationState, UserState userState, ProactiveState proactiveState, IBotTelemetryClient telemetryClient, IBackgroundTaskQueue backgroundTaskQueue, bool skillMode = false, ResponseManager responseManager = null, IServiceManager serviceManager = null) { _skillMode = skillMode; _services = services ?? throw new ArgumentNullException(nameof(services)); _endpointService = endpointService ?? throw new ArgumentNullException(nameof(endpointService)); _userState = userState ?? throw new ArgumentNullException(nameof(userState)); _conversationState = conversationState ?? throw new ArgumentNullException(nameof(conversationState)); _proactiveState = proactiveState ?? throw new ArgumentNullException(nameof(proactiveState)); _serviceManager = serviceManager ?? new ServiceManager(_services); _telemetryClient = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient)); _backgroundTaskQueue = backgroundTaskQueue ?? throw new ArgumentNullException(nameof(backgroundTaskQueue)); if (responseManager == null) { var supportedLanguages = services.LocaleConfigurations.Keys.ToArray(); responseManager = new ResponseManager( new IResponseIdCollection[] { new FindContactResponses(), new ChangeEventStatusResponses(), new CreateEventResponses(), new JoinEventResponses(), new CalendarMainResponses(), new CalendarSharedResponses(), new SummaryResponses(), new TimeRemainingResponses(), new UpdateEventResponses(), new UpcomingEventResponses() }, supportedLanguages); } _responseManager = responseManager; _dialogs = new DialogSet(_conversationState.CreateProperty <DialogState>(nameof(DialogState))); _dialogs.Add(new MainDialog(_services, _endpointService, _responseManager, _conversationState, _userState, _proactiveState, _telemetryClient, _backgroundTaskQueue, _serviceManager, _skillMode)); }
public override void Initialize() { var builder = new ContainerBuilder(); ConversationState = new ConversationState(new MemoryStorage()); UserState = new UserState(new MemoryStorage()); this.ProactiveState = new ProactiveState(new MemoryStorage()); this.TelemetryClient = new NullBotTelemetryClient(); this.BackgroundTaskQueue = new BackgroundTaskQueue(); this.Services = new MockSkillConfiguration(); this.EndpointService = new EndpointService(); Services.LocaleConfigurations.Add("en", new LocaleConfiguration() { Locale = "en-us", LuisServices = new Dictionary <string, ITelemetryLuisRecognizer> { { "general", GeneralTestUtil.CreateRecognizer() },
public DashboardService(DashboardOptions dashboardOptions, string reloadToken) { EndpointService = new EndpointService(); if (dashboardOptions.Dashboard != null) { SetDashboard(dashboardOptions.Dashboard); } SetRestEndpoints(dashboardOptions.StaticEndpoints?.ToArray()); SetRunspaceFactory(dashboardOptions.EndpointInitializationScript); UpdateToken = dashboardOptions.UpdateToken; ReloadToken = reloadToken; StartTime = DateTime.UtcNow; Properties = new Dictionary <string, object>(); DashboardOptions = dashboardOptions; }
/// <summary> /// Initializes a new instance of the <see cref="AutomotiveSkill"/> class. /// </summary> /// <param name="services">Skill Configuration information.</param> /// <param name="endpointService">Endpoint service for the bot.</param> /// <param name="conversationState">Conversation State.</param> /// <param name="userState">User State.</param> /// <param name="proactiveState">Proative state.</param> /// <param name="telemetryClient">Telemetry Client.</param> /// <param name="backgroundTaskQueue">Background task queue.</param> /// <param name="serviceManager">Service Manager.</param> /// <param name="skillMode">Indicates whether the skill is running in skill or local mode.</param> /// <param name="responseManager">The responses for the bot.</param> /// <param name="httpContext">HttpContext accessor used to create relative URIs for images when in local mode.</param> public AutomotiveSkill( SkillConfigurationBase services, EndpointService endpointService, ConversationState conversationState, UserState userState, ProactiveState proactiveState, IBotTelemetryClient telemetryClient, IBackgroundTaskQueue backgroundTaskQueue, bool skillMode = false, ResponseManager responseManager = null, IServiceManager serviceManager = null, IHttpContextAccessor httpContext = null) { _skillMode = skillMode; _services = services ?? throw new ArgumentNullException(nameof(services)); _endpointService = endpointService ?? throw new ArgumentNullException(nameof(endpointService)); _userState = userState ?? throw new ArgumentNullException(nameof(userState)); // If we are running in local-mode we need the HttpContext to create image file paths if (!skillMode) { _httpContext = httpContext ?? throw new ArgumentNullException(nameof(httpContext)); } _conversationState = conversationState ?? throw new ArgumentNullException(nameof(conversationState)); _serviceManager = serviceManager ?? new ServiceManager(); _telemetryClient = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient)); if (responseManager == null) { var supportedLanguages = services.LocaleConfigurations.Keys.ToArray(); responseManager = new ResponseManager( new IResponseIdCollection[] { new AutomotiveSkillMainResponses(), new AutomotiveSkillSharedResponses(), new VehicleSettingsResponses(), }, supportedLanguages); } _responseManager = responseManager; _dialogs = new DialogSet(_conversationState.CreateProperty <DialogState>(nameof(DialogState))); _dialogs.Add(new MainDialog(_services, _responseManager, _conversationState, _userState, _serviceManager, _httpContext, _telemetryClient, _skillMode)); }
public MainDialog(BotServices services, BotConfiguration botConfig, ConversationState conversationState, UserState userState, EndpointService endpointService) : base(nameof(MainDialog)) { _services = services ?? throw new ArgumentNullException(nameof(services)); _botConfig = botConfig; _conversationState = conversationState; _userState = userState; _endpointService = endpointService; _onboardingState = _userState.CreateProperty <OnboardingState>(nameof(OnboardingState)); _parametersAccessor = _userState.CreateProperty <Dictionary <string, object> >("userInfo"); var dialogState = _conversationState.CreateProperty <DialogState>(nameof(DialogState)); AddDialog(new OnboardingDialog(_services, _onboardingState)); AddDialog(new EscalateDialog(_services)); AddDialog(new CustomSkillDialog(_services.SkillConfigurations, dialogState, endpointService)); // Initialize skill dispatcher _skillRouter = new SkillRouter(_services.SkillDefinitions); }
public SkillDialog(SkillDefinition skillDefinition, SkillConfigurationBase skillConfiguration, EndpointService endpointService, IBotTelemetryClient telemetryClient, bool useCachedTokens = true) : base(skillDefinition.Id) { _skillDefinition = skillDefinition; _skillConfiguration = skillConfiguration; _endpointService = endpointService; _telemetryClient = telemetryClient; _useCachedTokens = useCachedTokens; var supportedLanguages = skillConfiguration.LocaleConfigurations.Keys.ToArray(); _responseManager = new ResponseManager( new IResponseIdCollection[] { new CommonResponses() }, supportedLanguages); AddDialog(new MultiProviderAuthDialog(skillConfiguration)); }
public void SetDashboard(Dashboard dashboard) { if (dashboard == null) { return; } Dashboard = dashboard; var dashboardBuilder = new DashboardBuilder(); var app = dashboardBuilder.Build(Dashboard); ElementScripts = app.ElementScripts; foreach (var endpoint in app.Endpoints.ToArray()) { EndpointService.Register(endpoint); } SetRunspaceFactory(Dashboard.InitializationScript); }
/// <summary> /// Initializes a new instance of the <see cref="ProactiveMessage{T}"/> class. /// </summary> /// <param name="accessors">The state accessors for managing bot state.</param> /// <param name="adapterIntegration">The <see cref="BotFrameworkAdapter"/> connects the bot to the service endpoint of the given channel.</param> /// <param name="env">Provides information about the web hosting environment an application is running in.</param> /// <param name="services">External services.</param> /// <param name="queueName">Service Bus queue name.</param> /// <param name="dialogs">List of Types of other <see cref="Dialog"/>s used when sending out the proactive message.</param> /// <param name="telemetryClient">Telemetry client.</param> public ProactiveMessage(StateAccessors accessors, IAdapterIntegration adapterIntegration, IHostingEnvironment env, BotServices services, string queueName, Dialog[] dialogs, TelemetryClient telemetryClient) { _accessors = accessors; _env = env; _botFrameworkAdapter = (BotFrameworkAdapter)adapterIntegration; _telemetryClient = telemetryClient; _dialogs = new DialogSet(_accessors.DialogStateAccessor); foreach (var dialog in dialogs) { _dialogs.Add(dialog); } // Verify Endpoint configuration. var endpointConfig = env.IsProduction() ? CarWashBot.EndpointConfiguration : CarWashBot.EndpointConfigurationDev; if (!services.EndpointServices.ContainsKey(endpointConfig)) { throw new ArgumentException($"Invalid configuration. Please check your '.bot' file for a Endpoint service named '{endpointConfig}'."); } _endpoint = services.EndpointServices[endpointConfig]; // Verify Storage configuration. if (!services.StorageServices.ContainsKey(CarWashBot.StorageConfiguration)) { throw new ArgumentException($"Invalid configuration. Please check your '.bot' file for a Storage service named '{CarWashBot.StorageConfiguration}'."); } var tableClient = services.StorageServices[CarWashBot.StorageConfiguration].CreateCloudTableClient(); _table = tableClient.GetTableReference(CarWashBot.UserStorageTableName); // Verify ServiceBus configuration. if (!services.ServiceBusServices.ContainsKey(CarWashBot.ServiceBusConfiguration)) { throw new ArgumentException($"Invalid configuration. Please check your '.bot' file for a Service Bus service named '{CarWashBot.ServiceBusConfiguration}'."); } _queueClient = new QueueClient(services.ServiceBusServices[CarWashBot.ServiceBusConfiguration], queueName, ReceiveMode.PeekLock, null); }