public RingCentralClientWrapper(IOptionsMonitor <RingCentralOptions> options, IHandoffRequestRecognizer handoffRequestRecognizer, ILogger logger = null) { _options = options ?? throw new ArgumentNullException(nameof(options)); _handoffRequestRecognizer = handoffRequestRecognizer ?? throw new ArgumentNullException(nameof(handoffRequestRecognizer)); _logger = logger ?? NullLogger.Instance; if (string.IsNullOrWhiteSpace(_options.CurrentValue.RingCentralEngageApiAccessToken)) { throw new ArgumentException(nameof(options.CurrentValue.RingCentralEngageApiAccessToken)); } if (_options.CurrentValue.RingCentralEngageApiUrl == null) { throw new ArgumentException(nameof(options.CurrentValue.RingCentralEngageApiUrl)); } // DimeloClient is used to send messages out to RingCentral platform in order to log messages // only do this if this feature has been enabled. if (_options.CurrentValue.LogMessagesToRingCentral) { if (string.IsNullOrWhiteSpace(_options.CurrentValue.RingCentralEngageCustomSourceRealtimeEndpointUrl)) { throw new ArgumentException(nameof(_options.CurrentValue.RingCentralEngageCustomSourceRealtimeEndpointUrl)); } if (_options.CurrentValue.RingCentralEngageCustomSourceApiAccessToken == null) { throw new ArgumentException(nameof(_options.CurrentValue.RingCentralEngageCustomSourceApiAccessToken)); } _ringCentralClient = new DimeloClient(_options.CurrentValue.RingCentralEngageCustomSourceRealtimeEndpointUrl, _options.CurrentValue.RingCentralEngageCustomSourceApiAccessToken); } }
public RingCentralAdapterWithErrorHandler( IBotFrameworkHttpAdapter botAdapter, RingCentralClientWrapper ringCentralClient, DownRenderingMiddleware downRenderingMiddleware, IHandoffRequestRecognizer handoffRequestRecognizer, ILogger <RingCentralAdapter> logger) : base(ringCentralClient, botAdapter, handoffRequestRecognizer, logger) { _ = downRenderingMiddleware ?? throw new NullReferenceException(nameof(downRenderingMiddleware)); // Downrender outbound messages processed by the adapter Use(downRenderingMiddleware); OnTurnError = async(turnContext, exception) => { // Log any leaked exception from the application. logger.LogError(exception, $"[OnTurnError] unhandled error : {exception.Message}"); // Send a message to the user await turnContext.SendActivityAsync("The bot encountered an error or bug."); await turnContext.SendActivityAsync("To continue to run this bot, please fix the bot source code."); // Send a trace activity, which will be displayed in the Bot Framework Emulator await turnContext.TraceActivityAsync("OnTurnError Trace", exception.Message, "https://www.botframework.com/schemas/error", "TurnError"); }; }
/// <summary> /// Initializes a new instance of the <see cref="RingCentralAdapter"/> class. /// </summary> /// <param name="ringCentralClient">RingCentralClient instance.</param> /// <param name="botAdapter">BotAdapter of the bot.</param> /// <param name="handoffRequestRecognizer">Recognizer to determine if it's a human or bot request.</param> /// <param name="logger">Logger instance.</param> public RingCentralAdapter( RingCentralClientWrapper ringCentralClient, IBotFrameworkHttpAdapter botAdapter, IHandoffRequestRecognizer handoffRequestRecognizer, ILogger logger = null) { _ringCentralClient = ringCentralClient ?? throw new ArgumentNullException(nameof(ringCentralClient)); _botAdapter = botAdapter ?? throw new ArgumentNullException(nameof(botAdapter)); _handoffRequestRecognizer = handoffRequestRecognizer ?? throw new ArgumentNullException(nameof(handoffRequestRecognizer)); _logger = logger ?? NullLogger.Instance; }
public RingCentralClientWrapper(IOptionsMonitor <RingCentralOptions> options) { _options = options ?? throw new ArgumentNullException(nameof(options)); _handoffRequestRecognizer = new StaticHandoffRequestRecognizer(); _logger = NullLogger.Instance; }
/// <summary> /// Initializes a new instance of the <see cref="ActivityPublishingMiddleware"/> class. /// Creates a new <see cref="ActivityPublishingMiddleware"/>. /// </summary> /// <param name="ringCentralClient">Client that is used to publish the activities to the RingCentral platform.</param> /// <param name="handoffRequestRecognizer">Analyzer to detect a handoff request.</param> /// <param name="logger">Optional logger.</param> public ActivityPublishingMiddleware(RingCentralClientWrapper ringCentralClient, IHandoffRequestRecognizer handoffRequestRecognizer, ILogger logger = null) { _ringCentralClient = ringCentralClient ?? throw new ArgumentNullException(nameof(ringCentralClient)); _handoffRequestRecognizer = handoffRequestRecognizer ?? throw new ArgumentNullException(nameof(handoffRequestRecognizer)); _logger = logger ?? NullLogger.Instance; }