![]() |
VOOZH | about |
dotnet add package Encamina.Enmarcha.Bot --version 8.3.0
NuGet\Install-Package Encamina.Enmarcha.Bot -Version 8.3.0
<PackageReference Include="Encamina.Enmarcha.Bot" Version="8.3.0" />
<PackageVersion Include="Encamina.Enmarcha.Bot" Version="8.3.0" />Directory.Packages.props
<PackageReference Include="Encamina.Enmarcha.Bot" />Project file
paket add Encamina.Enmarcha.Bot --version 8.3.0
#r "nuget: Encamina.Enmarcha.Bot, 8.3.0"
#:package Encamina.Enmarcha.Bot@8.3.0
#addin nuget:?package=Encamina.Enmarcha.Bot&version=8.3.0Install as a Cake Addin
#tool nuget:?package=Encamina.Enmarcha.Bot&version=8.3.0Install as a Cake Tool
Bot is a project that primarily contains cross-cutting utilities that can be used in a wide variety of projects.
First, install NuGet. Then, install Encamina.Enmarcha.Bot from the package manager console:
PM> Install-Package Encamina.Enmarcha.Bot
First, install .NET CLI. Then, install Encamina.Enmarcha.Bot from the .NET CLI:
dotnet add package Encamina.Enmarcha.Bot
Below are some of the most important utilities.
ActivityProcessorBase is an abstract class that processes activities from a turn context. It extends the HandlerManagerBase<IActivityHandler> class and implements the IActivityProcessor interface.
To use this class, you need to create a derived class and provide the necessary parameters to the base constructor:
public class MyActivityProcessor : ActivityProcessorBase
{
public MyActivityProcessor(IEnumerable<IActivityHandler> handlers) : base(handlers)
{
}
// Implement other methods as needed
}
The class defines several methods:
BeginProcessAsync: Begins the process of an activity.EndProcessAsync: Ends the process of an activity.ProcessAsync: Processes an activity based on the HandlerProcessTimes parameter.BotCloudAdapterWithErrorHandlerBase is a class that extends the CloudAdapter from the Microsoft Bot Framework, providing custom error handling for a bot that can be hosted in different cloud environments.
To use this class, you need to create an instance of IBotAdapterOptions<BotCloudAdapterWithErrorHandlerBase> and pass it to the constructor:
var options = new BotAdapterOptions<BotCloudAdapterWithErrorHandlerBase>
{
BotFrameworkAuthentication = new PasswordServiceClientCredentialFactory("MicrosoftAppId", "MicrosoftAppPassword"),
Logger = LoggerFactory.Create(builder => builder.AddConsole()).CreateLogger<BotCloudAdapterWithErrorHandlerBase>()
};
var adapter = new BotCloudAdapterWithErrorHandlerBase(options);
This will create a new instance of BotCloudAdapterWithErrorHandlerBase with the provided options. The OnTurnError property is set to ErrorHandlerAsync, which handles errors during the bot's turn.
The class also defines a list of default middleware rules that the bot will use:
TelemetryInitializerMiddleware: This middleware initializes telemetry for the bot. It's important to note that this middleware calls
TelemetryLoggerMiddleware, so adding TelemetryLoggerMiddleware as middleware will produce repeated log entries.
TranscriptLoggerMiddleware: This middleware logs the transcript of the conversation.
ShowTypingMiddleware: This middleware sends typing indicators to the user while the bot is processing the message.
AutoSaveStateMiddleware: This middleware automatically saves the bot's state after each turn.
BotAdapterOptionsBase is an abstract class that provides common options for a bot adapter. It implements the IBotAdapterOptions interface.
To use this class, you need to create a derived class and provide the necessary parameters to the base constructor:
public class MyBotAdapterOptions : BotAdapterOptionsBase
{
public MyBotAdapterOptions(BotFrameworkAuthentication botFrameworkAuthentication, IBotTelemetryClient botTelemetryClient, IEnumerable<BotState> botStates, IEnumerable<IMiddleware> botMiddlewares)
: base(botFrameworkAuthentication, botTelemetryClient, botStates, botMiddlewares)
{
}
}
CardActionFactory is a static class that contains utility methods to create various CardAction objects. CardAction is a class from the Microsoft Bot Framework that represents an action that can be performed from a card.
You can use the methods of this class to create CardAction objects:
var emptyAction = CardActionFactory.EmptyAction("Some text");
var value = new MyActivityValue(); // MyActivityValue must inherit from ActivityValueBase
var messageBackAction = CardActionFactory.MessageBackAction(value, "Some text", "https://example.com/image.png");
The class defines several methods:
EmptyAction: Creates a CardAction without an action type and only text.MessageBackAction: Creates a CardAction that can be used to message back the bot with some values.BotBaseController is an abstract class that extends the ControllerBase class from ASP.NET Core. It's designed to handle requests from web chats or DirectLine clients.
To use this class, you need to create a derived class and provide the necessary parameters to the base constructor:
public class MyBotController : BotBaseController
{
public MyBotController(IBotFrameworkHttpAdapter adapter, IBot bot) : base(adapter, bot)
{
}
public override async Task HandleAsync()
{
// Implement your own logic to handle the request
}
}
You can then use your derived controller in your ASP.NET Core application:
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IBotFrameworkHttpAdapter, BotFrameworkHttpAdapter>();
services.AddSingleton<IBot, MyBot>();
services.AddControllers();
}
The class defines a method:
HandleAsync: Handles a request for the bot. This method is virtual and can be overridden in a derived class.ILoggingBuilderExtensions is a static class that contains an extension method for the ILoggingBuilder interface. It's designed to add an Application Insights logger to the logging factory.
You can use the AddApplicationInsigthsConversationScoped method to add an Application Insights logger to your logging factory:
public void ConfigureServices(IServiceCollection services)
{
services.AddLogging(builder =>
{
builder.AddApplicationInsigthsConversationScoped(
configureTelemetryConfiguration: config => { /* Configure telemetry here */ },
configureApplicationInsightsLoggerOptions: options => { /* Configure logger options here */ }
);
});
}
The class defines a method:
AddApplicationInsigthsConversationScoped: Adds an Application Insights logger named ApplicationInsigthsConversationScopedLoggerProvider to the factory.IServiceCollectionExtensions is a static class that contains extension methods for the IServiceCollection interface. It's designed to add services to the service collection, which is a fundamental part of the dependency injection system in ASP.NET Core.
You can use the AddDefaultBotStates method to add default bot states to your service collection:
public void ConfigureServices(IServiceCollection services)
{
services.AddDefaultBotStates();
}
The class defines a method:
AddDefaultBotStates: Adds default bot states to the service collection. These default bot states are ConversationState and UserState.LocalizedHeroCardGreetingsOptionsFromTableStorage is a class that provides localized options for greeting messages based on hero cards. The data is stored in Azure Table Storage. It implements the ILocalizedHeroCardGreetingsOptions interface.
To use this class, you need to create an instance and provide the necessary parameters:
var tableConnectionString = "Your Azure Table Storage connection string";
var tableName = "Your Azure Table Storage table name";
var defaultLocale = "en-US"; // The default locale
var cacheAbsoluteExpirationSeconds = 86400; // The cache expiration time in seconds
IMemoryCache memoryCache = null; // An optional memory cache
var options = new LocalizedHeroCardGreetingsOptionsFromTableStorage(tableConnectionString, tableName, defaultLocale, cacheAbsoluteExpirationSeconds, memoryCache);
You can then use this instance to get localized greeting messages based on hero cards. The exact usage will depend on how the ILocalizedHeroCardGreetingsOptions interface and its methods are used in your application.
The class has a constructor:
LocalizedHeroCardGreetingsOptionsFromTableStorage: Initializes a new instance of the class. It takes a connection string and table name for Azure Table Storage, a default locale, an expiration time for the cache, and an optional memory cache.LocalizedHeroCardGreetingsProvider is a class that sends a greeting message using a HeroCard. The message is localized based on the culture info from the activity. It extends the GreetingsProviderBase class.
To use this class, you need to create an instance and provide the necessary parameters:
var options = new LocalizedHeroCardGreetingsOptionsFromTableStorage(/* parameters here */);
var logger = LoggerFactory.Create(builder => builder.AddConsole()).CreateLogger<LocalizedHeroCardGreetingsProvider>();
var provider = new LocalizedHeroCardGreetingsProvider(options, logger);
You can then use this instance to send a greeting message:
await provider.SendAsync(turnContext, cancellationToken);
LocalizedHeroCardGreetingsProvider: Initializes a new instance of the class. It takes greetings options with values to build a HeroCard and a logger for this greetings provider.Options: Gets the current greetings options with values to build a HeroCard.SendAsync: Sends a greeting message using a HeroCard. The message is localized based on the culture info from the activity.LocalizedResponseGreetingsProvider is a class that sends a greeting message based on responses retrieved from an IIntentResponsesProvider. The message is localized based on the culture info from the activity. It extends the GreetingsProviderBase class.
To use this class, you need to create an instance and provide the necessary parameters:
IIntentResponsesProvider responsesProvider = /* Your IIntentResponsesProvider instance */;
string defaultLocale = "en-US"; // The default locale
string intentName = "Greetings"; // The expected greetings intent name
var provider = new LocalizedResponseGreetingsProvider(responsesProvider, defaultLocale, intentName);
You can then use this instance to send a greeting message:
await provider.SendAsync(turnContext, cancellationToken);
LocalizedResponseGreetingsProvider: Initializes a new instance of the class. It takes an IIntentResponsesProvider, a default locale, and an intent name.SendAsync: Sends a greeting message based on responses retrieved from an IIntentResponsesProvider. The message is localized based on the culture info from the activity.ApplicationInsightsConversationScopedLoggerEventSource is a class that logs error messages to Application Insights. It extends the EventSource class.
You can use the FailedToLog method to log an error message to Application Insights:
string errorMessage = "An error occurred.";
string applicationName = "MyApplication"; // Optional
ApplicationInsightsConversationScopedLoggerEventSource.Log.FailedToLog(errorMessage, applicationName);
ApplicationInsightsConversationScopedLoggerEventSource: Initializes a new instance of the class. It initializes the applicationName field with the name of the entry assembly.Log: Gets the instance of the logger event source.FailedToLog: Logs an error message to Application Insights. It takes an error message and an optional application name as parameters.ApplicationInsigthsConversationScopedLogger is a class that forwards log messages as Application Insights trace events and tracks the ConversationId as a property in the telemetry. It implements the ILogger interface.
To use this class, you need to create an instance and provide the necessary parameters:
string categoryName = "MyCategory";
TelemetryClient telemetryClient = new TelemetryClient();
ApplicationInsightsConversationScopedLoggerOptions options = new ApplicationInsightsConversationScopedLoggerOptions();
IHttpContextAccessor httpContextAccessor = new HttpContextAccessor();
var logger = new ApplicationInsigthsConversationScopedLogger(categoryName, telemetryClient, options, httpContextAccessor);
You can then use this instance to log messages:
logger.Log(LogLevel.Information, "This is a log message.");
ApplicationInsigthsConversationScopedLogger: Initializes a new instance of the class. It takes a category name, a TelemetryClient, an ApplicationInsightsConversationScopedLoggerOptions, and an IHttpContextAccessor.As an implementation of the ILogger interface, this class should implement methods such as Log, IsEnabled, and BeginScope.
ApplicationInsigthsConversationScopedLoggerProvider is a class that creates instances of ApplicationInsigthsConversationScopedLogger. It implements the ILoggerProvider and ISupportExternalScope interfaces.
To use this class, you need to create an instance and provide the necessary parameters:
IOptions<ApplicationInsightsConversationScopedLoggerOptions> options = Options.Create(new ApplicationInsightsConversationScopedLoggerOptions());
TelemetryClient telemetryClient = new TelemetryClient();
IHttpContextAccessor httpContextAccessor = new HttpContextAccessor();
var loggerProvider = new ApplicationInsigthsConversationScopedLoggerProvider(options, telemetryClient, httpContextAccessor);
You can then use this instance to create a logger:
ILogger logger = loggerProvider.CreateLogger("MyCategory");
ApplicationInsigthsConversationScopedLoggerProvider: Initializes a new instance of the class. It takes an IOptions<ApplicationInsightsConversationScopedLoggerOptions>, a TelemetryClient, and an IHttpContextAccessor.As an implementation of the ILoggerProvider interface, this class should implement methods such as CreateLogger and Dispose.
ConversationStateLoggerMiddleware is a middleware that automatically saves logger in conversation state. It implements the IMiddleware interface.
To use this middleware, you need to create an instance and provide the necessary parameters:
ConversationState conversationState = new ConversationState(new MemoryStorage());
var middleware = new ConversationStateLoggerMiddleware(conversationState);
You can then add this middleware to your bot:
botAdapter.Use(middleware);
GitHub Copilot: This C# code defines a class ConversationStateLoggerMiddleware that implements the IMiddleware interface. This middleware is designed to automatically save logger in conversation state.
Here's a brief explanation of the key components:
ConversationStateLoggerMiddleware: This is the constructor for the class. It takes a ConversationState as a parameter, which is used to initialize the conversationState field.
OnTurnAsync: This method saves the activity of the context in BotState by conversation id. It takes a ITurnContext, a NextDelegate, and an optional CancellationToken as parameters.
Here's how you might include this in a README:
ConversationStateLoggerMiddleware is a middleware that automatically saves logger in conversation state. It implements the IMiddleware interface.
To use this middleware, you need to create an instance and provide the necessary parameters:
ConversationState conversationState = new ConversationState(new MemoryStorage());
var middleware = new ConversationStateLoggerMiddleware(conversationState);
You can then add this middleware to your bot:
botAdapter.Use(middleware);
ConversationStateLoggerMiddleware: Initializes a new instance of the class. It takes a ConversationState.As an implementation of the IMiddleware interface, this class should implement methods such as OnTurnAsync. This method saves the activity of the context in BotState by conversation id.
DetectedLanguageTranslatorMiddleware is a middleware that automatically translates from a detected language to a configured translation language. It implements the IMiddleware interface.
To use this middleware, you need to create an instance and provide the necessary parameters:
CultureInfo translateToLanguage = new CultureInfo("en-US");
IEnumerable<CultureInfo> languageExceptions = new List<CultureInfo> { new CultureInfo("fr-FR") };
string languageDetectionServiceName = "YourLanguageDetectionServiceName";
string textTranslationServiceName = "YourTextTranslationServiceName";
ICognitiveServiceProvider cognitiveServiceProvider = new YourCognitiveServiceProvider();
var middleware = new DetectedLanguageTranslatorMiddleware(translateToLanguage, languageExceptions, languageDetectionServiceName, textTranslationServiceName, cognitiveServiceProvider);
You can then add this middleware to your bot:
botAdapter.Use(middleware);
DetectedLanguageTranslatorMiddleware: Initializes a new instance of the class. It takes a CultureInfo for the language to translate to, an IEnumerable<CultureInfo> for languages that are exceptions to translate, the names of a language detection cognitive service and a text translation cognitive service, and an ICognitiveServiceProvider to locate these services.As an implementation of the IMiddleware interface, this class should implement methods such as OnTurnAsync.
StartActivityTranslatorMiddleware is a middleware that automatically translates messages sent to consumers during start activities into the language received as Activity.Locale. It implements the IMiddleware interface.
To use this middleware, you need to create an instance and provide the necessary parameters:
string textTranslationServiceName = "YourTextTranslationServiceName";
ICognitiveServiceProvider cognitiveServiceProvider = new YourCognitiveServiceProvider();
var middleware = new StartActivityTranslatorMiddleware(textTranslationServiceName, cognitiveServiceProvider);
You can then add this middleware to your bot:
botAdapter.Use(middleware);
StartActivityTranslatorMiddleware: Initializes a new instance of the class. It takes a textTranslationServiceName and an ICognitiveServiceProvider to locate a language detection and a text translation service from the given names.
StartActivityTranslatorMiddleware: Initializes a new instance of the class. It takes an ITextTranslationService to translate texts.
As an implementation of the IMiddleware interface, this class should implement methods such as OnTurnAsync.
TranslatorUtils is a static class that provides utility methods for translation operations.
You can use the methods in this class as follows:
IDictionary<string, string> translations = new Dictionary<string, string> { { "en-US", "Hello" } };
CultureInfo language = new CultureInfo("en-US");
string translation = TranslatorUtils.GetTranslation(translations, language, "Default text");
ITextTranslationService translationService = new YourTextTranslationService();
IList<Activity> activities = new List<Activity> { new Activity { Type = ActivityTypes.Message, Text = "Hola" } };
CultureInfo fromLanguage = new CultureInfo("es-ES");
CultureInfo toLanguage = new CultureInfo("en-US");
CancellationToken cancellationToken = new CancellationToken();
await TranslatorUtils.TranslateMessagesAsync(translationService, activities, fromLanguage, toLanguage, cancellationToken);
GetTranslation: Retrieves a translation from a dictionary of translations based on the provided language. If no translation is found, it returns a default text.
TranslateMessagesAsync: Translates message type activities from one language to another using a provided ITextTranslationService. It also handles cancellation through a CancellationToken.
ApplicationInsightsConversationScopedLoggerOptions is a class that customizes the behavior of the tracing information sent to Application Insights using ApplicationInsigthsConversationScopedLogger. It inherits from ApplicationInsightsLoggerOptions.
To use this class, you need to create an instance and optionally set the EventsToTrack:
var options = new ApplicationInsightsConversationScopedLoggerOptions
{
EventsToTrack = new List<string> { "Event1", "Event2" }
};
ApplicationInsightsConversationScopedLoggerOptions: Initializes a new instance of the class. It doesn't take any parameters.EventsToTrack: Gets or sets a list of event names that should be tracked. If null, all events will be tracked.SendAnswersProcessorBase is an abstract class that processes and handles a collection of answers. It inherits from OrderableHandlerManagerBase<ISendAnswersHandler> and implements ISendAnswersProcessor interface.
To use this class, you need to create a derived class and provide the necessary implementations:
public class MySendAnswersProcessor : SendAnswersProcessorBase
{
public MySendAnswersProcessor(IEnumerable<ISendAnswersHandler> handlers) : base(handlers)
{
}
public override Task<SendResponseResult> SendResponseAsync<TAnswer>(ITurnContext context, IEnumerable<TAnswer> answers, CancellationToken cancellationToken)
{
// Your implementation here
}
}
SendAnswersProcessorBase: Initializes a new instance of the class. It takes an IEnumerable<ISendAnswersHandler> as a parameter, which is a collection of answer handlers for this processor.SendResponseAsync: Sends a response by processing and handling a given collection of answers. It takes an ITurnContext, an IEnumerable<TAnswer>, and a CancellationToken as parameters. It returns a Task<SendResponseResult>.SimpleAnswersHandler is a class that sends the first answer found with the highest confidence score as the response. It implements the ISendAnswersHandler interface.
To use this class, you need to create an instance:
var handler = new SimpleAnswersHandler();
ITurnContext context = new YourTurnContext();
IEnumerable<IAnswer> answers = new List<IAnswer> { new YourAnswer() };
CancellationToken cancellationToken = new CancellationToken();
SendResponseResult result = await handler.HandleSendResponseAsync(context, answers, cancellationToken);
SimpleAnswersHandler: Initializes a new instance of the class. It doesn't take any parameters.Order: Ensures that this is the last response handler to be evaluated.HandleSendResponseAsync: Sends a response by handling a given collection of answers. They take an ITurnContext, an IEnumerable<TAnswer>, and a CancellationToken as parameters. They return a Task<SendResponseResult>.| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 netstandard2.1 is compatible. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 1 NuGet packages that depend on Encamina.Enmarcha.Bot:
| Package | Downloads |
|---|---|
|
Encamina.Enmarcha.Bot.Skills.QuestionAnswering
Package Description |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 8.3.0 | 880 | 9/10/2025 |
| 8.3.0-preview-02 | 307 | 9/10/2025 |
| 8.3.0-preview-01 | 293 | 9/8/2025 |
| 8.2.1-preview-08 | 296 | 8/18/2025 |
| 8.2.1-preview-07 | 291 | 8/12/2025 |
| 8.2.1-preview-06 | 284 | 8/11/2025 |
| 8.2.1-preview-05 | 344 | 8/5/2025 |
| 8.2.1-preview-04 | 365 | 7/15/2025 |
| 8.2.1-preview-03 | 337 | 7/14/2025 |
| 8.2.1-preview-02 | 334 | 7/3/2025 |
| 8.2.1-preview-01 | 868 | 3/23/2025 |
| 8.2.0 | 2,971 | 10/22/2024 |
| 8.2.0-preview-01-m01 | 216 | 9/17/2024 |
| 8.1.9-preview-03 | 270 | 11/19/2024 |
| 8.1.9-preview-02 | 221 | 10/22/2024 |
| 8.1.9-preview-01 | 383 | 10/4/2024 |
| 8.1.8 | 340 | 9/23/2024 |
| 8.1.8-preview-07 | 1,364 | 9/12/2024 |
| 8.1.8-preview-06 | 299 | 9/11/2024 |