Skip to content

Commit

Permalink
Ignore errors from sending the typing indicator (#95)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aosolis authored Mar 25, 2020
1 parent 55e0419 commit 6784c0e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Source/Microsoft.Teams.Apps.FAQPlusPlus/Bots/FaqPlusPlusBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -581,11 +581,20 @@ private async Task<TeamsChannelAccount> 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);
}
}

/// <summary>
Expand Down

0 comments on commit 6784c0e

Please sign in to comment.