microsoft/teams.net

Public

mirrored fromhttps://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
74588b33035a67444a68e0299b0b92494fa76c4a

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

Samples/Samples.BotBuilder/BotBuilderAdapter.cs

25lines · modecode

1using Microsoft.Bot.Builder.Integration.AspNet.Core;
2using Microsoft.Bot.Builder.TraceExtensions;
3using Microsoft.Bot.Connector.Authentication;
4
5namespace 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}