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); }
private static async Task Main() { _uiPathHttpClient = new UiPathHttpClient(Settings.UiPathUserName, Settings.UiPathPassword, Settings.UiPathTenancyName); // DirectLine requires at least TLS 1.2 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; WriteLine("== Initializing direct line connection =="); var tokenResponse = new DirectLineClient(Settings.BotSecret).Tokens .GenerateTokenForNewConversation(); var conversation = await InitializeDirectLine(tokenResponse); var webSocketClient = new WebSocket(conversation.StreamUrl) { SslConfiguration = { EnabledSslProtocols = SslProtocols.Tls12 } }; webSocketClient.OnOpen += (sender, args) => WriteLine("Connected to direct line."); webSocketClient.OnMessage += async(sender, eventArgs) => { await WebSocketClientOnOnMessage(eventArgs); }; webSocketClient.Connect(); Read(); }