Created
March 3, 2022 00:03
-
-
Save sunnyy02/434a8f6d0f93551e2ad7931e9fddf745 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Bot.Builder.Adapters.Twilio; | |
using Microsoft.Bot.Builder.TraceExtensions; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.Logging; | |
namespace AppointmentBot | |
{ | |
public class TwilioAdapterWithErrorHandler : TwilioAdapter | |
{ | |
public TwilioAdapterWithErrorHandler(IConfiguration configuration, ILogger<TwilioAdapter> logger) | |
: base(configuration, null, logger) | |
{ | |
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"); | |
}; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment