Search code examples
c#botframework

Bot Framework v4.4.3 Update Skill Manifest Template


The document here says update skill manifest but does not specify how to add a new skill in the manifest file.

I have the following in the main dialog:

case MasterCollectionsLuis.Intent.PlayVideo:
                        {
                            turnResult = await dc.BeginDialogAsync(nameof(Water.PlayVideo.PlayVideoDialog));
                            break;
                        }

And have a base for PlayVideo and the Dialog itself as shown by the example SampleDialog and SampleDialogBase.

When I load the manifest file at http://localhost:1205/api/skill/manifest:

An unhandled exception occurred while processing the request.
InvalidOperationException: Unable to resolve service for type 'MasterCollections.Dialogs.Water.PlayVideo.PlayVideoDialog' while attempting to activate 'MasterCollections.Dialogs.MainDialog'.
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, bool throwIfCallSiteNotFound)

Solution

  • Dependency Injection error

    That error is to do with the dependency injection pipeline, without setting your Startup.cs file my best guess is that you haven't wired up PlayVideoDialog in there.

    In your Startup.cs file you will have a section where you register your Dialogs against the dependency injection service provider like so:

    services.AddTransient<CancelDialog>();
    services.AddTransient<EscalateDialog>();
    services.AddTransient<MainDialog>();
    

    You simply need to add another line each time you add a new Dialog:

    services.AddTransient<MyNewDialog>();
    

    In your case you would have PlayVideoDialog in place of MyNewDialog.

    Also make sure that you are not passing a PlayVideoDialog parameter into the constructor of MainDialog as this is not how Dialogs work, you should instead call the AddDialog(new PlayVideoDialog(...)) method inside the constructor of MainDialog.

    Skills manifest question

    I haven't created a skill myself but there is additional documentation which may or may not be helpful about adding skill support, adding skills, and the skills manifest file itself.

    In the documentation that you linked it states:

    this has been pre-populated with the Skill ID and name and a sample action which you can modify at this stage if required

    which leads me to believe you can manually modify this file to fit your requirements, but you don't have to modify it if there are no changes required.