public BotController( ILogger <BotController> logger, IAdapterIntegration adapter) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _adapter = adapter ?? throw new ArgumentNullException(nameof(adapter)); }
public Timers( IAdapterIntegration adapter, IConfiguration configuration) { _adapter = adapter; var appId = (configuration ?? throw new System.ArgumentNullException(nameof(configuration)))["BotWebApiApp:AppId"];
public Timer( IAdapterIntegration adapter, ConversationReference conversationReference, int seconds, int number) { _adapter = adapter; _logger = Log.ForContext <Timer>(); ConversationReference = conversationReference; Seconds = seconds; Number = number; }
public BotController( ObjectLogger objectLogger, IAdapterIntegration botAdapter, IBotFrameworkHttpAdapter alexaAdapter, AlexaBot alexaBot, MonitorBot monitorBot) { _objectLogger = objectLogger; _botAdapter = botAdapter; _alexaAdapter = alexaAdapter; _alexaBot = alexaBot; _monitorBot = monitorBot; }
public BotController( ILogger <BotController> logger, IAdapterIntegration adapter, IBot bot, IConfiguration configuration, Conversations conversations) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _adapter = adapter ?? throw new ArgumentNullException(nameof(adapter)); _bot = bot ?? throw new ArgumentNullException(nameof(bot)); _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); _conversations = conversations ?? throw new ArgumentNullException(nameof(conversations)); _logger.LogTrace("----- INSTANCE CREATED - {ClassName}", GetType().Name); }
public AlexaBot( ObjectLogger objectLogger, BotConversation conversation, IAdapterIntegration botAdapter, IConfiguration configuration, BotStateAccessors accessors, IMediator mediator, ILogger <AlexaBot> logger) { _objectLogger = objectLogger; _conversation = conversation; _botAdapter = botAdapter; _configuration = configuration; _accessors = accessors; _mediator = mediator; _logger = logger; }
/// <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); }
public AlexaBot( ILogger <AlexaBot> logger, ObjectLogger objectLogger, IConfiguration configuration, IAdapterIntegration botAdapter, BotConversation conversation, BotStateAccessors accessors, QnAMakerEndpoint endpoint) { _logger = logger; _objectLogger = objectLogger; _configuration = configuration; // ** Bot adapter (to send proactive message) _botAdapter = botAdapter; // ** Bot state handling _conversation = conversation; _accessors = accessors; // ** QnA endpoint AlexaBotQnA = new QnAMaker(endpoint); }
/// <summary> /// Initializes a new instance of the <see cref="WashStartedMessage"/> class. /// </summary> /// <param name="configuration">CarWash app configuration.</param> /// <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> public WashStartedMessage(CarWashConfiguration configuration, StateAccessors accessors, IAdapterIntegration adapterIntegration, IHostingEnvironment env, BotServices services) : base(accessors, adapterIntegration, env, services, configuration.ServiceBusQueues.BotWashStartedQueue, new Dialog[] { AuthDialog.LoginPromptDialog(), new FindReservationDialog() }) { }
/// <summary> /// Deserializes the incoming request using a BotMessageHandler, processes it with an <see cref="IAdapterIntegration"/> /// and returns an <see cref="InvokeResponse"/>. /// </summary> /// <param name="request">A <see cref="HttpRequestMessage"/>.</param> /// <param name="adapter">An instance of <see cref="IAdapterIntegration"/>.</param> /// <param name="botCallbackHandler">An instance of <see cref="BotCallbackHandler"/>.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/>.</param> /// <returns>An <see cref="InvokeResponse"/> returned from the adapter.</returns> protected override async Task <InvokeResponse> ProcessMessageRequestAsync(HttpRequestMessage request, IAdapterIntegration adapter, BotCallbackHandler botCallbackHandler, CancellationToken cancellationToken) { var activity = await request.Content.ReadAsAsync <Activity>(BotMessageHandlerBase.BotMessageMediaTypeFormatters, cancellationToken).ConfigureAwait(false); var invokeResponse = await adapter.ProcessActivityAsync( request.Headers.Authorization?.ToString(), activity, botCallbackHandler, cancellationToken).ConfigureAwait(false); return(invokeResponse); }
/// <summary> /// Initializes a new instance of the <see cref="BotMessageHandler"/> class. /// </summary> /// <param name="adapter">An instance of <see cref="IAdapterIntegration"/>.</param> public BotMessageHandler(IAdapterIntegration adapter) : base(adapter) { }
private static void ConfigureBotRoutes(HttpConfiguration httpConfiguration, BotFrameworkOptions options, IAdapterIntegration adapter) { var routes = httpConfiguration.Routes; var baseUrl = options.Paths.BasePath; routes.MapHttpRoute( BotMessageHandler.RouteName, baseUrl.Trim('/') + "/" + options.Paths.MessagesPath.Trim('/'), defaults: null, constraints: null, #pragma warning disable CA2000 // Dispose objects before losing scope (we will let ASP.Net core deal with disposing this handler) handler: new BotMessageHandler(adapter)); #pragma warning restore CA2000 // Dispose objects before losing scope }
public InteceptorAdapter(IAdapterIntegration innerAdapter) { _innerAdapter = innerAdapter; }
public async Task SendMessage(IAdapterIntegration adapter, string botAppId, ConversationReference conversationReference, CancellationToken cancellationToken) { await adapter.ContinueConversationAsync(botAppId, conversationReference, SendMessageAsync); }
/// <summary> /// Initializes a new instance of the <see cref="CarWashCommentLeftMessage"/> class. /// </summary> /// <param name="configuration">CarWash app configuration.</param> /// <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="telemetryClient">Telemetry client.</param> public CarWashCommentLeftMessage(CarWashConfiguration configuration, StateAccessors accessors, IAdapterIntegration adapterIntegration, IHostingEnvironment env, BotServices services, TelemetryClient telemetryClient) : base(accessors, adapterIntegration, env, services, configuration.ServiceBusQueues.BotCarWashCommentLeftQueue, new Dialog[] { AuthDialog.LoginPromptDialog(), new FindReservationDialog(telemetryClient) }, telemetryClient) { _telemetryClient = telemetryClient; }
/// <summary> /// Initializes a new instance of the <see cref="VehicleArrivedMessage"/> class. /// </summary> /// <param name="configuration">CarWash app configuration.</param> /// <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="telemetryClient">Telemetry client.</param> public VehicleArrivedMessage(CarWashConfiguration configuration, StateAccessors accessors, IAdapterIntegration adapterIntegration, IHostingEnvironment env, BotServices services, TelemetryClient telemetryClient) : base(accessors, adapterIntegration, env, services, configuration.ServiceBusQueues.BotVehicleArrivedNotificationQueue, new Dialog[] { AuthDialog.LoginPromptDialog(), new FindReservationDialog(telemetryClient) }, telemetryClient) { }
/// <summary> /// Abstract method to process the incoming request using the instance of <see cref="IAdapterIntegration"/> /// and to return an <see cref="InvokeResponse"/>. /// </summary> /// <param name="request">A <see cref="HttpRequestMessage"/>.</param> /// <param name="adapter">An instance of <see cref="IAdapterIntegration"/>.</param> /// <param name="botCallbackHandler">An instance of <see cref="BotCallbackHandler"/>.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/>.</param> /// <returns>An <see cref="InvokeResponse"/> returned from the adapter.</returns> protected abstract Task <InvokeResponse> ProcessMessageRequestAsync(HttpRequestMessage request, IAdapterIntegration adapter, BotCallbackHandler botCallbackHandler, CancellationToken cancellationToken);
public Timers(IAdapterIntegration adapter) { _adapter = adapter; }
public ChatHub(IUserRepository userRepository, IAdapterIntegration adapter, ConfigurationCredentialProvider credentialProvider) { this.userRepository = userRepository; this.adapter = (BotFrameworkAdapter)adapter; this.credentialProvider = credentialProvider; }
public ProactiveController(IAdapterIntegration adapter) { this._adapter = (BotFrameworkAdapter)adapter; }
/// <summary> /// Deserializes the incoming request using a BotMessageHandler, processes it with an <see cref="IAdapterIntegration"/> /// and returns an <see cref="InvokeResponse"/>. /// </summary> /// <param name="request">A <see cref="HttpRequest"/>.</param> /// <param name="adapter">An instance of <see cref="IAdapterIntegration"/>.</param> /// <param name="botCallbackHandler">An instance of <see cref="BotCallbackHandler"/>.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/>.</param> /// <returns>An <see cref="InvokeResponse"/> returned from the adapter.</returns> protected override async Task <InvokeResponse> ProcessMessageRequestAsync(HttpRequest request, IAdapterIntegration adapter, BotCallbackHandler botCallbackHandler, CancellationToken cancellationToken) { Activity activity; using (var memoryStream = new MemoryStream()) { await request.Body.CopyToAsync(memoryStream).ConfigureAwait(false); // In the case of request buffering being enabled, we could possibly receive a Stream that needs its position reset, // but we can't _blindly_ reset in case buffering hasn't been enabled since we'll be working with a non-seekable Stream // in that case which will throw a NotSupportedException if (request.Body.CanSeek) { request.Body.Position = 0; } memoryStream.Position = 0; // Get the request body and deserialize to the Activity object. // NOTE: We explicitly leave the stream open here so others can still access it (in case buffering was enabled); ASP.NET runtime will always dispose of it anyway using (var bodyReader = new JsonTextReader(new StreamReader(memoryStream, Encoding.UTF8, detectEncodingFromByteOrderMarks: false, bufferSize: 1024, leaveOpen: true))) { activity = BotMessageSerializer.Deserialize <Activity>(bodyReader); } } var invokeResponse = await adapter.ProcessActivityAsync( request.Headers["Authorization"], activity, botCallbackHandler, cancellationToken).ConfigureAwait(false); return(invokeResponse); }
protected override async Task <InvokeResponse> ProcessMessageRequestAsync(HttpRequest request, IAdapterIntegration adapter, BotCallbackHandler botCallbackHandler, CancellationToken cancellationToken) { var activity = default(Activity); using (var bodyReader = new JsonTextReader(new StreamReader(request.Body, Encoding.UTF8))) { activity = BotMessageHandlerBase.BotMessageSerializer.Deserialize <Activity>(bodyReader); } #pragma warning disable UseConfigureAwait // Use ConfigureAwait var invokeResponse = await adapter.ProcessActivityAsync( request.Headers["Authorization"], activity, botCallbackHandler, cancellationToken); #pragma warning restore UseConfigureAwait // Use ConfigureAwait return(invokeResponse); }
public NotificationService(string botAppId, IAdapterIntegration adapter) { _botAppId = botAppId ?? throw new ArgumentNullException(nameof(botAppId)); _adapter = adapter ?? throw new ArgumentNullException(nameof(adapter)); }
/// <summary> /// Initializes a new instance of the <see cref="BotMessageHandlerBase"/> class. /// </summary> /// <param name="adapter">An instance of <see cref="IAdapterIntegration"/>.</param> public BotMessageHandlerBase(IAdapterIntegration adapter) { _adapter = adapter ?? throw new ArgumentNullException(nameof(adapter)); }
private static void ConfigureBotRoutes(HttpConfiguration httpConfiguration, BotFrameworkOptions options, IAdapterIntegration adapter) { var routes = httpConfiguration.Routes; var baseUrl = options.Paths.BasePath; routes.MapHttpRoute( BotMessageHandler.RouteName, baseUrl.Trim('/') + "/" + options.Paths.MessagesPath.Trim('/'), defaults: null, constraints: null, handler: new BotMessageHandler(adapter)); }