Botframework Composer Custom Action not registered in factory

Viewed 252

I have an existing bot. I have added a custom action as described in the official docs. When the bot is started, only the errormessage:

mybot.dialog error: Type Mycustomaction not registered in factory.

is displayed in the chat window.

Initially the bot was created with Composer 1.x After migrating to Composer 2.x the existing custom actions did not work and adding new custom actions fails.

2 Answers

This error comes if you haven't added the new custom action in the appsettings.json file of the bot under components

mybot.dialog error: Type Mycustomaction not registered in factory.

"components": [
  {
    "name": "FirstCustomAction"
  },
  {
    "name": "SecondCustomAction"
  }
],

It can also occur if you are stupid like me and just copy the BotComponent class from some other component and forget to update it to register the new one :D

public class MyDialogBotComponent : BotComponent
{
   public override void ConfigureServices(IServiceCollection services, IConfiguration configuration)
   {
      services.AddSingleton<DeclarativeType>(sp => new DeclarativeType<MyDialog>(MyDialog.Kind));
   }
}

Or if your

[JsonProperty("$kind")] public const string Kind = nameof(MyDialog);

Is not updated to the new component

Related