microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
Samples/Samples.BotBuilder/BotBuilderAdapter.cs
25lines · modecode
| 1 | using Microsoft.Bot.Builder.Integration.AspNet.Core; |
| 2 | using Microsoft.Bot.Builder.TraceExtensions; |
| 3 | using Microsoft.Bot.Connector.Authentication; |
| 4 | |
| 5 | namespace Samples.BotBuilder |
| 6 | { |
| 7 | public class BotBuilderAdapter : CloudAdapter |
| 8 | { |
| 9 | public BotBuilderAdapter(BotFrameworkAuthentication auth, ILogger<IBotFrameworkHttpAdapter> logger) |
| 10 | : base(auth, logger) |
| 11 | { |
| 12 | OnTurnError = async (turnContext, exception) => |
| 13 | { |
| 14 | logger.LogError(exception, $"[OnTurnError] unhandled error : {exception.Message}"); |
| 15 | |
| 16 | // Send a message to the user |
| 17 | await turnContext.SendActivityAsync("The bot encountered an error or bug."); |
| 18 | await turnContext.SendActivityAsync("To continue to run this bot, please fix the bot source code."); |
| 19 | |
| 20 | // Send a trace activity, which will be displayed in the Bot Framework Emulator |
| 21 | await turnContext.TraceActivityAsync("OnTurnError Trace", exception.Message, "https://www.botframework.com/schemas/error", "TurnError"); |
| 22 | }; |
| 23 | } |
| 24 | } |
| 25 | } |