From 6784c0e44cb851ae2cfd513ec6dc26b5c9ef4229 Mon Sep 17 00:00:00 2001 From: Adrian Solis Date: Wed, 25 Mar 2020 12:09:33 -0700 Subject: [PATCH] Ignore errors from sending the typing indicator (#95) Bots posting typing-indicators to users in Europe region are receiving 502s at this time, as typing indicator support is scaled down temporarily to provide more resources to other scenarios. This change suppresses the exception thrown by sending the typing indicator, so that a failure to post the indicator is not a fatal error. The exception is still logged to App Insights so that the admin can monitor the ultimate resolution of this issue. --- .../Bots/FaqPlusPlusBot.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Source/Microsoft.Teams.Apps.FAQPlusPlus/Bots/FaqPlusPlusBot.cs b/Source/Microsoft.Teams.Apps.FAQPlusPlus/Bots/FaqPlusPlusBot.cs index 1c6f4f6..222f790 100644 --- a/Source/Microsoft.Teams.Apps.FAQPlusPlus/Bots/FaqPlusPlusBot.cs +++ b/Source/Microsoft.Teams.Apps.FAQPlusPlus/Bots/FaqPlusPlusBot.cs @@ -581,11 +581,20 @@ private async Task GetUserDetailsInPersonalChatAsync( } // Send typing indicator to the user. - private Task SendTypingIndicatorAsync(ITurnContext turnContext) + private async Task SendTypingIndicatorAsync(ITurnContext turnContext) { - var typingActivity = turnContext.Activity.CreateReply(); - typingActivity.Type = ActivityTypes.Typing; - return turnContext.SendActivityAsync(typingActivity); + try + { + var typingActivity = turnContext.Activity.CreateReply(); + typingActivity.Type = ActivityTypes.Typing; + await turnContext.SendActivityAsync(typingActivity); + } + catch (Exception ex) + { + // Do not fail on errors sending the typing indicator + this.telemetryClient.TrackTrace($"Failed to send a typing indicator: {ex.Message}", SeverityLevel.Warning); + this.telemetryClient.TrackException(ex); + } } ///