Iciclecreek.Bot.Builder.Dialogs
4.16.2-preview
See the version list below for details.
dotnet add package Iciclecreek.Bot.Builder.Dialogs --version 4.16.2-preview
NuGet\Install-Package Iciclecreek.Bot.Builder.Dialogs -Version 4.16.2-preview
<PackageReference Include="Iciclecreek.Bot.Builder.Dialogs" Version="4.16.2-preview" />
paket add Iciclecreek.Bot.Builder.Dialogs --version 4.16.2-preview
#r "nuget: Iciclecreek.Bot.Builder.Dialogs, 4.16.2-preview"
// Install Iciclecreek.Bot.Builder.Dialogs as a Cake Addin #addin nuget:?package=Iciclecreek.Bot.Builder.Dialogs&version=4.16.2-preview&prerelease // Install Iciclecreek.Bot.Builder.Dialogs as a Cake Tool #tool nuget:?package=Iciclecreek.Bot.Builder.Dialogs&version=4.16.2-preview&prerelease
Overview
This library provides two base clases
- IcyBot - An IBot implementation for code first bots without adaptive infrastructure dependencies.
- IcyDialog - A base dialog which simplifies the creation of code based recognizer based dialogs
IBot
The library provides a default IBot implementation that uses dependency injection to get the dialogs. The root dialog is the first Dialog registered in DI.
There is a service extension AddBot() which registers the bot and ensures that state/memory scopes are registered.
var sp = new ServiceCollection()
.AddSingleton<IStorage,MemoryStorage>() // or whatever storage you want.
.AddDialog<TestDialog>()
.AddDialog<FooDialog>()
.AddBot()
.BuildServiceProvider();
NOTE: This bot is not set up to handle skills, lg, etc. If you want all of that stuff you should use an the Adaptive.Runtime This bot is a suitable for simple bots that don't need multi-language declarative support, etc.
IcyDialog
IcyDialog encapsulates a number of patterns together to make a great base class for creating code-first dialogs.
hides BeginDialog/ContinueDialog and models the dialog simply as OnTurnAsync()
- dialog Options are autoamtically captured via dc.SaveOptions() and available via dc.GetOptions() on any turn.
The default OnTurnAsync() implementation will dispatch to strongly typed virtual methods (like ActivityHandler), but with DialogContext instead of TurnContext:
- OnMessageActivityAsync(dc)
- OnEndOfConversationAsync(dc)
- OnMessageReactionActivityAsync(dc)
- OnAdaptiveCardInvoke(dc)
- etc.
The default OnMessageActivity() implementation will invoke the Recognizer and route the activity using OnRecognizedIntentAsync()/OnUnrecognizedIntentAsync() methods
The default OnRecognizedIntentAsync() implementation will resolve methods to intent handlers using the following naming pattern:
protected Task<DialogTurnResult> OnXXXIntent(DialogContext dc, IMessageActivity messageActivity, TopScore topSCore, CancellationToken ct);
Examples:
- "Greeting" intent ⇒ OnGreetingIntent(dc, IMessageActivity, topScore, cancellationToken)
- "Goodbye" intent ⇒ OnGoodbyeIntent(dc, IMessageActivity, topScore, cancellationToken)
- "None" or empty intents ⇒ OnUnrecognizedIntent(dc, IMessageActivity, cancallationToken)
Sample dialog:
public class TestDialog : IcyDialog
{
public TestDialog()
{
// create a recognizer
this.Recognizer = new LucyRecognizer()
{
Intents = new string[] { "Greeting", "HighFive", "Goodbye", "Foo" },
Model = YamlConvert.DeserializeObject<LucyDocument>(...)
};
}
protected async Task<DialogTurnResult> OnGreetingIntent(DialogContext dc, IMessageActivity messageActivity, RecognizerResult recognizerResult, CancellationToken cancellationToken)
{
await dc.SendActivityAsync("Hello");
return await dc.WaitForInputAsync();
}
protected async Task<DialogTurnResult> OnHighFiveIntent(DialogContext dc, IMessageActivity messageActivity, RecognizerResult recognizerResult, CancellationToken cancellationToken)
{
await dc.SendActivityAsync("Slap!");
return await dc.WaitForInputAsync();
}
protected async Task<DialogTurnResult> OnFooIntent(DialogContext dc, IMessageActivity messageActivity, RecognizerResult recognizerResult, CancellationToken cancellationToken)
{
return await dc.BeginDialog<FooDialog>(1, cancellationToken: cancellationToken);
}
protected async Task<DialogTurnResult> OnGoodbyeIntent(DialogContext dc, IMessageActivity messageActivity, RecognizerResult recognizerResult, CancellationToken cancellationToken)
{
await dc.SendActivityAsync("Goodbye");
return await dc.EndDialogAsync();
}
protected override async Task<DialogTurnResult> OnEndOfConversationActivityAsync(DialogContext dc, IEndOfConversationActivity endOfConversationActivity, CancellationToken cancellationToken)
{
await dc.SendActivityAsync("EndOfConversation");
return await dc.CancelAllDialogsAsync();
}
}
}
Extension Helpers
The library includes some helpful extensions to reduce typing.
- dc.SaveOptions(options) and dc.GetOptions<T>() - methods for capturing and retrieving the options
- dc.WaitForInputAsync() - signal that your dialog is waiting input.
- dc.SendActivity() - shortcut for dc.Context.SendActivity()
- dc.BeginDialog<DialogT>() - begins a dialog assuming that the name of DialogT is the id of the dialog.
- dialogSet.Add<DialogT>() - Add an instance of dialogT to a dialogset
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.Bot.Builder.Dialogs (>= 4.16.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
4.20.11 | 177 | 5/26/2023 |
4.20.0 | 177 | 6/16/2023 |
4.19.11 | 163 | 5/25/2023 |
4.19.10 | 158 | 5/25/2023 |
4.19.9 | 158 | 5/16/2023 |
4.19.8 | 156 | 5/13/2023 |
4.19.7 | 155 | 5/13/2023 |
4.19.6 | 160 | 5/13/2023 |
4.19.5 | 168 | 5/13/2023 |
4.19.4 | 165 | 5/12/2023 |
4.19.3 | 169 | 5/11/2023 |
4.19.2 | 180 | 5/2/2023 |
4.19.0 | 228 | 4/15/2023 |
4.16.7 | 434 | 5/8/2022 |
4.16.6 | 414 | 5/6/2022 |
4.16.5 | 429 | 5/5/2022 |
4.16.4 | 417 | 5/2/2022 |
4.16.3 | 413 | 5/1/2022 |
4.16.2-preview | 168 | 4/27/2022 |
4.16.1-preview | 172 | 4/27/2022 |
4.16.0-preview | 161 | 4/26/2022 |