Iciclecreek.Bot.Builder.Dialogs 4.16.1-preview

This is a prerelease version of Iciclecreek.Bot.Builder.Dialogs.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Iciclecreek.Bot.Builder.Dialogs --version 4.16.1-preview
NuGet\Install-Package Iciclecreek.Bot.Builder.Dialogs -Version 4.16.1-preview
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Iciclecreek.Bot.Builder.Dialogs" Version="4.16.1-preview" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Iciclecreek.Bot.Builder.Dialogs --version 4.16.1-preview
#r "nuget: Iciclecreek.Bot.Builder.Dialogs, 4.16.1-preview"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Iciclecreek.Bot.Builder.Dialogs as a Cake Addin
#addin nuget:?package=Iciclecreek.Bot.Builder.Dialogs&version=4.16.1-preview&prerelease

// Install Iciclecreek.Bot.Builder.Dialogs as a Cake Tool
#tool nuget:?package=Iciclecreek.Bot.Builder.Dialogs&version=4.16.1-preview&prerelease

Overview

This library provides two base clases

  • IcyBot - A simplified 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 (called IcyBot). The root dialog is the first Dialog registered in DI.

There is a helper extension AddBot() which registers the bot and ensures that state/memory scopes are registered.

var sp = new ServiceCollection()
    .AddSingleton<IStorage>(new MemoryStorage()) // or whatever storage you want.
    .AddSingleton<Dialog, TestDialog>()
    .AddSingleton<Dialog, 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.

  1. 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.
  2. The default OnTurnAsync() will dispatch to strongly typed virtual methods (like ActivityHandler), but with DialogContext instead of TurnContext:

    • OnMessageActivityAsync(dc)
    • OnEndOfConversationAsync(dc)
    • OnMessageReactionActivityAsync(dc)
    • OnAdaptiveCardInvoke(dc)
    • etc.
  3. The default OnMessageActivity will invoke the Recognizer and route the activity using OnRecognizedIntentAsync()/OnUnrecognizedIntentAsync() methods

  4. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 164 5/26/2023
4.20.0 148 6/16/2023
4.19.11 136 5/25/2023
4.19.10 134 5/25/2023
4.19.9 138 5/16/2023
4.19.8 129 5/13/2023
4.19.7 124 5/13/2023
4.19.6 127 5/13/2023
4.19.5 144 5/13/2023
4.19.4 134 5/12/2023
4.19.3 149 5/11/2023
4.19.2 159 5/2/2023
4.19.0 202 4/15/2023
4.16.7 407 5/8/2022
4.16.6 386 5/6/2022
4.16.5 403 5/5/2022
4.16.4 391 5/2/2022
4.16.3 386 5/1/2022
4.16.2-preview 137 4/27/2022
4.16.1-preview 143 4/27/2022
4.16.0-preview 137 4/26/2022